sk-client/Assets/ManagedResources/~Lua/Modules/Pay/ExpansionRedPacket.lua

76 lines
2.6 KiB
Lua

require("Base/BasePanel")
ExpansionRedPacket = Inherit(BasePanel)
local this = ExpansionRedPacket
this.RechargeCommodityConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.RechargeCommodityConfig, "Type", GoodsTypeDef.ExpansionRedPacket)
function this:InitComponent()
this.btnOnce = Util.GetGameObject(this.gameObject, "btnOnce")
this.btnMultiple = Util.GetGameObject(this.gameObject, "btnMultiple")
this.redPacket = Util.GetGameObject(this.gameObject, "redPacket")
this.btnBack = Util.GetGameObject(this.gameObject, "btnBack")
this.btnHelp = Util.GetGameObject(this.gameObject, "btnHelp")
this.helpPosition = this.btnHelp.transform:GetComponent("RectTransform").localPosition
Util.GetGameObject(this.gameObject, "btnOnce/Text"):GetComponent("Text").text = MoneyUtil.GetMoney(this.RechargeCommodityConfig[1].Price)
Util.GetGameObject(this.gameObject, "btnMultiple/Text"):GetComponent("Text").text = MoneyUtil.GetMoney(this.RechargeCommodityConfig[2].Price)
end
function this:BindEvent()
Util.AddClick(this.btnBack, function()
this:ClosePanel()
-- Game.GlobalEvent:DispatchEvent(GameEvent.Tokens.RefreshTask)
end)
Util.AddClick(this.btnOnce, function()
if not this.buyState then
return
end
PayManager.Pay({Id = this.RechargeCommodityConfig[1].Id}, function ()
this:OnShow()
-- Game.GlobalEvent:DispatchEvent(GameEvent.Tokens.RefreshTask)
end)
end)
Util.AddClick(this.btnMultiple, function()
if not this.buyState then
return
end
PayManager.Pay({Id = this.RechargeCommodityConfig[2].Id}, function ()
this:OnShow()
-- Game.GlobalEvent:DispatchEvent(GameEvent.Tokens.RefreshTask)
end)
end)
Util.AddClick(this.btnHelp, function()
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.ExpansionRedPacket, this.helpPosition.x, this.helpPosition.y)
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnOpen()
end
function this:OnShow()
this.buyState = true
for i = 1, #this.RechargeCommodityConfig do
local config = this.RechargeCommodityConfig[i]
local boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.ExpansionRedPacket, config.Id) or 0
if boughtNum >= config.Limit then
this.buyState = false
end
end
Util.SetGray(this.redPacket, not this.buyState)
Util.GetGameObject(this.gameObject, "redPacket/Image"):SetActive(not this.buyState)
end
function this:OnSortingOrderChange()
end
function this:OnClose()
end
function this:OnDestroy()
end
return ExpansionRedPacket