--后起之秀 local UILaterEnterMain = UIViewClass() local EventSystem = require('Event/EventSystem') function UILaterEnterMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_LaterEnter_GetReward, self.Refresh) self.lateEnterDay = MDL.LaterEnter.GetLaterEnterDay() self.rewardDays = CTL.LaterEnter.GetRewardDays() self:Refresh() end function UILaterEnterMain:Refresh() self.curSelectDay = CTL.LaterEnter.GetDefaultSelectDayTab() self:RefreshDaysBtn() self:RefreshUI() end function UILaterEnterMain:RefreshDaysBtn() for i = 1, 3 do if i > self.rewardDays then UIUtils.SetActive(self.group_DailyBtn[i].gameObject, false) else UIUtils.SetActive(self.group_DailyBtn[i].gameObject, true) local rewardState = MDL.LaterEnter.GetRewardState(i) self.group_DailyBtn[i].state_btn:SetState(rewardState) UIUtils.SetActive(self.group_DailyBtn[i].btn_Unselect, self.curSelectDay ~= i) UIUtils.SetActive(self.group_DailyBtn[i].btn_Select, self.curSelectDay == i) self.group_DailyBtn[i].btn:SetRedPoint(rewardState == MDL.LaterEnter.RewardState.Claimable) self.group_DailyBtn[i].txt_Select.text = string.FormatByIdsId(Const_IDS.IDS_HeroFund_DayNum, i) self.group_DailyBtn[i].txt_Unselect.text = string.FormatByIdsId(Const_IDS.IDS_HeroFund_DayNum, i) end end end function UILaterEnterMain:RefreshUI() local laterEnterData = DataSheetManager.LaterEnterData:GetDataByID_LastDay(self.lateEnterDay, self.curSelectDay) self.loop_Award1:ReloadAll(laterEnterData.Reward_Table) self.loop_Award2:ReloadAll(laterEnterData.SpecialReward_Table) --刷新按钮 local rewardState = MDL.LaterEnter.GetRewardState(self.curSelectDay) self.state_Get:SetState(rewardState) self.btn_Get:SetRedPoint(rewardState == MDL.LaterEnter.RewardState.Claimable) local nextGetDay = self.curSelectDay - MDL.LaterEnter.GetCurActivityOpenDay() if nextGetDay == 1 then self.lab_Collect.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OperationActivity_Hint1) elseif nextGetDay > 1 then self.lab_Collect.text = string.FormatByIdsId(Const_IDS.IDS_OperationActivity_Hint2, nextGetDay) end end function UILaterEnterMain:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UILaterEnterMain:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.LaterEnter}) elseif comp == self.btn_Get then MDL.LaterEnter.LaterEnterRewardReq(self.curSelectDay) else for i = 1, self.rewardDays do if comp == self.group_DailyBtn[i].btn then self.curSelectDay = i self:RefreshDaysBtn() self:RefreshUI() return end end end end function UILaterEnterMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Award1 then UTL.Item.SetItemCell(cellTable.item, data.Item, data.ItemNum) elseif scrollRect == self.loop_Award2 then UTL.Item.SetItemCell(cellTable.item, data.SpecialItem, data.SpecialItemNum) end end function UILaterEnterMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Award1 then if cellTable.item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(data.Item) end elseif scrollRect == self.loop_Award2 then if cellTable.item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(data.SpecialItem) end end end return UILaterEnterMain