local UIAnniversaryLuckyDrawRewardListPanel = UIViewClass() local ANNIVERSARY_LUCKY_DRAW_SELF_RECORD_ISSHOWRARE = "ANNIVERSARY_LUCKY_DRAW_SELF_RECORD_ISSHOWRARE" function UIAnniversaryLuckyDrawRewardListPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_AnniversaryLuckyDraw_SelfRewardRecord, self.RefreshList) MDL.AnniversaryLuckyDraw.NewYearLuckyDrawRecordReq(context.activityId, MDL.AnniversaryLuckyDraw.RecordType.RecordTypeSelf) self.isShowRare = PersistentData.PlayerData:Get(ANNIVERSARY_LUCKY_DRAW_SELF_RECORD_ISSHOWRARE) or false --TODO self.toggle_Hide.isOn = self.isShowRare end function UIAnniversaryLuckyDrawRewardListPanel:RefreshList() local drawRecord = MDL.AnniversaryLuckyDraw.GetSelfLuckyDrawRecord() UIUtils.SetActive(self.group_Empty, false) if #drawRecord == 0 then UIUtils.SetActive(self.group_Empty, true) if self.isShowRare then UIUtils.SetLabelText(self.txt_Empty, Const_IDS.IDS_AnniversaryLuckyDraw_Hint_18) else UIUtils.SetLabelText(self.txt_Empty, Const_IDS.IDS_AnniversaryLuckyDraw_Hint_19) end return end if self.isShowRare then self.Loop_RewardList:ClearCells() local num = 0 for _, v in ipairs(drawRecord) do local cfg = DataSheetManager.LuckyDrawReward:GetDataByReward(v.rewardCfgId) if cfg and cfg.PublicityType ~= CTL.AnniversaryLuckyDraw.PublicityType.Normal then self.Loop_RewardList:AddData(v, 0) num = num+1 end end if num == 0 then UIUtils.SetActive(self.group_Empty, true) UIUtils.SetLabelText(self.txt_Empty, Const_IDS.IDS_AnniversaryLuckyDraw_Hint_18) end else self.Loop_RewardList:ReloadAll(drawRecord) end end function UIAnniversaryLuckyDrawRewardListPanel:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIAnniversaryLuckyDrawRewardListPanel:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_pop_up_Close then UIUtils.SetActive(self.RewardInfoCopy_Popup, false) elseif comp == self.img_Copy then UIUtils.GetSystemCopyText(self.txt_code.text) CTL.Tips.AddTipsMsg(Const_IDS.IDS_VIPInvitation_CopyHint) end end function UIAnniversaryLuckyDrawRewardListPanel:OnValueChanged(comp, value) if comp == self.toggle_Hide then if self.isShowRare == value then return end self.isShowRare = not self.isShowRare PersistentData.PlayerData:Set(ANNIVERSARY_LUCKY_DRAW_SELF_RECORD_ISSHOWRARE, self.isShowRare, true) self:RefreshList() end end function UIAnniversaryLuckyDrawRewardListPanel:OnCellInit(scrollRect, index, cellTable, data) local itemData = DataSheetManager.ItemData:GetDataByID(data.rewardId) local str = UIUtils.GetLocalizedTxt(Const_IDS[itemData.Name]).."*"..data.rewardNum UIUtils.SetLabel(cellTable.txt_Reward, str) UIUtils.SetLabel(cellTable.txt_Time, os.date("%m/%d %H:%M:%S", data.drawTime)) UIUtils.SetLabel(cellTable.txt_Num, data.index) local cfg = DataSheetManager.LuckyDrawReward:GetDataByReward(data.rewardCfgId) if cfg then UIUtils.SetActive(cellTable.btn_Check, cfg.RewardItemType ~= 0) if cfg.PublicityType == CTL.AnniversaryLuckyDraw.PublicityType.Normal then cellTable.state_Txt:SetState(2) elseif cfg.PublicityType == CTL.AnniversaryLuckyDraw.PublicityType.Middle then cellTable.state_Txt:SetState(1) else cellTable.state_Txt:SetState(0) end else UIUtils.SetActive(cellTable.btn_Check, false) cellTable.state_Txt:SetState(2) end end function UIAnniversaryLuckyDrawRewardListPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Check then UIUtils.SetLabel(self.txt_code, data.code) UIUtils.SetActive(self.RewardInfoCopy_Popup, true) end end return UIAnniversaryLuckyDrawRewardListPanel