miduo_client/Assets/ManagedResources/~Lua/Modules/Operating/OperatingPanel.lua

300 lines
12 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
--[[
2020-05-09 13:31:21 +08:00
* @ClassName OperatingPanel
* @Description
* @Date 2019/5/25 14:16
* @Author MagicianJoker, fengliudianshao@outlook.com
* @Copyright Copyright (c) 2019, MagicianJoker
--]]
--礼包>月卡>成长礼金>连续充值>签到>关注有礼>高级鸡精
2020-06-03 19:09:01 +08:00
local WeekMonthGiftPackPage = require("Modules/Operating/WeekMonthGiftPackPage")
2020-05-09 13:31:21 +08:00
local MonthCardPage = require("Modules/Operating/MonthCardPage")
local GrowthGiftPage = require("Modules/Operating/GrowthGiftPage")
local ContinuityRechargePage = require("Modules/Operating/ContinuityRechargePage") --积天豪礼
local CumulativeSignIn = require("Modules/Operating/CumulativeSignInPage") --累计签到
local AttentionGiftPage = require("Modules/Operating/AttentionGiftPage") --关注有礼
local UpperMonthCard = require("Modules/Operating/UppperMonthCard")--月基金
---@class OperatingPanel
local OperatingPanel = quick_class("OperatingPanel", BasePanel)
2020-07-08 09:40:36 +08:00
local kMaxTab = 11
2020-05-09 13:31:21 +08:00
--显示类型 type 面板类型 body 显示页签索引
local ShowType={
Welfare={type=1,body={1,2,5,6}},--福利
2020-05-09 13:31:21 +08:00
MonthFund={type=2,body={7,8}} --超值基金
}
2020-05-15 16:52:35 +08:00
local TabToContent = {
[1] = 1,
[2] = 2,
[3] = 3,
[4] = 4,
[5] = 5,
[6] = 5,
[7] = 7,
2020-05-15 16:52:35 +08:00
[8] = 7,
[9] = 6,
[10] = 5,
[11] = 5,
[12] = 5,
2022-05-18 19:39:19 +08:00
[13] = 8,
2020-05-15 16:52:35 +08:00
}
2021-02-23 19:12:16 +08:00
local TabImageConfig = {
[1] = {normal = "r_meiriqiandao_anniu_01_zh", select = "r_meiriqiandao_anniu_zh"},
[2] = {normal = "c_chengzhang_yueka002_zh", select = "c_chengzhang_yueka001_zh"},
[3] = {normal = "c_czjj_icon2_zh", select = "c_czjj_icon1_zh"},
[4] = {normal = "r_jitianhaoli_anniu_01_zh", select = "r_jitianhaoli_anniu_zh"},
[5] = {normal = "m_meizhoulibao_icon2_zh", select = "m_meizhoulibao_icon1_zh"},
[6] = {normal = "m_meiyuelibao_icon2_zh", select = "m_meiyuelibao_icon1_zh"},
[7] = {normal = "y_yjj_128yjj001_zh", select = "y_yjj_128yjj002_zh"},
[8] = {normal = "y_yjj_328yjj002_zh", select = "y_yjj_328yjj001_zh"},
[9] = {normal = "r_guanzhuyouli_anniu_01_zh", select = "r_guanzhuyouli_anniu_zh"},
[10] = {normal = "z_zhenqibaoge_anniu_02_zh", select = "z_zhenqibaoge_anniu_01_zh"},
[11] = {normal = "s_shengxingyouli_anniu_02_zh", select = "s_shengxingyouli_anniu_01_zh"},
[12] = {normal = "r_huodong_leijichengzhianniu_01_zh", select = "r_huodong_leijichengzhianniu_zh"},
2022-05-18 19:39:19 +08:00
[13] = {normal = "s_sztq_icon2_zh", select = "s_sztq_icon1_zh"},
2021-02-23 19:12:16 +08:00
}
2020-05-15 16:52:35 +08:00
local kMaxTab = #TabToContent
2020-05-09 13:31:21 +08:00
function OperatingPanel:InitComponent()
2021-04-21 13:12:04 +08:00
self.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
self.btnBack = Util.GetGameObject(self.transform, "bg/btnBack")
2020-05-25 19:16:23 +08:00
self.tabsContent = Util.GetGameObject(self.transform, "bg/tabList/viewPort/tabsContent"):GetComponent("RectTransform")
2020-05-09 13:31:21 +08:00
self.operateTabs = {}
self.selectTabs = {}
for i = 1, kMaxTab do
self.operateTabs[i] = Util.GetGameObject(self.tabsContent.transform, "tabs_" .. i)
2021-04-21 13:12:04 +08:00
self.operateTabs[i]:GetComponent("Image").sprite = self.spLoader:LoadSprite(TabImageConfig[i].normal)
2020-05-09 13:31:21 +08:00
self.selectTabs[i] = Util.GetGameObject(self.operateTabs[i], "selected")
2021-04-21 13:12:04 +08:00
self.selectTabs[i]:GetComponent("Image").sprite = self.spLoader:LoadSprite(TabImageConfig[i].select)
2020-05-09 13:31:21 +08:00
end
self.selectTabIndex = -1
self.operatingContents = {
[1] = CumulativeSignIn.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
2020-05-09 13:31:21 +08:00
[2] = MonthCardPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_2")),
[3] = GrowthGiftPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_3")),
[4] = ContinuityRechargePage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_4")),
[5] = WeekMonthGiftPackPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_5")),
2020-05-09 13:31:21 +08:00
[6] = AttentionGiftPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_6")),
[7] = UpperMonthCard:New(self, Util.GetGameObject(self.transform, "bg/pageContent/page_7")),
}
table.walk(self.operatingContents, function(content)
content:OnHide()
end)
BindRedPointObject(RedPointType.CumulativeSignIn, Util.GetGameObject(self.operateTabs[1], "redPoint"))
2020-09-25 14:11:05 +08:00
BindRedPointObject(RedPointType.WeekGiftPage, Util.GetGameObject(self.operateTabs[5], "redPoint"))
BindRedPointObject(RedPointType.MonthGiftPage, Util.GetGameObject(self.operateTabs[6], "redPoint"))
2020-05-09 13:31:21 +08:00
BindRedPointObject(RedPointType.MonthCard, Util.GetGameObject(self.operateTabs[2], "redPoint"))
BindRedPointObject(RedPointType.GrowthGift, Util.GetGameObject(self.operateTabs[3], "redPoint"))
2020-05-15 16:52:35 +08:00
-- BindRedPointObject(RedPointType.ContinuityRecharge, Util.GetGameObject(self.operateTabs[4], "redPoint"))
2020-05-09 13:31:21 +08:00
-- 上部货币显示
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform, { showType = UpViewOpenType.ShowLeft })
end
function OperatingPanel:BindEvent()
Util.AddClick(self.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
--UIManager.OpenPanel(UIName.MainPanel)
end)
for i = 1, kMaxTab do
Util.AddClick(self.operateTabs[i], function()
self:OnTabClicked(i)
end)
end
end
2020-06-28 17:48:49 +08:00
function OperatingPanel:OnOpen(data)
2020-05-09 13:31:21 +08:00
for i = 1, #self.operatingContents do
self.operatingContents[i]:OnHide()
end
data = data and data or {}
self.selectTabIndex = data.tabIndex and data.tabIndex or self:GetPriorityIndex()
self.extraParam = data.extraParam
2020-06-08 20:18:49 +08:00
self.showType= data.showType or 1
2020-05-09 13:31:21 +08:00
self.tabsContent.anchoredPosition = Vector2(0, 0)
self:RefreshTabStatus()
end
function OperatingPanel:OnShow()
SoundManager.PlayMusic(SoundConfig.BGM_Main)
self:OnTabChanged(self.selectTabIndex)
end
function OperatingPanel:OnSortingOrderChange()
--特效穿透签到 和 礼包特殊处理
2020-07-08 11:46:43 +08:00
self.operatingContents[1]:OnSortingOrderChange( self.sortingOrder)
2020-06-28 17:52:29 +08:00
self.operatingContents[3]:OnSortingOrderChange( self.sortingOrder)
self.operatingContents[4]:OnSortingOrderChange( self.sortingOrder)
self.operatingContents[5]:OnSortingOrderChange( self.sortingOrder)
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function OperatingPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MonthCard.OnMonthCardUpdate, self.RefreshMonthCardData,self)
end
--移除事件监听(用于子类重写)
function OperatingPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MonthCard.OnMonthCardUpdate, self.RefreshMonthCardData,self)
end
function OperatingPanel:RefreshMonthCardData()
if self.selectTabIndex == 2 then
self.operatingContents[2]:OnShow(self.sortingOrder,nil, self.selectTabIndex)
end
end
function OperatingPanel:OnClose()
if self.selectTabIndex ~= -1 then
2020-05-15 16:52:35 +08:00
local curContent = TabToContent[self.selectTabIndex]
if curContent then
self.operatingContents[curContent]:OnHide()
end
2020-05-09 13:31:21 +08:00
end
end
function OperatingPanel:OnDestroy()
SubUIManager.Close(self.UpView)
ClearRedPointObject(RedPointType.CumulativeSignIn)
ClearRedPointObject(RedPointType.GrowthGift)
ClearRedPointObject(RedPointType.MonthCard)
2020-09-25 14:11:05 +08:00
ClearRedPointObject(RedPointType.WeekGiftPage)
ClearRedPointObject(RedPointType.MonthGiftPage)
2020-05-09 13:31:21 +08:00
self.operatingContents[1]:OnDestroy()
2020-08-13 22:30:09 +08:00
self.operatingContents[5]:OnDestroy()
2021-04-21 13:12:04 +08:00
self.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
function OperatingPanel:OnTabClicked(index)
if index == 9 then --第9个是什么绑定手鸡
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11386])
2020-05-09 13:31:21 +08:00
return
end
if self.selectTabIndex == index then
return
end
self:OnTabChanged(index)
end
function OperatingPanel:OnTabChanged(index)
for i, select in ipairs(self.selectTabs) do
select:SetActive(i == index)
end
self:ShowTabContent(index)
end
function OperatingPanel:ShowTabContent(index)
2020-06-28 17:48:49 +08:00
-- 货币界面
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.SoulCrystal })
2020-05-09 13:31:21 +08:00
local oldSelect
oldSelect, self.selectTabIndex = self.selectTabIndex, index
2020-05-15 16:52:35 +08:00
local oldContent, curContent = TabToContent[oldSelect], TabToContent[self.selectTabIndex]
if oldContent then
self.operatingContents[oldContent]:OnHide()
end
if index == 5 then
2020-06-03 19:09:01 +08:00
self.operatingContents[curContent]:OnShow(self.sortingOrder, 1)
2020-05-15 16:52:35 +08:00
return
elseif index == 6 then
2020-06-03 19:09:01 +08:00
self.operatingContents[curContent]:OnShow(self.sortingOrder, 2)
2020-05-15 16:52:35 +08:00
return
2020-06-28 17:48:49 +08:00
elseif index==10 then
self.operatingContents[curContent]:OnShow(self.sortingOrder)
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TimelimitCall })
return
2020-07-08 11:46:43 +08:00
elseif index == 11 then
self.operatingContents[curContent]:OnShow(self.sortingOrder)
2020-07-14 11:05:47 +08:00
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.QianKunBox })
2020-07-08 11:46:43 +08:00
return
2020-05-09 13:31:21 +08:00
end
if self.extraParam then
2020-05-15 16:52:35 +08:00
self.operatingContents[curContent]:OnShow(self.sortingOrder, self.extraParam, self.selectTabIndex)
2020-05-09 13:31:21 +08:00
self.extraParam = nil
else
2020-05-15 16:52:35 +08:00
self.operatingContents[curContent]:OnShow(self.sortingOrder,nil, self.selectTabIndex)
2020-05-09 13:31:21 +08:00
end
end
--活动结束隐藏的按钮
function OperatingPanel:RefreshTabStatus()
for n = 1, #self.operateTabs do
self.operateTabs[n]:SetActive(false)
end
if self.showType==ShowType.Welfare.type then
for i = 1, #ShowType.Welfare.body do
self.operateTabs[ShowType.Welfare.body[i]]:SetActive(true)
end
--判断成长基金活动是否开启或结束16是最后一档活动ActivityId
local t2 = false
2020-06-08 13:57:30 +08:00
local GrowthRewardId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.GrowthReward)
if GrowthRewardId then--是否开启
t2 = true
end
local hasGift = OperatingManager.HasGoodsByShowType(4)
if t2 and not hasGift then
t2 = false
end
if t2 and GrowthRewardId == 16 then--是否结束
local singleRewardData = ActivityGiftManager.GetActivityInfo(GrowthRewardId, 5324)
2020-06-08 13:57:30 +08:00
if not singleRewardData then
2020-05-25 19:16:23 +08:00
t2 = false
2020-06-08 13:57:30 +08:00
else
if singleRewardData.state == 1 then
t2 = false
end
2020-05-25 19:16:23 +08:00
end
end
self.operateTabs[3]:SetActive(t2)
2020-05-15 16:52:35 +08:00
self.operateTabs[4]:SetActive(false)
2020-07-24 12:11:00 +08:00
--
local isWeekGift = OperatingManager.HasGoodsByShowType(15)
local isMonthGift = OperatingManager.HasGoodsByShowType(16)
self.operateTabs[5]:SetActive(isWeekGift)
self.operateTabs[6]:SetActive(isMonthGift)
2020-05-09 13:31:21 +08:00
elseif self.showType==ShowType.MonthFund.type then
--- 7 跟 8 是活动开启
self.operateTabs[7]:SetActive(OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_128))--, SALARY_TYPE.BASE_128
self.operateTabs[8]:SetActive(OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_328))--, SALARY_TYPE.BASE_328
2020-07-24 12:11:00 +08:00
2020-05-09 13:31:21 +08:00
end
2020-07-31 10:33:05 +08:00
2020-07-31 13:35:15 +08:00
if not RECHARGEABLE then--(是否开启充值)
self.operateTabs[5]:SetActive(false)
2020-07-31 13:35:15 +08:00
self.operateTabs[2]:SetActive(false)
self.operateTabs[6]:SetActive(false)
2020-07-31 13:35:15 +08:00
self.operateTabs[3]:SetActive(false)
self.operateTabs[7]:SetActive(false)--, SALARY_TYPE.BASE_128
self.operateTabs[8]:SetActive(false)--, SALARY_TYPE.BASE_328
2020-08-03 10:18:04 +08:00
self.operateTabs[10]:SetActive(true)
self.operateTabs[11]:SetActive(true)
self.operateTabs[12]:SetActive(true)
2020-07-31 13:35:15 +08:00
end
2020-05-09 13:31:21 +08:00
end
function OperatingPanel:GetPriorityIndex()
local index = 1
2020-05-09 13:31:21 +08:00
for idx, operateItem in ipairs(self.operateTabs) do
if Util.GetGameObject(operateItem, "redPoint").activeSelf then
index = idx
break
end
end
return index
end
2020-06-23 18:36:24 +08:00
return OperatingPanel