miduo_client/Assets/ManagedResources/~Lua/Modules/ContinuePackage/PremiumRebatePanel.lua

176 lines
6.6 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.

require("Base/BasePanel")
local PremiumRebatePanel = Inherit(BasePanel)
local this = PremiumRebatePanel
local rechargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local activityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
local TabBox = require("Modules/Common/TabBox")
local tabs = {}
local BTNS = {
[1] = {bg1 = "b_baibao_andi",bg2 = "b_baibao_liangdi",text1 = "6\n",showType = 48,},
[2] = {bg1 = "b_baibao_andi",bg2 = "b_baibao_liangdi",text1 = "30\n",showType = 49,},
}
local curPage = 1
function PremiumRebatePanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.backBtn = Util.GetGameObject(self.gameObject, "closeBtn")
self.itemPre = Util.GetGameObject(self.gameObject, "Bg/ItemPre")
self.scrollItem = Util.GetGameObject(self.gameObject, "Bg/scroll")
self.leftTime = Util.GetGameObject(self.gameObject, "Bg/time"):GetComponent("Text")
self.tabbox = Util.GetGameObject(self.gameObject, "bg/tabbox")
local rootHight = self.scrollItem.transform.rect.height
local width = self.scrollItem.transform.rect.width
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollItem.transform,
self.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, -5))
self.scrollView.moveTween.MomentumAmount = 1
self.scrollView.moveTween.Strength = 2
self.scrollView.elastic = false
self.itemViewList = {}
self.sortingOrder = 0
end
--绑定事件(用于子类重写)
function PremiumRebatePanel:BindEvent()
Util.AddOnceClick(self.backBtn, function()
self:ClosePanel()
end)
-- 初始化Tab管理器
self.PageTabCtrl = TabBox.New()
self.PageTabCtrl:SetTabAdapter(self.PageTabAdapter)
self.PageTabCtrl:SetTabIsLockCheck(self.PageTabIsLockCheck)
self.PageTabCtrl:SetChangeTabCallBack(self.OnPageTabChange)
end
function PremiumRebatePanel.PageTabAdapter(tab, index, status)
local select = Util.GetGameObject(tab, "select")
local title = Util.GetGameObject(tab, "title"):GetComponent("Text")
title.text = self.spLoader:LoadSprite(BTNS[index].text1)
if status == "select" then
select.gameObject:SetActive(true)
else
select.gameObject:SetActive(false)
end
end
function PremiumRebatePanel.PageTabIsLockCheck()
return true
end
function PremiumRebatePanel.OnPageTabChange(index)
if curPage == index then
return
end
curPage = index
this:Refresh(false,false)
end
--添加事件监听(用于子类重写)
function PremiumRebatePanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityProgressStateChange,self.OnShow,self)
end
--移除事件监听(用于子类重写)
function PremiumRebatePanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityProgressStateChange,self.OnShow,self)
end
function PremiumRebatePanel:OnSortingOrderChange()
end
--界面打开时调用(用于子类重写)
function PremiumRebatePanel:OnOpen()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function PremiumRebatePanel:OnShow()
self.actData = ActivityGiftManager.GetActivityInfo(ActivityTypeDef.chaozhifanli)
self.actConfigData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",ActivityTypeDef.chaozhifanli)
self:Refresh(true,true)
end
function PremiumRebatePanel:Refresh(isTop,isAni)
self.giftData = DynamicActivityManager.GetGiftDataByType({DataType.Direct,5,BTNS[curPage].showType})
self:SetRewardShow(isTop,isAni)
self:SetTime()
end
function PremiumRebatePanel:SetRewardShow(isTop,isAni)
-- 显示
self.scrollView:SetData(self.giftData, function (index, item)
self:ShowSingleHero(item, self.giftData[index],index)
end,not isTop,not isAni)
end
function PremiumRebatePanel:ShowSingleHero(go,_data,index)
local title = Util.GetGameObject(go, "title"):GetComponent("Text")
local grid = Util.GetGameObject(go, "Grid")
local btnGet = Util.GetGameObject(go, "btnGet")
local btnText = Util.GetGameObject(go, "btnGet/Text"):GetComponent("Text")
local btnImg = Util.GetGameObject(go, "btnGet"):GetComponent("Image")
local obj = Util.GetGameObject(btnGet, "Obj")
local icon = Util.GetGameObject(obj, "icon"):GetComponent("Image")
local cost = Util.GetGameObject(obj, "cost"):GetComponent("Text")
local missionConfigData = self.actConfigData[(curPage - 1)*15 + index]
title.text = missionConfigData.ContentsShow
if not self.itemViewList[go] then
self.itemViewList[go] = {}
end
for k,v in ipairs(self.itemViewList[go]) do
v.gameObject:SetActive(false)
end
for i = 1, #_data.data.shows do
if not self.itemViewList[go][i] then
self.itemViewList[go][i] = SubUIManager.Open(SubUIConfig.ItemView,self.grid.transform)
self.itemViewList[go][i].gameObject:SetActive(false)
end
self.itemViewList[go][i]:OnOpen(false, {_data.data.shows[i][1],_data.data.shows[i][2],_data.data.shows[i][3]}, 0.9,false,false,false,self.sortingOrder)
self.itemViewList[go][i].gameObject:SetActive(true)
end
btnText.gameObject:SetActive(true)
btnText.text = string.format("%s 元",_data.data.price)
local missionData = self.actData.mission[(curPage - 1)*15 + index]
if missionData then
if missionData.state == 0 then
Util.SetGray(btnGet,false)
Util.AddOnceClick(btnGet,function ()
PayManager.Pay(_data.data.shopData.goodsId, function(id)
FirstRechargeManager.RefreshAccumRechargeValue(_data.data.shopData.goodsId)
OperatingManager.SetHadBuyGoodsId({_data.data.shopData.goodsId})
missionData.state = 0
self:ShowSingleHero(go,_data,index)
self:Refresh(false,false)
end)
end)
else
Util.SetGray(btnGet,true)
btnText.text = "已购买"
end
else
Util.SetGray(btnGet,true)
PopupTipPanel.ShowTip("累计购买X天后才可购买")
end
end
function PremiumRebatePanel:SetTime()
end
function PremiumRebatePanel:OnClose()
if self.timer then
self.timer:Stop()
self.timer = nil
end
end
--界面销毁时调用(用于子类重写)
function PremiumRebatePanel:OnDestroy()
self.spLoader:Destroy()
self.itemViewList = {}
end
return PremiumRebatePanel