miduo_client/Assets/ManagedResources/~Lua/Modules/DynamicActivity/DynamicActivityPanel.lua

182 lines
6.7 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
require("Base/BasePanel")
2020-07-28 09:48:02 +08:00
local DynamicActivityPanel = Inherit(BasePanel)
local this = DynamicActivityPanel
-- Tab管理器
local TabBox = require("Modules/Common/TabBox")
this._CurPageIndex =1
2020-08-20 18:32:14 +08:00
local orginLayer
2020-07-28 09:48:02 +08:00
local _PageInfo = {--后期可以做成tableInserticon名字都去读表
2020-08-22 17:36:57 +08:00
[1] = { --破阵诛仙
default = "p_pozhengzhuxian_anniu_02", lock = "p_pozhengzhuxian_anniu_02", select = "p_pozhengzhuxian_anniu_01",
rpType = RedPointType.PoZhenZhuXianTask,panelType = PanelType.Main,
},
[2] = { --限时召唤
2020-07-28 09:48:02 +08:00
default = "x_xianshizaohuan_02", lock = "x_xianshizaohuan_02", select = "x_xianshizaohuan_01",
2020-08-03 20:01:59 +08:00
rpType = RedPointType.TimeLimited,panelType = PanelType.TimelimitCall,
2020-07-28 09:48:02 +08:00
},
2020-08-22 17:36:57 +08:00
[3] = { --乾坤宝盒
2020-07-28 09:48:02 +08:00
default = "q_qiankun_baoheanniu_02", lock = "q_qiankun_baoheanniu_02", select = "q_qiankun_baoheanniu_01",
2020-08-03 20:01:59 +08:00
rpType = RedPointType.QianKunBox,panelType = PanelType.QianKunBox,
2020-08-13 15:38:20 +08:00
},
2020-08-20 17:36:19 +08:00
[4] = { --珍奇礼包
2020-08-13 15:38:20 +08:00
default = "z_zhenqibaoge_anniu_02", lock = "z_zhenqibaoge_anniu_02", select = "z_zhenqibaoge_anniu_01",
2020-08-28 17:46:07 +08:00
rpType = "",panelType = PanelType.Main,
2020-08-20 17:36:19 +08:00
},
2020-08-28 16:36:08 +08:00
[5] = { --累计充值
default = "r_huodong_leijichengzhianniu_01", lock = "r_huodong_leijichengzhianniu_01", select = "r_huodong_leijichengzhianniu",
2020-08-28 17:46:07 +08:00
rpType = RedPointType.PoZhenZhuXianRecharge,panelType = PanelType.Main,
2020-08-28 16:36:08 +08:00
},
[6] = { --限时商市
2020-08-21 11:23:46 +08:00
default = "x_xianshishangshi_anniu_02", lock = "x_xianshishangshi_anniu_02", select = "x_xianshishangshi_anniu_01",
2020-08-28 17:46:07 +08:00
rpType = "",panelType = PanelType.Main,
2020-08-21 11:23:46 +08:00
},
2020-07-28 09:48:02 +08:00
}
2020-08-13 15:38:20 +08:00
2020-08-21 11:23:46 +08:00
local TimeLimitedCall = require("Modules/DynamicActivity/TimeLimitedCall")
local QianKunBox = require("Modules/DynamicActivity/QianKunBox")
local PoZhenZhuXianPage=require("Modules/DynamicActivity/PoZhenZhuXianPage")
local ZhenQiYiBaoPage=require("Modules/DynamicActivity/ZhenQiYiBaoPage")
2020-08-28 16:36:08 +08:00
local LeiJiChongZhiPage=require("Modules/DynamicActivity/LeiJiChongZhiPage")
2020-08-21 11:23:46 +08:00
local XianShiShangShi=require("Modules/DynamicActivity/XianShiShangShi")
2020-07-28 09:48:02 +08:00
--初始化组件(用于子类重写)
function DynamicActivityPanel:InitComponent()
2020-08-06 15:14:47 +08:00
orginLayer = 0
2020-07-28 09:48:02 +08:00
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 = {
2020-08-22 17:36:57 +08:00
[1] = PoZhenZhuXianPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_3")),
[2] = TimeLimitedCall.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
[3] = QianKunBox.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_2")),
2020-08-20 17:36:19 +08:00
[4] = ZhenQiYiBaoPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_4")),
2020-08-28 16:36:08 +08:00
[5] = LeiJiChongZhiPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_5")),
[6] = XianShiShangShi.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_6")),
2020-07-28 09:48:02 +08:00
}
-- 上部货币显示
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改变事件
2020-08-20 17:36:19 +08:00
function this.OnPageTabChange(index)
2020-07-28 09:48:02 +08:00
this._CurPageIndex = index
for i = 1, #this.PageList do
2020-08-13 15:38:20 +08:00
if this.PageList[i] then
this.PageList[i]:OnHide()
this.PageList[i].gameObject:SetActive(false)
end
2020-07-28 09:48:02 +08:00
end
2020-08-20 17:36:19 +08:00
this.PageList[index]:OnShow(this.sortingOrder,this)
2020-07-28 09:48:02 +08:00
this.PageList[index].gameObject:SetActive(true)
2020-08-03 20:01:59 +08:00
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = _PageInfo[index].panelType })
2020-07-28 09:48:02 +08:00
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()
-- 这里管理全部子界面的销毁,保证子界面生命周期完整
for _, page in pairs(this.PageList) do
if page.OnDestroy then
page:OnDestroy()
end
end
2020-07-28 09:48:02 +08:00
end
return this