local UISubjectMonthSignIn = UIViewClass() local activity_subject_month_op_pb = require("Proto/activity_subject_month_op_pb") function UISubjectMonthSignIn:OnOpened(context) self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateSignInInfo, self.SetRewardList) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:CheckIfClose() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self.activityId = MDL.SubjectMonth.GetActivityId() local activityType = MDL.OperationActivity.ActivityType.SubjectMonth MDL.MonthSignIn.OpenSubjectMonthSignInReq(self.activityId, activity_subject_month_op_pb.SignInOptType_OpenPanel) self.activityInfo = MDL.OperationActivity.GetOperationActivityInfo(activityType, self.activityId) local prefabData = CTL.SubjectMonth.GetVersionsPrefabData() self.loginID = prefabData.LoginID local VersionsLoginCfg = DataSheetManager.VersionsLogin:GetDataByLoginID(self.loginID) UIUtils.SetTextureByAssetBundle(self.img_Bg, ConstAssetPathConfig.BG_Path2 .. VersionsLoginCfg.LoginBackgroundPic) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_VersionsActivity_ChildName1) UIUtils.SetLabelText(self.txt_Title, Const_IDS[VersionsLoginCfg.LoginPicIDS]) UTL.Item.SetLocalizationImage(self.loc_Title, self.img_Title, VersionsLoginCfg.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 UISubjectMonthSignIn:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabel(cellTable.txt_Day, data.Day) cellTable.img_state:SetState(data.IsRare) 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.MonthSignIn.GetState(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 if data.IsRare == 1 then UIUtils.SetActive(cellTable.img_Farme, false) end end function UISubjectMonthSignIn:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Get then -- 领奖 MDL.MonthSignIn.OpenSubjectMonthSignInReq(activity_subject_month_op_pb.SignInOptType_ReceiveReward, 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 UISubjectMonthSignIn:SetRewardList() if self.loop_FestivalLogin.Count > 0 then self.loop_FestivalLogin:ClearCells() end local length = DataSheetManager.VersionsLoginReward:GetDataLengthByLoginID_Day(self.loginID) if length > 0 then for i, v in DataSheetManager.VersionsLoginReward:GetDataByLoginID_Day(self.loginID) do self.loop_FestivalLogin:AddData(v, 0) end end if length <= 7 then self.loop_FestivalLogin:SetMovementType(3) else self.loop_FestivalLogin:SetMovementType(1) local moveIndex = MDL.MonthSignIn.GetMoveIndex() self.loop_FestivalLogin:MoveIndex(moveIndex) end end -- 打开界面检查活动是否已结束 function UISubjectMonthSignIn:CheckIfClose() if not CTL.SubjectMonth.IsOpen() then self:CloseView() end end function UISubjectMonthSignIn:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UISubjectMonthSignIn:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() end end function UISubjectMonthSignIn:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end return UISubjectMonthSignIn