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

254 lines
9.8 KiB
Lua
Raw Normal View History

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 = {
[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,redpoint= RedPointType.chaozhifanli6,price = 6},
--[2] = {bg1 = "b_baibao_andi",bg2 = "b_baibao_liangdi",text1 = "c_czfl_18yuan",text2 = "c_czfl_18yuan",showType = 49,actType = 111,goodsType = GoodsTypeDef.chaozhifanli,redpoint= RedPointType.chaozhifanli30,price = 12},
--[3] = {bg1 = "b_baibao_andi",bg2 = "b_baibao_liangdi",text1 = "c_czfl_18yuan",text2 = "c_czfl_18yuan",showType = 49,actType = ActivityTypeDef.chaozhifanli30,goodsType = GoodsTypeDef.chaozhifanli,redpoint= RedPointType.chaozhifanli30,price = 30},
2021-12-16 11:45:02 +08:00
}
2021-12-16 18:41:30 +08:00
local curPage = 1
local redList = {}
local gridPar
2021-12-16 18:41:30 +08:00
function PremiumRebatePanel:InitComponent()
2021-12-17 16:41:08 +08:00
this.spLoader = SpriteLoader.New()
this.backBtn = Util.GetGameObject(self.gameObject, "closeBtn")
2023-11-02 18:49:37 +08:00
this.btn_close = Util.GetGameObject(self.gameObject, "Bg/btn_close")
2021-12-17 16:41:08 +08:00
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")
Util.GetGameObject(self.gameObject, "Bg/NameBg/Image"):GetComponent("Text").text="超值连充"
this.jiantou=Util.GetGameObject(self.gameObject, "Bg/jiantou")
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
this.itemViewList = {}
grid=Util.GetGameObject(self.gameObject, "Bg/scroll/ScrollCycleView/grid"):GetComponent("RectTransform")
2021-12-17 16:41:08 +08:00
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()
2023-11-02 18:49:37 +08:00
end)
Util.AddOnceClick(this.btn_close, 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")
2022-11-09 17:55:54 +08:00
local title = Util.GetGameObject(tab, "Text"):GetComponent("Text")
local red = Util.GetGameObject(tab, "red")
2021-12-16 18:41:30 +08:00
if status == "select" then
select.gameObject:SetActive(true)
2022-11-09 17:55:54 +08:00
title.text = BTNS[index].price..""
2021-12-16 18:41:30 +08:00
else
select.gameObject:SetActive(false)
2022-11-09 17:55:54 +08:00
title.text = BTNS[index].price..""
2021-12-16 11:45:02 +08:00
end
BindRedPointObject(BTNS[index].redpoint,red)
redList[BTNS[index].redpoint] = red
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)
FixedUpdateBeat:Add(this.OnUpdate,self)
2021-12-17 16:41:08 +08:00
this.PageTabCtrl:Init(this.tabbox.gameObject, BTNS,curPage)
2021-12-16 11:45:02 +08:00
end
2022-12-30 15:40:43 +08:00
local sorts={
[1]=0,
[0]=1,
[2]=2,
}
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)
2022-02-11 15:09:32 +08:00
table.sort(this.actData.mission,function(a,b)
2022-12-30 15:40:43 +08:00
if a.state==b.state then
2022-02-11 15:09:32 +08:00
return a.missionId < b.missionId
2022-12-30 15:40:43 +08:00
else
return sorts[a.state]<sorts[b.state]
end
2022-02-11 15:09:32 +08:00
end)
2022-11-09 17:55:54 +08:00
LogError("this.actData.activityId=="..this.actData.activityId)
--this.giftData = DynamicActivityManager.GetGiftDataByType({{DataType.Direct,BTNS[curPage].goodsType,BTNS[curPage].showType}})
2021-12-17 16:41:08 +08:00
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)
2022-11-09 17:55:54 +08:00
this.leftTime.text = "每档位每日限购一次"
2021-12-17 16:41:08 +08:00
this:SetRewardShow(isTop,isAni)
this:SetTime()
2021-12-16 11:45:02 +08:00
end
function this.OnUpdate()
if gridPar~=nil then
if gridPar.localPosition and gridPar.localPosition.y>2140 then
this.jiantou:SetActive(false)
else
this.jiantou:SetActive(true)
end
end
end
2021-12-16 18:41:30 +08:00
function PremiumRebatePanel:SetRewardShow(isTop,isAni)
2021-12-16 11:45:02 +08:00
-- 显示
this.scrollView:SetData(this.actData.mission, function (index, item)
this:ShowSingleHero(item, this.actData.mission[index],index)
2021-12-16 11:45:02 +08:00
end,not isTop,not isAni)
2022-02-11 15:09:32 +08:00
local index = this.actData.value + 1
for i = 1,#this.actData.mission do
if this.actData.mission[i].state == 0 and this.actData.mission[i].progress >= activityRewardConfig[this.actData.mission[i].missionId].Values[1][1] then
index = i
break
end
end
this.scrollView:SetIndex(index)
2021-12-16 11:45:02 +08:00
end
2022-12-30 15:40:43 +08:00
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")
2022-02-11 15:09:32 +08:00
local btnProgressText = Util.GetGameObject(go, "btnGet/progress"):GetComponent("Text")
2021-12-16 11:45:02 +08:00
local btnImg = Util.GetGameObject(go, "btnGet"):GetComponent("Image")
local red = Util.GetGameObject(btnImg.gameObject, "red")
2022-12-30 15:40:43 +08:00
LogError("_data.missionId===".._data.missionId.." state==".._data.state)
local missionConfigData = activityRewardConfig[_data.missionId]
if missionConfigData then
2021-12-30 15:05:21 +08:00
go.gameObject:SetActive(true)
else
go.gameObject:SetActive(false)
return
end
2022-11-09 17:55:54 +08:00
--btnProgressText.text = string.format("%s/%s",_data.progress,missionConfigData.Values[1][1])
btnProgressText.gameObject:SetActive(false)
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
2022-11-09 17:55:54 +08:00
local recharge=ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,missionConfigData.Values[1][1])
title.text = recharge.Name
if recharge then
for i = 1, #recharge.BaseReward do
local reward=recharge.BaseReward[i]
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
if tonumber(reward)~=0 and tonumber(reward[1])~=0 then
this.itemViewList[go][i]:OnOpen(false, {reward[1],reward[2],reward[3]}, 0.65,false,false,false,this.sortingOrder)
this.itemViewList[go][i].gameObject:SetActive(true)
end
2021-12-16 11:45:02 +08:00
end
end
2022-11-09 17:55:54 +08:00
2021-12-16 18:41:30 +08:00
btnText.gameObject:SetActive(true)
red.gameObject:SetActive(false)
2023-11-08 17:38:45 +08:00
btnImg.sprite = this.spLoader:LoadSprite("Btn_hz_cheng_01")
btnText.text = "前往"--_data.data.price
2022-11-09 17:55:54 +08:00
if _data.state == 0 then --不可购买
2021-12-16 18:41:30 +08:00
Util.SetGray(btnGet,true)
2022-11-09 17:55:54 +08:00
btnText.text = recharge.Price
btnText.text = recharge.Price..""
elseif _data.state == 1 then --可购买
Util.SetGray(btnGet,false)
btnText.text = recharge.Price..""
elseif _data.state==2 then --已购买
-- body
Util.SetGray(btnGet,false)
btnText.text = "已购买"
2021-12-16 18:41:30 +08:00
end
2022-11-09 17:55:54 +08:00
Util.AddOnceClick(btnGet,function ()
if _data.state==0 then
--PopupTipPanel.ShowTip("购买上一档礼包后可购买")
elseif _data.state==1 then
PayManager.Pay(recharge.Id, function(id)
_data.state = 2
self:ShowSingleHero(go,_data,index)
end)
elseif _data.state==2 then
PopupTipPanel.ShowTip("已购买")
end
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()
--FixedUpdateBeat:Remove(this.OnUpdate,self)
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()
FixedUpdateBeat:Remove(this.OnUpdate,self)
2021-12-17 16:41:08 +08:00
this.itemViewList = {}
for k,v in pairs(redList) do
ClearRedPointObject(k,v)
end
redList = {}
2021-12-16 11:45:02 +08:00
end
2021-12-16 18:41:30 +08:00
return PremiumRebatePanel