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

256 lines
9.5 KiB
Lua
Raw Normal View History

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")--月基金
2020-06-28 17:48:49 +08:00
local TimeLimitedCall = require("Modules/Operating/TimeLimitedCall")--限时召唤
2020-05-09 13:31:21 +08:00
---@class OperatingPanel
local OperatingPanel = quick_class("OperatingPanel", BasePanel)
2020-06-28 17:48:49 +08:00
local kMaxTab = 10
2020-05-09 13:31:21 +08:00
--显示类型 type 面板类型 body 显示页签索引
local ShowType={
2020-05-25 19:16:23 +08:00
Welfare={type=1,body={1,2,5,9}},--福利
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] = 6,
[7] = 7,
[8] = 7,
[9] = 1,
2020-06-28 17:48:49 +08:00
[10] = 8,
2020-05-15 16:52:35 +08:00
}
local kMaxTab = #TabToContent
2020-05-09 13:31:21 +08:00
function OperatingPanel:InitComponent()
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)
self.selectTabs[i] = Util.GetGameObject(self.operateTabs[i], "selected")
end
self.selectTabIndex = -1
self.operatingContents = {
2020-06-03 19:09:01 +08:00
[1] = WeekMonthGiftPackPage.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] = CumulativeSignIn.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_5")),
[6] = AttentionGiftPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_6")),
[7] = UpperMonthCard:New(self, Util.GetGameObject(self.transform, "bg/pageContent/page_7")),
2020-06-28 17:48:49 +08:00
[8] = TimeLimitedCall.new(self,Util.GetGameObject(self.transform, "bg/pageContent/page_8")),
2020-05-09 13:31:21 +08:00
}
table.walk(self.operatingContents, function(content)
content:OnHide()
end)
BindRedPointObject(RedPointType.GiftPage, Util.GetGameObject(self.operateTabs[1], "redPoint"))
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
BindRedPointObject(RedPointType.CumulativeSignIn, Util.GetGameObject(self.operateTabs[5], "redPoint"))
2020-06-28 17:48:49 +08:00
BindRedPointObject(RedPointType.TimeLimited, Util.GetGameObject(self.operateTabs[10], "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-06-28 17:48:49 +08:00
-- self.operatingContents[1]:OnSortingOrderChange( self.sortingOrder)
--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()
2020-06-08 20:18:49 +08:00
-- LogError("self.selectTabIndex 1 "..self.selectTabIndex)
2020-05-09 13:31:21 +08:00
if self.selectTabIndex == 2 then
2020-06-08 20:18:49 +08:00
-- LogError("self.selectTabIndex 2 "..self.selectTabIndex)
2020-05-09 13:31:21 +08:00
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()
2020-06-28 17:48:49 +08:00
LogRed("Remove UpVIew")
2020-05-09 13:31:21 +08:00
SubUIManager.Close(self.UpView)
ClearRedPointObject(RedPointType.CumulativeSignIn)
ClearRedPointObject(RedPointType.GrowthGift)
2020-05-15 16:52:35 +08:00
-- ClearRedPointObject(RedPointType.ContinuityRecharge)
2020-05-09 13:31:21 +08:00
ClearRedPointObject(RedPointType.GiftPage)
ClearRedPointObject(RedPointType.MonthCard)
2020-06-28 17:48:49 +08:00
ClearRedPointObject(RedPointType.TimeLimited)
2020-05-09 13:31:21 +08:00
self.operatingContents[1]:OnDestroy()
2020-06-28 17:48:49 +08:00
self.operatingContents[8]:OnDestroy()
2020-05-09 13:31:21 +08:00
end
function OperatingPanel:OnTabClicked(index)
if index == 6 then --第6个是什么绑定手鸡
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11487])
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 == 1 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 == 9 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-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
2020-06-08 13:57:30 +08:00
--判断成长基金活动是否结束16是最后一档活动ActivityId
local GrowthRewardId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.GrowthReward)
local singleRewardData
2020-05-25 19:16:23 +08:00
local t2 = true
2020-06-08 13:57:30 +08:00
if GrowthRewardId == 16 then
singleRewardData = ActivityGiftManager.GetActivityInfo(GrowthRewardId, 5324)
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-06-28 17:48:49 +08:00
self.operateTabs[10]:SetActive(ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy) ~= nil)
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
end
end
function OperatingPanel:GetPriorityIndex()
2020-06-13 11:47:13 +08:00
local index = 5
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