12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- ---@class KLTaskFinishPanel:UIKmlLuaPanelBase
- ---@field view KLTaskFinishPanelView
- local KLTaskFinishPanel = class(UIKmlLuaPanelBase)
- local this =KLTaskFinishPanel
- ---创建时调用一次
- function this:Init()
- self.finishTaskId = self.args.taskId
- self.retMap = {}
- self.retList = {}
- self:GetRewardMap()
- GUI:DataListInitData( self.view.award_list,function()
- return table.count(self.retList)
- end,function(realIndex)
-
- end,function(realIndex, kmlcontrol)
- return self:DataListItemInitFunc(realIndex, kmlcontrol)
- end, function(realIndex, kmlcontrol)
- end)
- end
- function this:DataListItemInitFunc(realIndex, kmlcontrol)
- local item = GUI:GetChildControl(self.view.award_list,realIndex,'award_item')
-
- local cfgId = self.retList[realIndex+1]
- local itemCount = self.retMap[cfgId].count
- GUI:Item_UpdataData(item, {
- itemid = cfgId,
- itemcount = tostring(itemCount)
- })
-
- GUI:AddOnClickEvent(item, self, function()
- SL:OpenTips(nil,cfgId)
- end)
- end
- function this:GetRewardMap()
- local allTasks = SL:TaskInfo_GetAllTasks()
- local boxItem = allTasks[self.finishTaskId].boxReward
- for _, boxInfo in pairs(boxItem) do
- self.retMap[boxInfo.cfgId] = boxInfo
- table.insert(self.retList, boxInfo.cfgId)
- end
- local rewardList = SL:GetConfig('cfg_task', self.finishTaskId).rewardItem
- for _, boxInfo in pairs(rewardList) do
- local cfgId = boxInfo[1]
- local count = boxInfo[2]
- if self.retMap[cfgId] then
- self.retMap[cfgId]["count"] = self.retMap[cfgId]["count"] + count
- else
- self.retMap[cfgId] = {
- cfgId = cfgId,
- count = SL:GetSimpleNumber(count, 0)
- }
- table.insert(self.retList, cfgId)
- end
- end
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- local task_title = SL:GetConfig('cfg_task', self.finishTaskId).title
- GUI:Text_setString(self.view.LabelTask, task_title)
- local diaLogDone = SL:GetConfig('cfg_task', self.finishTaskId).diaLogDone
- GUI:Text_setString(self.view.LabelDesc, diaLogDone)
- GUI:DataListUpdateData(self.view.award_list)
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.BtnClose,self,self.BtnClose)
- GUI:AddOnClickEvent(self.view.BtnGet,self,self.BtnGet)
- end
- function this:Close()
- SL.ShowMainPanel()
- end
- function this:BtnClose()
- GUI:UIPanel_Close("dev/ui/Task/Panel/KLTaskFinish/KLTaskFinishPanel")
- end
- function this:BtnGet()
- SL:ReqSubmitTaskMessage(self.finishTaskId, 1)
- GUI:UIPanel_Close("dev/ui/Task/Panel/KLTaskFinish/KLTaskFinishPanel")
- end
- return this
|