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

182 lines
7.4 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 BTNS = {
[1] = {bg1 = "b_baibao_andi",bg2 = "b_baibao_liangdi",text1 = "c_czfl_6yuan",text2 = "c_czfl_6yuan2",showType = 48,actType = ActivityTypeDef.chaozhifanli,goodsType = GoodsTypeDef.chaozhifanli},
[2] = {bg1 = "b_baibao_andi",bg2 = "b_baibao_liangdi",text1 = "c_czfl_30yuan",text2 = "c_czfl_30yuan2",showType = 49,actType = ActivityTypeDef.chaozhifanli30,goodsType = GoodsTypeDef.chaozhifanli},
}
local curPage = 1
function PremiumRebatePanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.backBtn = Util.GetGameObject(self.gameObject, "closeBtn")
this.itemPre = Util.GetGameObject(self.gameObject, "Bg/ItemPre")
this.scrollItem = Util.GetGameObject(self.gameObject, "Bg/scroll")
this.leftTime = Util.GetGameObject(self.gameObject, "Bg/time/leftTime"):GetComponent("Text")
this.tabbox = Util.GetGameObject(self.gameObject, "Bg/tabbox")
local rootHight = this.scrollItem.transform.rect.height
local width = this.scrollItem.transform.rect.width
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollItem.transform,
this.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 15))
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
this.scrollView.elastic = false
this.itemViewList = {}
this.sortingOrder = 0
end
--绑定事件(用于子类重写)
function PremiumRebatePanel:BindEvent()
Util.AddOnceClick(this.backBtn, function()
this:ClosePanel()
end)
-- 初始化Tab管理器
this.PageTabCtrl = TabBox.New()
this.PageTabCtrl:SetTabAdapter(this.PageTabAdapter)
this.PageTabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck)
this.PageTabCtrl:SetChangeTabCallBack(this.OnPageTabChange)
end
function this.PageTabAdapter(tab, index, status)
local select = Util.GetGameObject(tab, "select")
local title = Util.GetGameObject(tab, "title"):GetComponent("Image")
if status == "select" then
select.gameObject:SetActive(true)
title.sprite = this.spLoader:LoadSprite(BTNS[index].text1)
else
select.gameObject:SetActive(false)
title.sprite = this.spLoader:LoadSprite(BTNS[index].text2)
end
end
function this.PageTabIsLockCheck()
return false
end
function this.OnPageTabChange(index)
if curPage == index then
return
end
curPage = index
this:Refresh(false,false)
end
--添加事件监听(用于子类重写)
function PremiumRebatePanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityProgressStateChange,this.OnShow,self)
end
--移除事件监听(用于子类重写)
function PremiumRebatePanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityProgressStateChange,this.OnShow,self)
end
function PremiumRebatePanel:OnSortingOrderChange()
end
--界面打开时调用(用于子类重写)
function PremiumRebatePanel:OnOpen()
curPage = 1
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function PremiumRebatePanel:OnShow()
this:Refresh(true,true)
this.PageTabCtrl:Init(this.tabbox.gameObject, BTNS,curPage)
end
function PremiumRebatePanel:Refresh(isTop,isAni)
--value 累计充值天数 昨天
this.actData = ActivityGiftManager.GetActivityTypeInfo(BTNS[curPage].actType)
this.giftData = DynamicActivityManager.GetGiftDataByType({{DataType.Direct,BTNS[curPage].goodsType,BTNS[curPage].showType}})
this.actConfigData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",this.actData.activityId)
local missionConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ActivityRewardConfig,"ActivityId",this.actData.activityId,"Sort",this.actData.value + 1)
local missionData = ActivityGiftManager.GetActivityInfo(this.actData.activityId,missionConfig.Id)
if missionData.state == 1 then
this.leftTime.text = string.format("累计天数:%s/15",this.actData.value + 1)
else
this.leftTime.text = string.format("累计天数:%s/15",this.actData.value)
end
this:SetRewardShow(isTop,isAni)
this:SetTime()
end
function PremiumRebatePanel:SetRewardShow(isTop,isAni)
-- 显示
this.scrollView:SetData(this.giftData, function (index, item)
this:ShowSingleHero(item, this.giftData[index],index)
end,not isTop,not isAni)
this.scrollView:SetIndex(this.actData.value + 1)
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 missionConfigData = this.actConfigData[index]
title.text = missionConfigData.ContentsShow
if not this.itemViewList[go] then
this.itemViewList[go] = {}
end
for k,v in ipairs(this.itemViewList[go]) do
v.gameObject:SetActive(false)
end
for i = 1, #_data.data.shows do
if not this.itemViewList[go][i] then
this.itemViewList[go][i] = SubUIManager.Open(SubUIConfig.ItemView,grid.transform)
this.itemViewList[go][i].gameObject:SetActive(false)
end
this.itemViewList[go][i]:OnOpen(false, {_data.data.shows[i][1],_data.data.shows[i][2],_data.data.shows[i][3]}, 0.65,false,false,false,this.sortingOrder)
this.itemViewList[go][i].gameObject:SetActive(true)
end
btnText.gameObject:SetActive(true)
btnText.text = _data.data.price
local missionData = ActivityGiftManager.GetActivityInfo(this.actData.activityId,missionConfigData.Id)
if missionData.state == 0 and index == this.actData.value + 1 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})
ActivityGiftManager.SetActivityInfo(this.actData.activityId, missionData.missionId, 1)
missionData.state = 1
self:ShowSingleHero(go,_data,index)
end)
end)
elseif missionData.state == 1 then
Util.SetGray(btnGet,true)
btnText.text = "已购买"
Util.AddOnceClick(btnGet,function ()
end)
else
Util.SetGray(btnGet,true)
Util.AddOnceClick(btnGet,function ()
PopupTipPanel.ShowTip(string.format("累计充值超值返利%s天时可领取",index))
end)
end
end
function PremiumRebatePanel:SetTime()
end
function PremiumRebatePanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function PremiumRebatePanel:OnDestroy()
this.spLoader:Destroy()
this.itemViewList = {}
end
return PremiumRebatePanel