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

300 lines
12 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--[[
* @ClassName OperatingPanel
* @Description 运营活动
* @Date 2019/5/25 14:16
* @Author MagicianJoker, fengliudianshao@outlook.com
* @Copyright Copyright (c) 2019, MagicianJoker
--]]
--礼包>月卡>成长礼金>连续充值>签到>关注有礼>高级鸡精
local WeekMonthGiftPackPage = require("Modules/Operating/WeekMonthGiftPackPage")
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)
local kMaxTab = 11
--显示类型 type 面板类型 body 显示页签索引
local ShowType={
Welfare={type=1,body={1,2,5,6}},--福利
MonthFund={type=2,body={7,8}} --超值基金
}
local TabToContent = {
[1] = 1,
[2] = 2,
[3] = 3,
[4] = 4,
[5] = 5,
[6] = 5,
[7] = 7,
[8] = 7,
[9] = 6,
[10] = 5,
[11] = 5,
[12] = 5,
[13] = 8,
}
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"},
[13] = {normal = "s_sztq_icon2_zh", select = "s_sztq_icon1_zh"},
}
local kMaxTab = #TabToContent
function OperatingPanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.btnBack = Util.GetGameObject(self.transform, "bg/btnBack")
self.tabsContent = Util.GetGameObject(self.transform, "bg/tabList/viewPort/tabsContent"):GetComponent("RectTransform")
self.operateTabs = {}
self.selectTabs = {}
for i = 1, kMaxTab do
self.operateTabs[i] = Util.GetGameObject(self.tabsContent.transform, "tabs_" .. i)
self.operateTabs[i]:GetComponent("Image").sprite = self.spLoader:LoadSprite(TabImageConfig[i].normal)
self.selectTabs[i] = Util.GetGameObject(self.operateTabs[i], "selected")
self.selectTabs[i]:GetComponent("Image").sprite = self.spLoader:LoadSprite(TabImageConfig[i].select)
end
self.selectTabIndex = -1
self.operatingContents = {
[1] = CumulativeSignIn.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
[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")),
[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"))
BindRedPointObject(RedPointType.WeekGiftPage, Util.GetGameObject(self.operateTabs[5], "redPoint"))
BindRedPointObject(RedPointType.MonthGiftPage, Util.GetGameObject(self.operateTabs[6], "redPoint"))
BindRedPointObject(RedPointType.MonthCard, Util.GetGameObject(self.operateTabs[2], "redPoint"))
BindRedPointObject(RedPointType.GrowthGift, Util.GetGameObject(self.operateTabs[3], "redPoint"))
-- BindRedPointObject(RedPointType.ContinuityRecharge, Util.GetGameObject(self.operateTabs[4], "redPoint"))
-- 上部货币显示
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
function OperatingPanel:OnOpen(data)
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
self.showType= data.showType or 1
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()
--特效穿透签到 和 礼包特殊处理
self.operatingContents[1]:OnSortingOrderChange( self.sortingOrder)
self.operatingContents[3]:OnSortingOrderChange( self.sortingOrder)
self.operatingContents[4]:OnSortingOrderChange( self.sortingOrder)
self.operatingContents[5]:OnSortingOrderChange( self.sortingOrder)
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
local curContent = TabToContent[self.selectTabIndex]
if curContent then
self.operatingContents[curContent]:OnHide()
end
end
end
function OperatingPanel:OnDestroy()
SubUIManager.Close(self.UpView)
ClearRedPointObject(RedPointType.CumulativeSignIn)
ClearRedPointObject(RedPointType.GrowthGift)
ClearRedPointObject(RedPointType.MonthCard)
ClearRedPointObject(RedPointType.WeekGiftPage)
ClearRedPointObject(RedPointType.MonthGiftPage)
self.operatingContents[1]:OnDestroy()
self.operatingContents[5]:OnDestroy()
self.spLoader:Destroy()
end
function OperatingPanel:OnTabClicked(index)
if index == 9 then --第9个是什么绑定手鸡
PopupTipPanel.ShowTip(Language[11386])
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)
-- 货币界面
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.SoulCrystal })
local oldSelect
oldSelect, self.selectTabIndex = self.selectTabIndex, index
local oldContent, curContent = TabToContent[oldSelect], TabToContent[self.selectTabIndex]
if oldContent then
self.operatingContents[oldContent]:OnHide()
end
if index == 5 then
self.operatingContents[curContent]:OnShow(self.sortingOrder, 1)
return
elseif index == 6 then
self.operatingContents[curContent]:OnShow(self.sortingOrder, 2)
return
elseif index==10 then
self.operatingContents[curContent]:OnShow(self.sortingOrder)
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TimelimitCall })
return
elseif index == 11 then
self.operatingContents[curContent]:OnShow(self.sortingOrder)
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.QianKunBox })
return
end
if self.extraParam then
self.operatingContents[curContent]:OnShow(self.sortingOrder, self.extraParam, self.selectTabIndex)
self.extraParam = nil
else
self.operatingContents[curContent]:OnShow(self.sortingOrder,nil, self.selectTabIndex)
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
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)
if not singleRewardData then
t2 = false
else
if singleRewardData.state == 1 then
t2 = false
end
end
end
self.operateTabs[3]:SetActive(t2)
self.operateTabs[4]:SetActive(false)
--
local isWeekGift = OperatingManager.HasGoodsByShowType(15)
local isMonthGift = OperatingManager.HasGoodsByShowType(16)
self.operateTabs[5]:SetActive(isWeekGift)
self.operateTabs[6]:SetActive(isMonthGift)
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
if not RECHARGEABLE then--(是否开启充值)
self.operateTabs[5]:SetActive(false)
self.operateTabs[2]:SetActive(false)
self.operateTabs[6]:SetActive(false)
self.operateTabs[3]:SetActive(false)
self.operateTabs[7]:SetActive(false)--, SALARY_TYPE.BASE_128
self.operateTabs[8]:SetActive(false)--, SALARY_TYPE.BASE_328
self.operateTabs[10]:SetActive(true)
self.operateTabs[11]:SetActive(true)
self.operateTabs[12]:SetActive(true)
end
end
function OperatingPanel:GetPriorityIndex()
local index = 1
for idx, operateItem in ipairs(self.operateTabs) do
if Util.GetGameObject(operateItem, "redPoint").activeSelf then
index = idx
break
end
end
return index
end
return OperatingPanel