local UIWelfareBasePanel = UIViewClass() local TabSound = {"UI_gift" ,"UI_month_card", "UI_foundation"} local BgDir = ConstAssetPathConfig.Path14 function UIWelfareBasePanel:OnOpened(context) self:RegistSystemEvent(CTL.Welfare.WelfareRpEventId.Cell, self.UpdateCell) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.RefreshByGMSwitch) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.RefreshEventList) self:RegistSystemEvent(EventID.UI_OperationActivity_InfoChanged, self.RefreshEventList) self:RegistSystemEvent(EventID.UI_ReservedGift_CloseView, self.RefreshTabRedPoint) self:RegistSystemEvent(EventID.UI_WelfareBase_RefreshRedPoint, self.RefreshTabRedPoint) self:RegistSystemEvent(EventID.UI_WelfareBase_RefreshEventList, self.RefreshEventList) self:RegistSystemEvent(EventID.UI_SDKUser_Unlock_Update, self.RefreshEventList) self:RegistSystemEvent(EventID.UI_WeekendReward_UpdateInfo, self.RefreshEventList) -- 休沐祭礼 刷新入口显隐 self:RegistSystemEvent(EventID.VersionUpdate, self.RefreshTabRedPoint) self:RegistSystemEvent(EventID.VersionUpdate, self.RefreshEventList) self:RegistSystemEvent(EventID.UI_TestWelfare_GetRewardCloseView, self.RefreshEventList) -- 国服公测福利功能(仅公测使用,之后会将整个功能移除掉) self:RegistSystemEvent(EventID.Attention_ShowRedPoint, self.RefreshEventList) -- 关注有礼 self:RegistSystemEvent(EventID.PreDownloadJP_ShowRedPoint, self.RefreshTabRedPoint) -- 日服下载 self:RegistSystemEvent(EventID.UI_WelfareBase_ChangeBGPath, self.OnChangeBGPath) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_GuildWelfareTitle) self.view = nil self.cellList = {} local defaultWelfareId = context and context.welfareId self:RefreshEventList() self.playSound = false if defaultWelfareId then self:SelectSpecificIndexByWelfareId(defaultWelfareId) end self.playSound = true end function UIWelfareBasePanel:SwitchBgByTab(type) local bgName local dir = BgDir if type == CTL.Welfare.WelfareType.BindAccount or type == CTL.Welfare.WelfareType.RechargeReturn or type == CTL.Welfare.WelfareType.RechargeReturnTest then bgName = "ljcz_bg_01.png" elseif type == CTL.Welfare.WelfareType.WeekendReward -- 休沐祭礼 or type == CTL.Welfare.WelfareType.ReservedGift or type == CTL.Welfare.WelfareType.EnergyGet or type == CTL.Welfare.WelfareType.DailyDraw or type == CTL.Welfare.WelfareType.DailySignin or type == CTL.Welfare.WelfareType.OnlineReward then bgName = "mrlb_bg_01.png" elseif type == CTL.Welfare.WelfareType.LevelUpGift or type == CTL.Welfare.WelfareType.SignInGift or type == CTL.Welfare.WelfareType.VersionUpdate or type == CTL.Welfare.WelfareType.RewardsRetrieve or type == CTL.Welfare.WelfareType.PreDownloadJP then bgName = "mrlb_bg_01.png" elseif type == CTL.Welfare.WelfareType.Survey then if #MDL.Questionnaire.GetValidQuestionnaireIdList() > 0 then bgName = "MiniMapBg.png" end elseif type == CTL.Welfare.WelfareType.TestWelfare then -- 国服公测福利功能(仅公测使用,之后会将整个功能移除掉) bgName = "xdckjs_bg_01.png" elseif type == CTL.Welfare.WelfareType.AttentionReward then bgName = "gzh_bg_01.png" elseif type == CTL.Welfare.WelfareType.DouYinReward then bgName = "hyy_bg_06.png" elseif type == CTL.Welfare.WelfareType.SolicitContributions then bgName = "dyhd_bg_03.png" elseif type == CTL.Welfare.WelfareType.FestivalLogin_1 or type == CTL.Welfare.WelfareType.FestivalLogin_2 then -- 节日限时签到 local activityId = MDL.FestivalLogin.GetFestivalLoginActivityIdByWelfareType(type) local backgroundCfg = MDL.OperationActivity.ActivityBaseData[MDL.OperationActivity.ActivityType.FestivalLogin]:GetDataByActivityID(activityId) bgName = backgroundCfg.LoginBackgroundPic end bgName = dir..bgName UIUtils.SetTextureByAssetBundle(self.Bottom,bgName) end function UIWelfareBasePanel:SelectSpecificIndexByWelfareId(welfareId) if self.viewId == welfareId then return end local cellIndex = 0 for index, value in ipairs(self.tabIndexArray) do if value == welfareId then cellIndex = index - 1 break end end self.loop_EventList:SelectIndex(cellIndex) table.clear(self.tabIndexArray) end function UIWelfareBasePanel:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end function UIWelfareBasePanel:UpdateCell(state, content) local cellId = content.cellId local index = 0 for i, v in ipairs(self.cellList) do if v.ID == cellId then index = i - 1 end end self.loop_EventList:UpdateIndex(index) end function UIWelfareBasePanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIWelfareBasePanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then CTL.PushInterface.HidePushInterface(self.__viewClassPath, self.toggle_Skip) self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.PushInterface.HidePushInterface(self.__viewClassPath, self.toggle_Skip) CTL.HomeMain.CloseViewBackHomeMain() end end function UIWelfareBasePanel:RefreshByGMSwitch(funcId) if CTL.Welfare.IsFuncBelongsToWelfare(funcId) then self:RefreshTabRedPoint() end end function UIWelfareBasePanel:RefreshTabRedPoint() for i = 0, self.loop_EventList.Count -1 do self.loop_EventList:UpdateIndex(i) end end -- 一级页签 function UIWelfareBasePanel:RefreshEventList() if self.loop_EventList.Count > 0 then self.loop_EventList:ClearCells() end self.cellList = MDL.Welfare.GetWelfareEventList() self:SetBindAccountTabName() self.tabIndexArray = {} local selectedIndex = 0 local index = -1 for i, v in ipairs(self.cellList) do if self:CheckTabShow(v.ID) then index = index + 1 self.loop_EventList:AddData(v, 0) table.insert(self.tabIndexArray,v.ID) if self.viewId and self.viewId == v.ID then selectedIndex = index end end end self.viewId = nil --帮助刷新子界面 ---可能后续添加一个默认选中的逻辑 self.loop_EventList:SelectIndex(selectedIndex) end --绑定账户Tab页 名字会变 function UIWelfareBasePanel:SetBindAccountTabName() for i,v in ipairs(CTL.Welfare.BindAccountIdTable) do local data = DataSheetManager.Welfare:GetDataByID(v) if (v == CTL.Welfare.BindAccountIdType.BindAccountId or v == CTL.Welfare.BindAccountIdType.FBConcernId or v == CTL.Welfare.BindAccountIdType.StoreReviewsId) and CTL.TestingGift.CheckTabShow(data) then self.BindAccountTabName = data.Title return end end end function UIWelfareBasePanel:CheckTabShow(id) --绑定账户 相关显隐逻辑 if id == CTL.Welfare.WelfareType.BindAccount then for i, v in DataSheetManager.Welfare:GetEnumerator() do if (v.ID == CTL.Welfare.BindAccountIdType.FBConcernId or v.ID == CTL.Welfare.BindAccountIdType.StoreReviewsId or v.ID == CTL.Welfare.BindAccountIdType.BindAccountId) and CTL.TestingGift.CheckTabShow(v) then return true end end return false --秘宝之匣 判断奖励是否领完了,领完了就不显示页签 elseif id == CTL.Welfare.WelfareType.OnlineReward then if CTL.OnlineReward.IsRewardFinished() then return false end --十四日礼判断是否领完了 elseif id == CTL.Welfare.WelfareType.SignInGift then if MDL.SignIn.IsCollectedAllReward() then return false end elseif id == CTL.Welfare.WelfareType.VersionUpdate then if not MDL.VersionUpdate.IsOpen() then return false end --问卷判断是否还有可用的问卷 elseif id == CTL.Welfare.WelfareType.Survey then if #MDL.Questionnaire.GetValidQuestionnaireIdList() == 0 then return false end end return true end function UIWelfareBasePanel:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_EventList then if self.viewId == data.ID then return end if self.view then self.subView_Welfare:CloseAll() self.view = nil self.viewId = nil end self.viewId = data.ID self.context.welfareId = data.ID self:SwitchBgByTab(self.viewId) self.view = CTL.Welfare.OpenViewByWelfareType(self.subView_Welfare, self.viewId) end end function UIWelfareBasePanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_EventList then --绑定账户Tab单独设置标题 if data.ID == CTL.Welfare.WelfareType.BindAccount then UIUtils.SetLabelText(cellTable.txt_Unselected, Const_IDS[self.BindAccountTabName]) UIUtils.SetLabelText(cellTable.txt_Selected, Const_IDS[self.BindAccountTabName]) else UIUtils.SetLabelText(cellTable.txt_Unselected, Const_IDS[data.ActivityName]) UIUtils.SetLabelText(cellTable.txt_Selected, Const_IDS[data.ActivityName]) end UIUtils.SetLocalizationImage(cellTable.img_New, "zr_msz_new.png") cellTable.img_New:SetNativeSize() UIUtils.SetActive(cellTable.img_New, false) cellTable.cell:SetRedPoint(MDL.RedPoint.GetNodeStateByLogicParams(CTL.Welfare.WelfareRpEventId.TownHome, data.ID)) -- 增加 “限时” 标签显隐 UIUtils.SetActive(cellTable.img_TimeLimit, false) if data.ID == CTL.Welfare.WelfareType.WeekendReward then UIUtils.SetActive(cellTable.img_TimeLimit, true) end end end function UIWelfareBasePanel:OnChangeBGPath(path) UIUtils.SetTextureByAssetBundle(self.Bottom, path) end return UIWelfareBasePanel