168 lines
6.0 KiB
Lua
168 lines
6.0 KiB
Lua
require("Base/BasePanel")
|
||
local DynamicActivityPanel = Inherit(BasePanel)
|
||
local this = DynamicActivityPanel
|
||
-- Tab管理器
|
||
local TabBox = require("Modules/Common/TabBox")
|
||
this._CurPageIndex =1
|
||
local _PageInfo = {--后期可以做成tableInsert,icon名字都去读表
|
||
[1] = { --限时召唤
|
||
default = "x_xianshizaohuan_02", lock = "x_xianshizaohuan_02", select = "x_xianshizaohuan_01",
|
||
rpType = RedPointType.TimeLimited,panelType = PanelType.TimelimitCall,
|
||
},
|
||
[2] = { --乾坤宝盒
|
||
default = "q_qiankun_baoheanniu_02", lock = "q_qiankun_baoheanniu_02", select = "q_qiankun_baoheanniu_01",
|
||
rpType = RedPointType.QianKunBox,panelType = PanelType.QianKunBox,
|
||
},
|
||
[3] = { --破阵诛仙
|
||
default = "p_pozhengzhuxian_anniu_02", lock = "p_pozhengzhuxian_anniu_02", select = "p_pozhengzhuxian_anniu_01",
|
||
rpType = RedPointType.pozhenzhuxianTask,panelType = PanelType.QianKunBox,
|
||
},
|
||
[4] = { --珍奇礼包
|
||
default = "z_zhenqibaoge_anniu_02", lock = "z_zhenqibaoge_anniu_02", select = "z_zhenqibaoge_anniu_01",
|
||
rpType = RedPointType.QianKunBox,panelType = PanelType.QianKunBox,
|
||
},
|
||
[5] = { --累计充值
|
||
default = "r_huodong_leijichengzhianniu_01", lock = "r_huodong_leijichengzhianniu_01", select = "r_huodong_leijichengzhianniu",
|
||
rpType = RedPointType.QianKunBox,panelType = PanelType.QianKunBox,
|
||
}
|
||
}
|
||
|
||
local TimeLimitedCall = require("Modules/Operating/TimeLimitedCall")
|
||
local QianKunBox = require("Modules/Operating/QianKunBox")
|
||
local PoZhenZhuXianPage=require("Modules/Operating/PoZhenZhuXianPage")
|
||
local ZhenQiYiBaoPage=require("Modules/Operating/ZhenQiYiBaoPage")
|
||
local LeiJiChongZhiPage=require("Modules/Operating/LeiJiChongZhiPage")
|
||
--初始化组件(用于子类重写)
|
||
function DynamicActivityPanel:InitComponent()
|
||
orginLayer = 0
|
||
this.tabbox = Util.GetGameObject(self.gameObject, "bg/tabbox")
|
||
this.btnBack = Util.GetGameObject(self.gameObject, "bg/btnBack")
|
||
this.content = Util.GetGameObject(self.gameObject, "bg/pageContent")
|
||
|
||
this.PageList = {
|
||
[1] = TimeLimitedCall.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
|
||
[2] = QianKunBox.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_2")),
|
||
[3] = PoZhenZhuXianPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_3")),
|
||
[4] = ZhenQiYiBaoPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_4")),
|
||
}
|
||
|
||
-- 上部货币显示
|
||
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft})
|
||
end
|
||
--绑定事件(用于子类重写)
|
||
function DynamicActivityPanel:BindEvent()
|
||
-- 初始化Tab管理器
|
||
this.PageTabCtrl = TabBox.New()
|
||
this.PageTabCtrl:SetTabAdapter(this.PageTabAdapter)
|
||
this.PageTabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck)
|
||
this.PageTabCtrl:SetChangeTabCallBack(this.OnPageTabChange)
|
||
|
||
-- 关闭界面打开主城
|
||
Util.AddClick(this.btnBack, function()
|
||
this:ClosePanel()
|
||
end)
|
||
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function DynamicActivityPanel:AddListener()
|
||
end
|
||
--移除事件监听(用于子类重写)
|
||
function DynamicActivityPanel:RemoveListener()
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function DynamicActivityPanel:OnOpen(chooseIndex)
|
||
-- 初始化tab数据
|
||
this.PageTabCtrl:Init(this.tabbox, _PageInfo)
|
||
this._CurPageIndex = chooseIndex or 1
|
||
|
||
end
|
||
|
||
-- 打开,重新打开时回调
|
||
function DynamicActivityPanel:OnShow()
|
||
if this._CurPageIndex then
|
||
this.PageTabCtrl:ChangeTab(this._CurPageIndex)
|
||
end
|
||
end
|
||
|
||
----==========================一级页签相关===========================================
|
||
-- tab按钮自定义显示设置
|
||
function this.PageTabAdapter(tab, index, status)
|
||
local img = Util.GetGameObject(tab, "img"):GetComponent("Image")
|
||
local lock = Util.GetGameObject(tab, "lock")
|
||
local redpot = Util.GetGameObject(tab, "redpot")
|
||
|
||
img.sprite = Util.LoadSprite(_PageInfo[index][status])
|
||
img:SetNativeSize()
|
||
local islock = status == "lock"
|
||
Util.SetGray(img.gameObject, islock)
|
||
lock:SetActive(islock)
|
||
|
||
-- 判断是否需要检测红点
|
||
redpot:SetActive(false)
|
||
if not islock then
|
||
this.ClearPageRedpot(index)
|
||
this.BindPageRedpot(index, redpot)
|
||
end
|
||
end
|
||
|
||
-- tab可用性检测
|
||
function this.PageTabIsLockCheck(index)
|
||
return false
|
||
end
|
||
|
||
-- tab改变事件
|
||
function this.OnPageTabChange(index)
|
||
this._CurPageIndex = index
|
||
for i = 1, #this.PageList do
|
||
if this.PageList[i] then
|
||
this.PageList[i]:OnHide()
|
||
this.PageList[i].gameObject:SetActive(false)
|
||
end
|
||
|
||
end
|
||
this.PageList[index]:OnShow(this.sortingOrder,this)
|
||
this.PageList[index].gameObject:SetActive(true)
|
||
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = _PageInfo[index].panelType })
|
||
end
|
||
|
||
-- 绑定数据
|
||
local _PageBindData = {}
|
||
local _TabBindData = {}
|
||
function this.BindPageRedpot(page, redpot)
|
||
local rpType = _PageInfo[page].rpType
|
||
if not rpType then return end
|
||
BindRedPointObject(rpType, redpot)
|
||
_PageBindData[rpType] = redpot
|
||
end
|
||
function this.ClearPageRedpot(page)
|
||
-- 清除红点绑定
|
||
if page then -- 清除某个
|
||
local rpType = _PageInfo[page].rpType
|
||
if not rpType then return end
|
||
ClearRedPointObject(rpType, _PageBindData[rpType])
|
||
_PageBindData[rpType] = nil
|
||
else -- 全部清除
|
||
for rpt, redpot in pairs(_PageBindData) do
|
||
ClearRedPointObject(rpt, redpot)
|
||
end
|
||
_PageBindData = {}
|
||
end
|
||
end
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function DynamicActivityPanel:OnClose()
|
||
if this._CurPageIndex then
|
||
this.PageList[this._CurPageIndex]:OnHide()
|
||
this.PageList[this._CurPageIndex].gameObject:SetActive(false)
|
||
end
|
||
end
|
||
--界面销毁时调用(用于子类重写)
|
||
function DynamicActivityPanel:OnDestroy()
|
||
SubUIManager.Close(this.UpView)
|
||
-- 清除红点
|
||
this.ClearPageRedpot()
|
||
this.PageList[1]:OnDestroy()
|
||
end
|
||
return this |