2021-12-16 11:45:02 +08:00
|
|
|
|
require("Base/BasePanel")
|
2021-12-16 18:41:30 +08:00
|
|
|
|
local PremiumRebatePanel = Inherit(BasePanel)
|
|
|
|
|
local this = PremiumRebatePanel
|
2021-12-16 11:45:02 +08:00
|
|
|
|
local rechargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
|
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
local activityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
|
|
|
|
|
local TabBox = require("Modules/Common/TabBox")
|
2021-12-16 11:45:02 +08:00
|
|
|
|
local BTNS = {
|
2021-12-17 16:41:08 +08:00
|
|
|
|
[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},
|
2021-12-16 11:45:02 +08:00
|
|
|
|
}
|
2021-12-16 18:41:30 +08:00
|
|
|
|
local curPage = 1
|
|
|
|
|
function PremiumRebatePanel:InitComponent()
|
2021-12-17 16:41:08 +08:00
|
|
|
|
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")
|
2021-12-16 11:45:02 +08:00
|
|
|
|
|
2021-12-17 16:41:08 +08:00
|
|
|
|
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
|
2021-12-16 18:41:30 +08:00
|
|
|
|
|
2021-12-17 16:41:08 +08:00
|
|
|
|
this.itemViewList = {}
|
|
|
|
|
this.sortingOrder = 0
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:BindEvent()
|
2021-12-17 16:41:08 +08:00
|
|
|
|
Util.AddOnceClick(this.backBtn, function()
|
|
|
|
|
this:ClosePanel()
|
2021-12-16 18:41:30 +08:00
|
|
|
|
end)
|
|
|
|
|
-- 初始化Tab管理器
|
2021-12-17 16:41:08 +08:00
|
|
|
|
this.PageTabCtrl = TabBox.New()
|
|
|
|
|
this.PageTabCtrl:SetTabAdapter(this.PageTabAdapter)
|
|
|
|
|
this.PageTabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck)
|
|
|
|
|
this.PageTabCtrl:SetChangeTabCallBack(this.OnPageTabChange)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-17 16:41:08 +08:00
|
|
|
|
function this.PageTabAdapter(tab, index, status)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
local select = Util.GetGameObject(tab, "select")
|
2021-12-17 16:41:08 +08:00
|
|
|
|
local title = Util.GetGameObject(tab, "title"):GetComponent("Image")
|
2021-12-16 18:41:30 +08:00
|
|
|
|
if status == "select" then
|
|
|
|
|
select.gameObject:SetActive(true)
|
2021-12-17 16:41:08 +08:00
|
|
|
|
title.sprite = this.spLoader:LoadSprite(BTNS[index].text1)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
else
|
|
|
|
|
select.gameObject:SetActive(false)
|
2021-12-17 16:41:08 +08:00
|
|
|
|
title.sprite = this.spLoader:LoadSprite(BTNS[index].text2)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
2021-12-16 18:41:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-17 16:41:08 +08:00
|
|
|
|
function this.PageTabIsLockCheck()
|
|
|
|
|
return false
|
2021-12-16 18:41:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-17 16:41:08 +08:00
|
|
|
|
function this.OnPageTabChange(index)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
if curPage == index then
|
|
|
|
|
return
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
2021-12-16 18:41:30 +08:00
|
|
|
|
curPage = index
|
|
|
|
|
this:Refresh(false,false)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
2021-12-16 18:41:30 +08:00
|
|
|
|
|
2021-12-16 11:45:02 +08:00
|
|
|
|
--添加事件监听(用于子类重写)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:AddListener()
|
2021-12-17 16:41:08 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityProgressStateChange,this.OnShow,self)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:RemoveListener()
|
2021-12-17 16:41:08 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityProgressStateChange,this.OnShow,self)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:OnSortingOrderChange()
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
2021-12-16 18:41:30 +08:00
|
|
|
|
|
2021-12-16 11:45:02 +08:00
|
|
|
|
--界面打开时调用(用于子类重写)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:OnOpen()
|
2021-12-17 16:41:08 +08:00
|
|
|
|
curPage = 1
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:OnShow()
|
2021-12-17 16:41:08 +08:00
|
|
|
|
this:Refresh(true,true)
|
|
|
|
|
this.PageTabCtrl:Init(this.tabbox.gameObject, BTNS,curPage)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:Refresh(isTop,isAni)
|
2021-12-17 16:41:08 +08:00
|
|
|
|
--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)
|
2021-12-17 13:29:08 +08:00
|
|
|
|
end
|
2021-12-17 16:41:08 +08:00
|
|
|
|
|
|
|
|
|
this:SetRewardShow(isTop,isAni)
|
|
|
|
|
this:SetTime()
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:SetRewardShow(isTop,isAni)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
-- 显示
|
2021-12-17 16:41:08 +08:00
|
|
|
|
this.scrollView:SetData(this.giftData, function (index, item)
|
|
|
|
|
this:ShowSingleHero(item, this.giftData[index],index)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end,not isTop,not isAni)
|
2021-12-17 16:41:08 +08:00
|
|
|
|
this.scrollView:SetIndex(this.actData.value + 1)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:ShowSingleHero(go,_data,index)
|
|
|
|
|
local title = Util.GetGameObject(go, "title"):GetComponent("Text")
|
2021-12-16 11:45:02 +08:00
|
|
|
|
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")
|
2021-12-17 16:41:08 +08:00
|
|
|
|
local missionConfigData = this.actConfigData[index]
|
2021-12-16 18:41:30 +08:00
|
|
|
|
title.text = missionConfigData.ContentsShow
|
2021-12-17 16:41:08 +08:00
|
|
|
|
if not this.itemViewList[go] then
|
|
|
|
|
this.itemViewList[go] = {}
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
2021-12-17 16:41:08 +08:00
|
|
|
|
for k,v in ipairs(this.itemViewList[go]) do
|
2021-12-16 11:45:02 +08:00
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
end
|
2021-12-16 18:41:30 +08:00
|
|
|
|
for i = 1, #_data.data.shows do
|
2021-12-17 16:41:08 +08:00
|
|
|
|
if not this.itemViewList[go][i] then
|
|
|
|
|
this.itemViewList[go][i] = SubUIManager.Open(SubUIConfig.ItemView,grid.transform)
|
|
|
|
|
this.itemViewList[go][i].gameObject:SetActive(false)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
2021-12-17 16:41:08 +08:00
|
|
|
|
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)
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
2021-12-16 18:41:30 +08:00
|
|
|
|
btnText.gameObject:SetActive(true)
|
2021-12-17 16:41:08 +08:00
|
|
|
|
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
|
2021-12-17 11:22:54 +08:00
|
|
|
|
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})
|
2021-12-17 18:46:05 +08:00
|
|
|
|
ActivityGiftManager.SetActivityInfo(this.actData.activityId, missionData.missionId, 1)
|
|
|
|
|
missionData.state = 1
|
|
|
|
|
self:ShowSingleHero(go,_data,index)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
end)
|
2021-12-17 11:22:54 +08:00
|
|
|
|
end)
|
|
|
|
|
elseif missionData.state == 1 then
|
|
|
|
|
Util.SetGray(btnGet,true)
|
|
|
|
|
btnText.text = "已购买"
|
2021-12-17 17:19:30 +08:00
|
|
|
|
Util.AddOnceClick(btnGet,function ()
|
|
|
|
|
|
|
|
|
|
end)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
else
|
|
|
|
|
Util.SetGray(btnGet,true)
|
2021-12-17 16:41:08 +08:00
|
|
|
|
Util.AddOnceClick(btnGet,function ()
|
2021-12-17 17:48:26 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format("累计充值超值返利%s天时可领取!",index))
|
2021-12-17 16:41:08 +08:00
|
|
|
|
end)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
end
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:SetTime()
|
|
|
|
|
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:OnClose()
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
2021-12-16 18:41:30 +08:00
|
|
|
|
function PremiumRebatePanel:OnDestroy()
|
2021-12-17 16:41:08 +08:00
|
|
|
|
this.spLoader:Destroy()
|
|
|
|
|
this.itemViewList = {}
|
2021-12-16 11:45:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 18:41:30 +08:00
|
|
|
|
return PremiumRebatePanel
|