--势力宝箱界面 local UICommandTheWorldReward = UIViewClass() --region 生命周期方法 function UICommandTheWorldReward:OnOpened() UIManager.ActiveUIModle(false, "UICommandTheWorldReward") self:RegistSystemEvent(EventID.UI_CommandTheWorld_RefreshGuildReward, self.InitData) --刷新势力宝箱界面 UTL.Item.SetLocalizationImage(self.loc_TitleLoc, self.img_Title, "hltxtc_msz_scbx.png") --获取宝箱列表数据 self.rewardList = MDL.CommandTheWorld.GetCommandWorldLevelReward() self:InitData() end function UICommandTheWorldReward:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UICommandTheWorldReward:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UICommandTheWorldReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Tasks then local rewardData = data.data --威望等级 UIUtils.SetLabel(cellTable.txt_ConditionTitle,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_PrestigeLV,tostring(rewardData.Level))) --需求积分 UIUtils.SetLabel(cellTable.txt_ConditionInfo,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_PrestigeValue,tostring(rewardData.Integral))) --显示奖励列表 for i,v in ipairs(rewardData.Reward_Table) do UTL.Item.SetItemCell(cellTable.group_Prize[i], v.RewardID, v.RewardNum) end --显示领取状态 cellTable.state_Btn:SetState(data.hasGetReward and 1 or 0) --判断是否可领取 cellTable.event_Collect:SetGray(not data.isCanGet) end end function UICommandTheWorldReward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Tasks then if target == cellTable.event_Collect then if not MDL.Guild.IsHasGuild() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Bag_Tips_NoGuild) return end MDL.CommandTheWorld.ClaimCommandWorldGuildTreasureBoxReq(data.data.Level) return end --道具点击 for i, v in ipairs(cellTable.group_Prize) do if v.event_Click == target then local rewardTable = data.data.Reward_Table UTL.ItemTips.ShowCommonTipsById(rewardTable[i].RewardID) end end end end function UICommandTheWorldReward:OnClosed() UIManager.ActiveUIModle(true, "UICommandTheWorldReward") end --endregion -- 排序“可领取”状态>“不可领取”状态>“已领取”状态,相同状态的排序,按照奖励等级由小到大排序 local function SortRewards(a, b) if a.hasGetReward and b.hasGetReward then return a.data.Level < b.data.Level end if a.hasGetReward then return false end if b.hasGetReward then return true end if a.isCanGet and b.isCanGet then return a.data.Level < b.data.Level end if a.isCanGet then return true end if b.isCanGet then return false end return a.data.Level < b.data.Level end function UICommandTheWorldReward:InitData() self.rewardData = {} for i,v in ipairs(self.rewardList) do self.rewardData[i]= {} self.rewardData[i].data = v self.rewardData[i].isCanGet = MDL.CommandTheWorld.IsCanGetLevelRewardByLevel(v.Level) self.rewardData[i].hasGetReward = MDL.CommandTheWorld.IsGetLevelRewardByLevel(v.Level) end table.sort(self.rewardData, SortRewards) self.loop_Tasks:ReloadAll(self.rewardData) end return UICommandTheWorldReward