local UIFestivalLoginReward = UIViewClass() function UIFestivalLoginReward:OnOpened(context) self.welfareType = context.welfareType self.activityType = MDL.OperationActivity.ActivityType.FestivalLogin self.activityId = MDL.FestivalLogin.GetFestivalLoginActivityIdByWelfareType(self.welfareType) self:RegistSystemEvent(EventID.UI_FestivalLogin_RefreshView, self.SetRewardList) self:RegistSystemEvent(EventID.UI_OperationActivity_DataChanged, self.SetRewardList) self:RegistSystemEvent(EventID.UI_OperationActivity_InfoChanged, self.SetRewardList) self.activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) local backgroundCfg = MDL.OperationActivity.ActivityBaseData[self.activityType]:GetDataByActivityID(self.activityId) self:CheckIfClose() self:SetRewardList() UIUtils.SetLabelText(self.txt_Title, Const_IDS[backgroundCfg.LoginPicIDS]) UTL.Item.SetLocalizationImage(self.loc_Title, self.img_Title, backgroundCfg.LoginPic) self.img_Title:SetNativeSize() local month,day,hourMinute = UTL.Time.FormatTimeSimple(self.activityInfo.endTime) if GameAppInfo.IsVietnamPackage() then UIUtils.SetLabel(self.txt_Time, UIUtils.GetLocalizedTxt(Const_IDS.IDS_FestivalLogin_Hint1) .. os.date(UTL.Time.FormatDateEnum.MDHM, self.activityInfo.endTime)) else UIUtils.SetLabel(self.txt_Time, UIUtils.GetLocalizedTxt(Const_IDS.IDS_FestivalLogin_Hint1)..string.Concat(string.FormatByIdsKey("IDS_Time_MonthDay", month, day), hourMinute)) end end function UIFestivalLoginReward:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabel(cellTable.txt_Day, data.Day) for i = 1, #cellTable.group_Items do local Item_Table = data.LoginReward_Table if i <= #Item_Table then UIUtils.SetActive(cellTable.group_Items[i].gameObject, true) UTL.Item.SetItemCell(cellTable.group_Items[i], Item_Table[i].LoginRewardItem, Item_Table[i].LoginRewardNum) else UIUtils.SetActive(cellTable.group_Items[i].gameObject, false) end end local status = MDL.FestivalLogin.GetFestivalLoginDayState(self.activityId, data.Day) local taskStateEnum = MDL.OACommon.ActivityTaskState if status == taskStateEnum.UnDone then cellTable.state_Btn:SetState(1) elseif status == taskStateEnum.Done then cellTable.state_Btn:SetState(0) elseif status == taskStateEnum.Commit then cellTable.state_Btn:SetState(2) end end function UIFestivalLoginReward:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Get then -- 领奖 MDL.FestivalLogin.ActivityFestivalLoginRewardReq(self.activityId, data.Day) else for i = 1, #cellTable.group_Items do if target == cellTable.group_Items[i].event_Click then UTL.ItemTips.ShowCommonTipsById(data.LoginReward_Table[i].LoginRewardItem) break end end end end function UIFestivalLoginReward:SetRewardList() if self.loop_FestivalLogin.Count > 0 then self.loop_FestivalLogin:ClearCells() end self.rewardList = MDL.OperationActivity.FestivalLoginReward:GetDataByActivityID_Day(self.activityId) if #self.rewardList > 0 then for i, v in ipairs(self.rewardList) do self.loop_FestivalLogin:AddData(v, 0) end end if #self.rewardList <= 7 then self.loop_FestivalLogin:SetMovementType(3) else self.loop_FestivalLogin:SetMovementType(1) local moveIndex = MDL.FestivalLogin.GetFestivalLoginRewardMoveIndex(self.welfareType) self.loop_FestivalLogin:MoveIndex(moveIndex - 1) end end -- 打开界面检查活动是否已结束 function UIFestivalLoginReward:CheckIfClose() if not CTL.OperationActivity.IsOperationActivityOpen(self.activityInfo) then self:CloseView(true) EventSystem.Dispatch(EventID.UI_WelfareBase_RefreshEventList) end end return UIFestivalLoginReward