123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- ---@class KLEveryDayGiftRechargePanel:UIKmlLuaPanelBase
- ---@field view KLEveryDayGiftRechargePanelView
- local KLEveryDayGiftRechargePanel = class(UIKmlLuaPanelBase)
- local this =KLEveryDayGiftRechargePanel
- ---创建时调用一次
- function this:Init()
- self.allData = {}
- self.rewardShowList = {}
- GUI:DataListInitData(self.view.rewardShowDataList, function()
- return table.count(self.allData.rewardShowItem)
- end,function()
- end,function()
- end,function(realIndex)
- local ItemInfoSlotModelControl = GUI:GetChildControl(self.view.rewardShowDataList,realIndex,'ItemInfoSlotModel') --任务名称
- local info = self.allData.rewardShowItem[realIndex+1]
- GUI:Item_setItemId(ItemInfoSlotModelControl, info.itemId)
- GUI:Item_UpdataData(ItemInfoSlotModelControl,{itemcount = info.count})
- GUI:AddOnClickEvent(ItemInfoSlotModelControl,self,function()
- SL:OpenTips(nil, info.itemId)
- end)
- end)
- self.taskListInfo = {}
- GUI:DataListInitData(self.view.taskList, function()
- return table.count(self.allData.task)
- end,function()
- end,function()
- end,function(realIndex)
- local taskNameControl = GUI:GetChildControl(self.view.taskList,realIndex,'taskName') --任务名称
- local taskrewardlistControl = GUI:GetChildControl(self.view.taskList,realIndex,'taskrewardlist') --任务奖励列表
- local taskGetButtonControl = GUI:GetChildControl(self.view.taskList,realIndex,'getButton') --getButton
- local haveGainText = GUI:GetChildControl(self.view.taskList,realIndex,'haveGainText') --已领取
- local redpoint = GUI:GetChildControl(self.view.taskList,realIndex,'redpoint') --红点
- local info = self.allData.task[realIndex+1]
- GUI:Button_setTitleText(taskNameControl, info.task)
- GUI:setVisible(redpoint, false)
- GUI:setVisible(haveGainText,false)
- GUI:setVisible(taskGetButtonControl,true)
- if info.canGain and info.haveGain then
- GUI:Button_setTitleText(taskGetButtonControl, "已领取")
- GUI:setVisible(haveGainText,true)
- GUI:setVisible(taskGetButtonControl,false)
- elseif info.canGain then
- GUI:Button_setTitleText(taskGetButtonControl, "可领取")
- GUI:setVisible(redpoint, true)
- else
- GUI:Button_setTitleText(taskGetButtonControl, "前往")
- end
- GUI:AddOnClickEvent(taskGetButtonControl,self,self.GetButton,{ info})
- self:RewardItemUpdateFun(taskrewardlistControl,realIndex)
- end)
- end
- --Task奖励列表刷新
- function this:RewardItemUpdateFun(ItemInfoListControl,Index)
- local data = self.allData.task[Index+1]
- local showRewards={}
- for k,v in ipairs(data.gift) do
- table.insert(showRewards,v)
- end
- GUI:DataListInitData(ItemInfoListControl, function()
- return table.count(showRewards)
- end,function()
- end,function()
- end,function(realIndex)
- local taskRewardItemModel = GUI:GetChildControl(ItemInfoListControl,realIndex,'taskRewardItem') --模型
- local info = showRewards[realIndex+1]
- GUI:Item_setItemId(taskRewardItemModel, info.itemId)
- GUI:Item_UpdataData(taskRewardItemModel,{itemcount = info.count})
- GUI:AddOnClickEvent(taskRewardItemModel,self,function()
- SL:OpenTips(nil, info.itemId)
- end)
- end)
- GUI:DataListUpdateData(ItemInfoListControl)
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.FreeBtn, self, self.FreeBtn)
- SL:RegisterLUAEvent(LUA_EVENT_EVERYDAYGIFT_RECHARGE_CHANGE, this.LUA_EVENT_EVERYDAYGIFT_RECHARGE_CHANGE, self)
- end
- --服务器发送礼包组消息后刷新礼包组的数据
- function this:LUA_EVENT_EVERYDAYGIFT_RECHARGE_CHANGE()
- self:RefreshPanel()
- end
- ---免费馈赠领取按钮
- function this:FreeBtn()
- local FreeId = InfoManager.everyDayGiftRechargeInfo.EverDayGiftFreeDataId
- if not self.allData.dayFreeGift then --今日未领取过免费
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = 13, action = "reward", id = FreeId })
- else
- SL:TipMessage("今日已领取过", 1, NoticeType.NoticeMid )
- end
- end
- ---列表的领取按钮
- function this:GetButton(control, info)
- if info[1].canGain and info[1].haveGain then
- SL:TipMessage( "该奖励已领取", 1, NoticeType.NoticeMid )
- elseif info[1].canGain then
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = 13, action = "reward", id = info[1].id })
- else
- GUI:UIPanel_Close("dev/outui/MainRecharge/Panel/KLMainRecharge/KLMainRechargePanel")
- --跳转到每日礼包页签
- local navId = SL:GetConfig("cfg_global",20001).value
- GUI:UIPanel_Open("dev/outui/MainRecharge/Panel/KLMainRecharge/KLMainRechargePanel",_,_,{mainRechargeId = navId})
- end
- end
- ---界面显示时调用一次
- function this:Show()
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- self:RefreshPanel()
- end
- function this:RefreshPanel()
- self.taskListInfo = {}
- self.allData = InfoManager.everyDayGiftRechargeInfo.EveryDayGiftData
- GUI:Text_setString(self.view.everydayTaskText,"每日充值"..tostring(self.allData.needCost).."元即可领取以下奖励")
- if self.allData.dayFreeGift then --今日是否已经领取过免费馈赠
- GUI:setVisible(self.view.FreeBtn, false)
- GUI:setVisible(self.view.FreeGetImg, true)
- else
- GUI:setVisible(self.view.FreeBtn, true)
- GUI:setVisible(self.view.FreeGetImg, false)
- end
- GUI:Text_setString(self.view.roundsNum,"第"..tostring(self.allData.group).."轮")
- GUI:DataListUpdateData(self.view.rewardShowDataList)
- GUI:DataListUpdateData(self.view.taskList)
- end
- function this:Close()
- end
- return this
|