local UIRedEnvelopeRainReward = UIViewClass() -- 排行奖励界面 -- context = { rankType = EnvelopeRainRankType } 打开界面的排行榜类型 local RedEnvelopeRainStar = DataSheetManager.ConstData:GetDataByID("RedEnvelopeRainStar").DateValue -------------------- function UIRedEnvelopeRainReward:OnCreated() self.curRightLoopTab = 0 end function UIRedEnvelopeRainReward:OnOpened(context) self.activityType = MDL.OperationActivity.ActivityType.RedEnvelopeRain self.curActivityId = CTL.RedEnvelopRain.GetCurOpenRedEnvelopRainActivityId() self:InitPanel() if context.rankType == MDL.RedEnvelopRain.EnvelopeRainRankType.AllRank then self.UICommonPopUpTab.loop_Tab:SelectIndex(1) else self.UICommonPopUpTab.loop_Tab:SelectIndex(0) end end function UIRedEnvelopeRainReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUpTab.btn_Close) end function UIRedEnvelopeRainReward:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView(false) end end function UIRedEnvelopeRainReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then if data == MDL.RedEnvelopRain.EnvelopeRainRankRewardType.TodayRank then UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS.IDS_RedEnvelopeRain_RankingToday) UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS.IDS_RedEnvelopeRain_RankingToday) else UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS.IDS_RedEnvelopeRain_TotalRanking) UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS.IDS_RedEnvelopeRain_TotalRanking) end cellTable.state_ArrowState:SetState(0) elseif scrollRect == self.loop_Reward then -- 设置背景 cellTable.State:SetState(index % 2 == 0 and 0 or 1) -- 设置名次 if data.Rank <= 3 then cellTable.state_Rank:SetState(data.Rank - 1) else cellTable.state_Rank:SetState(3) local beforeData if self.curRightLoopTab == MDL.RedEnvelopRain.EnvelopeRainRankRewardType.TodayRank then beforeData = MDL.OperationActivity.RedEnvelopeRainDailyRank:GetDataByActivityID_ID(self.curActivityId, data.ID - 1) else beforeData = MDL.OperationActivity.RedEnvelopeRainTotalRank:GetDataByActivityID_ID(self.curActivityId, data.ID - 1) end if beforeData.Rank + 1 >= data.Rank then UIUtils.SetLabel(cellTable.txt_Rank, data.Rank) else UIUtils.SetLabel(cellTable.txt_Rank, string.format("%s—%s", beforeData.Rank + 1, data.Rank)) end end -- 设置奖励 for i, rewardData in ipairs(data.RankReward_Table) do local itemObj = cellTable.content[i] if not itemObj then itemObj = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.content, self.Item_template.gameObject) end UIUtils.SetActive(itemObj.gameObject, true) UTL.Item.SetItemCell(itemObj, rewardData.RankRewardID, rewardData.RankRewardNum) end for i = #data.RankReward_Table + 1, #cellTable.content do UIUtils.SetActive(cellTable.content[i].gameObject, false) end end end function UIRedEnvelopeRainReward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then self.curRightLoopTab = data if self.loop_Reward.Count > 0 then self.loop_Reward:ClearCells() end if data == MDL.RedEnvelopRain.EnvelopeRainRankRewardType.TodayRank then local _, _, timeStr = UTL.Time.FormatTimeSimple(UTL.Time.GetServerZeroTimestamp() + RedEnvelopeRainStar) UIUtils.SetLabel(self.txt_Notice, string.FormatByIdsId(Const_IDS.IDS_RedEnvelopeRain_SettlementTips1, timeStr)) -- 设置排名数据 for _, data in MDL.OperationActivity.RedEnvelopeRainDailyRank:GetEnumerator() do self.loop_Reward:AddData(data, 0) end else local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, CTL.RedEnvelopRain.GetCurOpenRedEnvelopRainActivityId()) if activityInfo then --时区跨天的情况 local timeDiff = UTL.Time.GetServerZeroTimestampByTimestamp(activityInfo.endTime) + RedEnvelopeRainStar - activityInfo.endTime if timeDiff > 0 then --当时间差大于0的时候 默认是需要回退一天的 UIUtils.SetLabel(self.txt_Notice, string.FormatByIdsId(Const_IDS.IDS_RedEnvelopeRain_SettlementTips2, UTL.Time.FormatTimeCompletely(UTL.Time.GetServerZeroTimestampByTimestamp(activityInfo.endTime) + RedEnvelopeRainStar - UTL.Time.TotalSecondsOneDay))) else --当时间差小于0的时候 默认是当天 UIUtils.SetLabel(self.txt_Notice, string.FormatByIdsId(Const_IDS.IDS_RedEnvelopeRain_SettlementTips2, UTL.Time.FormatTimeCompletely(UTL.Time.GetServerZeroTimestampByTimestamp(activityInfo.endTime) + RedEnvelopeRainStar))) end end -- 设置排名数据 for _, data in MDL.OperationActivity.RedEnvelopeRainTotalRank:GetEnumerator() do self.loop_Reward:AddData(data, 0) end end elseif scrollRect == self.loop_Reward then for i, itemObj in ipairs(cellTable.content) do if itemObj.event_Click == target then local itemData = data.RankReward_Table[i] UTL.ItemTips.ShowCommonTipsById(itemData.RankRewardID) end end end end -------------------- function UIRedEnvelopeRainReward:InitPanel() -- 设置标题 UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS.IDS_BattlefieldMuster_RankReward) -- 初始化Tab列表 self.UICommonPopUpTab.loop_Tab:AddData(MDL.RedEnvelopRain.EnvelopeRainRankRewardType.TodayRank, 0) self.UICommonPopUpTab.loop_Tab:AddData(MDL.RedEnvelopRain.EnvelopeRainRankRewardType.AllRank, 0) end return UIRedEnvelopeRainReward