2020-07-28 09:48:02 +08:00
|
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
[2] = { --乾坤宝盒
|
|
|
|
|
default = "q_qiankun_baoheanniu_02", lock = "q_qiankun_baoheanniu_02", select = "q_qiankun_baoheanniu_01",
|
|
|
|
|
rpType = RedPointType.QianKunBox,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
local TimeLimitedCall = require("Modules/Operating/TimeLimitedCall")
|
|
|
|
|
local QianKunBox = require("Modules/Operating/QianKunBox")
|
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function DynamicActivityPanel:InitComponent()
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- 上部货币显示
|
|
|
|
|
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, lastIndex)
|
|
|
|
|
this._CurPageIndex = index
|
|
|
|
|
for i = 1, #this.PageList do
|
|
|
|
|
this.PageList[i]:OnHide()
|
|
|
|
|
this.PageList[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
this.PageList[index]:OnShow(this.sortingOrder, _PageInfo[index].params and unpack(_PageInfo[index].params) or nil)
|
|
|
|
|
this.PageList[index].gameObject:SetActive(true)
|
|
|
|
|
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()
|
2020-07-28 20:13:09 +08:00
|
|
|
|
this.PageList[1]:OnDestroy()
|
2020-07-28 09:48:02 +08:00
|
|
|
|
end
|
|
|
|
|
return this
|