123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- ---@class KLMainActivityPanel:UIKmlLuaPanelBase
- ---@field view KLMainActivityPanelView
- local KLMainActivityPanel = class(UIKmlLuaPanelBase)
- local this =KLMainActivityPanel
- function this:AsyncLoadUI()
- end
- ---创建时调用一次
- function this:Init()
- self.togDataList = {}
- --获取sub_mainActivity表内所有数据
- self.togDataList = SL:GetConfigTable("sub_mainActivity")
- GUI:DataListInitData(self.view.TogInfoList, function()
- return self:GetAllTogCount()
- end,function()
- end,function()
- end, function(realIndex)
- self:TogUpdateFun(realIndex)
- end)
- end
- function this:GetAllTogCount()
- return table.count(self.togDataList)
- end
- function this:togItemOnTog(control,isOn)
- if GUI:Toggle_getIsOn(control) == "1" or isOn then
- local subArgs={}
- if self.args then
- for key, value in pairs(self.args) do
- subArgs[key]=value
- end
- end
- subArgs.mainActivityData = control.mainActivityData
- GUI:UIPanel_Open(control.mainActivityData.subUIRoute,self.view.subParent,self,subArgs)
- self:OnClickActivityMask()
- else
- GUI:UIPanel_Close(control.mainActivityData.subUIRoute)
- end
- end
- function this:TogUpdateFun(realIndex)
- local data = self.togDataList[realIndex + 1]
- local index = realIndex+1
- local togItem = GUI:GetChildControl(self.view.TogInfoList, realIndex, 'togItem')
- local txt_togName = GUI:GetChildControl(self.view.TogInfoList, realIndex, 'txt_togName')
- local img_corner = GUI:GetChildControl(self.view.TogInfoList, realIndex, 'img_corner')
- GUI:SetActive(img_corner,false)
- if data.cornerType ~= 0 then --配0不展示角标
- GUI:SetActive(img_corner,true)
- if data.cornerType == 1 then
- GUI:Image_loadTexture(img_corner, "img_xianshi","Atlas/QJ5_MainActivityPanel.spriteatlas")
- end
- end
- togItem.index = index
- togItem.togId = data.id
- togItem.mainActivityData = data
- togItem.redControl = GUI:GetChildControl(self.view.TogInfoList, realIndex, 'img_redPoint')
- self.TogControlList[index] = togItem
- GUI:setName(togItem,data.togName)
- GUI:Text_setString(txt_togName,data.showTogName)
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.btn_close,self,self.OnClickClose)
- end
- function this:OnClickClose()
- GUI:UIPanel_Close("dev/outui/MainActivity/Panel/KLMainActivity/KLMainActivityPanel")
- SL.ShowMainPanel()
- end
- ---界面显示时调用一次
- function this:Show()
-
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- self.TogControlList = {} --所有页签组件表
- table.sort(self.togDataList,function(a,b)
- return a.sortId < b.sortId
- end)
- SL.HideMainPanel()
- GUI:DataListUpdateData(self.view.TogInfoList,_,function()
- self:InitToggles()
- self:RefreshTogState()
- self:RefreshIndex()
- self:RefreshTogRedPointShow()
- InfoManager.mainActivityInfo:RefreshMainActivityRedPoint("tog_OpenServerAthletics",InfoManager.openServerAthleticsInfo:IsShowRed())
- end)
- end
- function this:RefreshTogState()
- for k, v in ipairs(self.TogControlList) do
- local isShow = this:IsOpenJudge(v.mainActivityData.showCondition,v.mainActivityData.id)
- GUI:SetActive(self.TogControlList[k],isShow)
- end
- end
- function this:IsOpenJudge(condition,id)
- local isShow = condition == "" or ConditionManager.Check4D(condition)
- ---if else 可特殊处理页签显示隐藏
- return isShow
- end
- function this:RefreshIndex()
- local allClose = true
- local showIndex = 0
- --默认选首个激活页签
- for i, value in ipairs(self.TogControlList) do
- if GUI:getVisible(value) then
- showIndex = i
- allClose = false
- break
- end
- end
- --优选传参页签
- --从外部跳转时,传sub_mainActivity表内id
- if self.args and self.args.mainActivityId then
- local tempID = tonumber(self.args.mainActivityId)
- local realWanttedIndex = -1
- for _, value in ipairs(self.TogControlList) do
- if value.togId == tempID then
- realWanttedIndex = value.index
- break
- end
- end
- if realWanttedIndex>0 and GUI:getVisible(self.TogControlList[realWanttedIndex]) then
- showIndex = realWanttedIndex
- else
- SL:TipMessage("界面未激活,无法跳转",1,NoticeType.NoticeMid)
- end
- end
- --关闭所有子界面
- for _, v in pairs(self.TogControlList) do
- GUI:UIPanel_Close(v.mainActivityData.subUIRoute)
- end
- if showIndex > 0 and not allClose then
- GUI:Toggle_setIsOn(self.TogControlList[showIndex],true)
- self:togItemOnTog(self.TogControlList[showIndex],true)
- else
- SL:TipMessage("当前没有开启的活动",1,NoticeType.NoticeMid)
- end
- end
- function this:InitToggles()
- for _ , v in pairs(self.TogControlList) do
- GUI:SetToggleOnValueChange(v, self, self.togItemOnTog)
- end
- end
- function this:RefreshTogRedPointShow()
- for _, v in pairs(self.TogControlList) do
- if InfoManager.mainActivityInfo.mainActivityRedsTbl then
- if GUI:getVisible(v) then
- GUI:SetActive(v.redControl,InfoManager.mainActivityInfo.mainActivityRedsTbl[v.mainActivityData.togName])
- end
- end
- end
- end
- function this:OnClickActivityMask()
- GUI:setVisible(self.view.img_activityMask, true)
- if self.timer then
- SL:UnSchedule(self.timer)
- end
- self.timer = SL:ScheduleOnce(0.5, function()
- GUI:setVisible(self.view.img_activityMask, false)
- end)
- end
- function this:Close()
- if self.timer then
- SL:UnSchedule(self.timer)
- self.timer = nil
- end
- SL.ShowMainPanel()
- end
- return this
|