tcx_xiyou_yueNan
DESKTOP-MMO982B\User 2026-07-23 22:03:17 +08:00
parent f8e8fd3bb7
commit 410e424903
4 changed files with 256 additions and 0 deletions

View File

@ -537,6 +537,7 @@ UIName = {
GodsWayListPanelNew=545,--多队塔列表
BecomeAGodPanel=546,--多队塔成神界面
BecomeAGodPropertyPanel=547,--多队塔成神升级界面
DailyShoppingPanel = 548, --每日代金券
}
SubUIConfig = {

View File

@ -1374,6 +1374,8 @@ function this:TabBtnAction(id, actType, data)
UIManager.OpenPanel(UIName.ActivityMainPanel, id)
elseif id == FUNCTION_OPEN_TYPE.XiaoYaoYou then
XiaoYaoManager.OpenMapList()
elseif id == 164 then
UIManager.OpenPanel(UIName.DailyShoppingPanel)
elseif id == FUNCTION_OPEN_TYPE.TRIAL then
if ActTimeCtrlManager.SingleFuncState(30) then
CarbonManager.difficulty = 2

View File

@ -0,0 +1,246 @@
require("Base/BasePanel")
DailyShoppingPanel = Inherit(BasePanel)
local this = DailyShoppingPanel
-- 初始化组件(用于子类重写)
function DailyShoppingPanel:InitComponent()
this.spLoader = SpriteLoader.New()
self.actConfig = ConfigManager.GetConfigData(ConfigName.ActivityGroups, 15604)
self.Reward = Util.GetGameObject(self.gameObject, "BG/ShopList")
self.itemPre = Util.GetGameObject(self.gameObject, "shopItem")
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.btnClose = Util.GetGameObject(self.gameObject, "BG/CloseBtn")
this.localList = Util.GetGameObject(self.gameObject, "BG/ShopList")
self.endTimeBg = Util.GetGameObject(self.gameObject,"BG/DownBG/growPack")
self.endTime = Util.GetGameObject(self.endTimeBg,"Time"):GetComponent("Text")
end
-- 绑定事件(用于子类重写)
function DailyShoppingPanel:BindEvent()
-- 关闭界面打开主城
Util.AddClick(this.btnBack, function ()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
this:ClosePanel()
end)
Util.AddClick(this.btnClose, function ()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
this:ClosePanel()
end)
end
function DailyShoppingPanel:RefreshData()
self.shopData = DynamicActivityManager.GetGiftDataByType(self.actConfig.ShopData)
for i = 1, 4 do
local itempre = Util.GetGameObject(self.gameObject, "BG/ShopList/shopItem (" .. i .. ")")
if self.shopData[i] then
itempre:SetActive(true)
self:RefreshShowData(itempre, self.shopData[i])
else
itempre:SetActive(false)
end
end
--[[
if not self.scrollView then
-- 更改完空间大小后再生成滚动条
local rootHight = self.Reward.transform.rect.height
local width = self.Reward.transform.rect.width
self.scrollView = SubUIManager.Open(
SubUIConfig.ScrollCycleView, self.Reward.transform, self.itemPre, nil, Vector2.New(width, rootHight), 2, 2,
Vector2.New(0, 10)
)
self.scrollView.moveTween.MomentumAmount = 1
self.scrollView.moveTween.Strength = 2
self.scrollView.elastic = false
end
]]
-- 刷新剩余时间
self:GetRemainTime()
-- 刷新商品数据
-- self:RefreshGiftData()
end
-- 刷新礼包的数据
function DailyShoppingPanel:RefreshGiftData()
self.scrollView:ForeachItemGO(function (growIndex, go)
go.gameObject:SetActive(false)
end)
local callBack = function (growIndex, item)
self:RefreshShowData(item, self.shopData[growIndex], growIndex)
end
local growIndex = 0
self.scrollView:SetData(self.shopData, callBack, false, false)
-- LogError("sssssssssssssssssssssss " .. #self.shopData)
for i = 1, #self.shopData do
if self.shopData[i].DataType == DynamicActivityManager.selectIndex.dataType then
for j = 1, #DynamicActivityManager.selectIndex.goodsId do
if (self.shopData[i].data.shopData.id or self.shopData[i].data.shopData.goodsId)
== DynamicActivityManager.selectIndex.goodsId[j] then
DynamicActivityManager.SetSelectIndex(0, {}, 1)
growIndex = i
break
end
end
end
if growIndex ~= 0 then
break
end
end
if growIndex ~= 0 then
self.scrollView:SetIndex(growIndex)
end
end
-- 刷新每一条的显示数据
function DailyShoppingPanel:RefreshShowData(item, _data)
-- LogError("ffffffffffffffffffff".._data.Id)
if not _data then
item.gameObject:SetActive(false)
return
end
item.gameObject:SetActive(true)
local _itemData = { _data.data.shows[1][1], _data.data.shows[1][2], _data.data.shows[1][3] }
local itemSId = tonumber(_itemData[1])
local itemNum = tonumber(_itemData[2]) or 0
-- local Double:SetActive((_itemData[3] and _itemData[3] == 2) and true or false)
local itemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig, itemSId)
local itemName = Util.GetGameObject(item, "GameObject/bg/itemName"):GetComponent("Text")
local priceText = Util.GetGameObject(item, "GameObject/bg/price"):GetComponent("Text")
local numText = Util.GetGameObject(item, "GameObject/bg/num"):GetComponent("Text")
local icon = Util.GetGameObject(item, "GameObject/bg/item"):GetComponent("Image")
itemName.text = GetLanguageStrById(itemConfig.Name)
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfig.ResourceID))
priceText.text = "" .. _data.data.price
numText.text = "" .. itemNum
local btnBuy = Util.GetGameObject(item, "GameObject/bg")
local buyInfo = Util.GetGameObject(item, "GameObject/bg/buyLimitbg/tip"):GetComponent("Text")
local isCanBuy = (_data.data.limitNum - _data.data.boughtNum > 0) and 0 or 2
btnBuy:GetComponent("Button").interactable = (isCanBuy == 0 or isCanBuy == 1)
Util.SetGray(btnBuy, isCanBuy ~= 0)
if isCanBuy == 2 then
buyInfo.text = "已售罄"
else
-- 设置按钮提示 -- 已经购买不显示(特权礼包需要显示时间)
buyInfo.text = isCanBuy == 2 and "" or _data.data.buyInfo
end
Util.AddOnceClick(btnBuy, function ()
if isCanBuy == 0 then -- 0 可购买 1购买条件不足 2已购买
-- 道具商品
if _data.data.linkAct then
NetManager.GetActivityRewardRequest(_data.data.missionId, _data.data.activityId, function (drop)
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1, function ()
self:RefreshData()
end)
end)
else
-- 直购商品
PayManager.Pay(_data.data.shopData.goodsId, function (id)
FirstRechargeManager.RefreshAccumRechargeValue(_data.data.shopData.goodsId)
self:RefreshData()
end)
end
elseif isCanBuy == 2 then
PopupTipPanel.ShowTip(Language[10515])
end
end)
end
function DailyShoppingPanel:SpecialTime(t)
if not t or t < 0 then
return Language[11749]
end
local _sec = t % 60
local allMin = math.floor(t / 60)
local _min = allMin % 60
local allHour = math.floor(t / 3600)
local _hour = allHour % 24
local allDays = math.floor(t / 86400)
if allDays >= 1 then
return string.format(Language[11703], allDays), allDays
else
if _hour >= 1 then
return string.format(Language[11704], _hour), _hour
else
if _min >= 1 then
return string.format(Language[11705], _min), _min
else
return Language[12152]
end
end
end
return Language[11749]
end
-- 添加事件监听(用于子类重写)
function DailyShoppingPanel:AddListener()
end
-- 移除事件监听(用于子类重写)
function DailyShoppingPanel:RemoveListener()
end
-- 界面打开时调用(用于子类重写)
function DailyShoppingPanel:OnOpen(_sortIndex)
end
-- 界面打开时调用(用于子类重写)
function DailyShoppingPanel:OnShow()
self:RefreshData()
end
-- 每种礼包的剩余时间
function DailyShoppingPanel:GetRemainTime()
if self.actConfig.ShowTime == 0 then
self.endTimeBg.gameObject:SetActive(false)
return
end
self.endTimeBg.gameObject:SetActive(true)
-- 判断是否有timer
if self.localTimer then
self.localTimer:Stop()
self.localTimer = nil
end
local la = self.actConfig.ShowTime ~= 1 and Language[10023] or Language[11355]
local freshTime = 0
if self.shopData and #self.shopData > 0 then
freshTime = self.shopData[#self.shopData].data.endTime - GetTimeStamp()
end
self.endTime.text = la .. TimeToFelaxible(freshTime)
self.localTimer = Timer.New(function ()
self.endTime.text = la .. TimeToFelaxible(freshTime)
if freshTime <= 0 then
if self.actConfig.ActiveType > 0 then
local id = ActivityGiftManager.IsActivityTypeOpen(self.actConfig.ActiveType)
if id then
self:RefreshData(nil, true, true)
end
end
self:RefreshData(nil, true, true)
end
freshTime = freshTime - 1
end, 1, -1, true)
self.localTimer:Start()
end
local orginLayer
function DailyShoppingPanel:OnSortingOrderChange()
end
-- 界面关闭时调用(用于子类重写)
function DailyShoppingPanel:OnClose()
if self.localTimer then
self.localTimer:Stop()
self.localTimer = nil
end
end
function DailyShoppingPanel:OnFocus()
end
-- 界面销毁时调用(用于子类重写)
function DailyShoppingPanel:OnDestroy()
this.spLoader:Destroy()
if self.scrollView then
SubUIManager.Close(self.scrollView)
end
if self.localTimer then
self.localTimer:Stop()
self.localTimer = nil
end
self.scrollView = nil
end
return DailyShoppingPanel

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5dfdd0f5102fabf43af9f63d76d459db
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: