local UINewYearPrayReward = UIViewClass() local noLimitRewardItemId = DataSheetManager.ConstData:GetDataByID("PrayUnlimitedReward").IntValue function UINewYearPrayReward:OnOpened(context) self.activityId = context.activityId CTL.NewYear.SetCommonTitle(self.activityId, CTL.NewYear.ViewTitle.PrayRewardTitle, self:GetUICommonPopUp()) self:RefreshReward() end function UINewYearPrayReward:RefreshReward() if self.loop_Reward.Count > 0 then self.loop_Reward:ClearCells() end self.rareTable = {} for i, v in ipairs(MDL.OperationActivity.NewYearLuckyBag:GetDataByActivityID_ID(self.activityId)) do if v.RareRewardSign and v.RareRewardSign > 0 then table.insert(self.rareTable, v) else self.loop_Reward:AddData(v, 0) end end self.loop_Reward:AddData({isNoLimitReward = true, ItemID = noLimitRewardItemId, ItemNum = 1}, 0) for i, v in ipairs(self.group_RareReward) do local data = self.rareTable[i] if data then UIUtils.SetActive(v.gameObject, true) self:RefreshItemCell(v, data) else UIUtils.SetActive(v.gameObject, false) end end end function UINewYearPrayReward:OnBackButtonPressed() self:OnButtonClicked(self:GetUICommonPopUp().btn_Close) end function UINewYearPrayReward:OnButtonClicked(comp) if comp == self:GetUICommonPopUp().btn_Close then self:CloseView() else for i, v in ipairs(self.group_RareReward) do if comp == v.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(self.rareTable[i].ItemID) end end end end function UINewYearPrayReward:RefreshItemCell(cell, data) UTL.Item.SetItemCell(cell.Item, data.ItemID, data.ItemNum) if data.isNoLimitReward then UIUtils.SetActive(cell.img_Mask, false) cell.txt_Num.text = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Activity_NoLimitTimes"]) else local curNum = data.TotalNum - MDL.NewYear.GetPrayPoolInfo(self.activityId, data.ID) UIUtils.SetActive(cell.img_Mask, curNum <= 0) curNum = curNum > 0 and curNum or UTL.Color.FormatRedColor(curNum) cell.txt_Num.text = curNum .. "/" .. data.TotalNum end end function UINewYearPrayReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Reward then self:RefreshItemCell(cellTable, data) end end function UINewYearPrayReward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Reward then if target == cellTable.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end end function UINewYearPrayReward:GetUICommonPopUp() if self.UICommonPopUp then return self.UICommonPopUp end if self.UICommon51ActivityPopUp then return self.UICommon51ActivityPopUp end end return UINewYearPrayReward