109 lines
4.1 KiB
Lua
109 lines
4.1 KiB
Lua
--[[
|
|
* @ClassName QuickPurchasePanel
|
|
* @Description 快捷购买界面
|
|
* @Date 2019/5/17 20:25
|
|
* @Author MagicianJoker, fengliudianshao@outlook.com
|
|
* @Copyright Copyright (c) 2019, MagicianJoker
|
|
--]]
|
|
|
|
local QuickCommonPurchasePart = require("Modules/QuickPurchase/QuickCommonPurchasePart")
|
|
local QuickSpecialPurchasePart = require("Modules/QuickPurchase/QuickSpecialPurchasePart")
|
|
local QuickCoinPurchasePart=require("Modules/QuickPurchase/QuickCoinPurchasePart")
|
|
|
|
---@class QuickPurchasePanel
|
|
local QuickPurchasePanel = quick_class("QuickPurchasePanel", BasePanel)
|
|
|
|
local ColorDef = {
|
|
"#000000FF",
|
|
"#FF0000FF",
|
|
"#FF0000FF",
|
|
}
|
|
|
|
function QuickPurchasePanel:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.Mask = Util.GetGameObject(self.transform, "Mask")
|
|
self.closeBtn = Util.GetGameObject(self.transform, "frame/bg/closeBtn")
|
|
self.title = Util.GetGameObject(self.transform, "frame/bg/title"):GetComponent("Text")
|
|
self.help = Util.GetGameObject(self.transform, "frame/bg/help")
|
|
self.commonPurchase = QuickCommonPurchasePart.new(self, self.transform:Find("frame/bg/commonPart"))
|
|
self.commonPurchase:OnHide()
|
|
self.specialPurchase = QuickSpecialPurchasePart.new(self, self.transform:Find("frame/bg/specialPart"))
|
|
self.specialPurchase:OnHide()
|
|
self.coinPurchase=QuickCoinPurchasePart.new(self,self.transform:Find("frame/bg/coinPart"))
|
|
self.coinPurchase:OnHide()
|
|
|
|
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function QuickPurchasePanel:BindEvent()
|
|
Util.AddOnceClick(self.help, function()
|
|
local pos = self.help.transform.localPosition
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.BuyCoin, pos.x, pos.y)
|
|
end)
|
|
Util.AddOnceClick(self.Mask, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddOnceClick(self.closeBtn, function()
|
|
self:ClosePanel()
|
|
end)
|
|
end
|
|
--context = {type}
|
|
function QuickPurchasePanel:OnOpen(context)
|
|
self.title.text = Language[11668]
|
|
self.help:SetActive(false)
|
|
if context.type == UpViewRechargeType.Energy or
|
|
-- context.type == UpViewRechargeType.Gold or
|
|
context.type == UpViewRechargeType.ChallengeTicket or
|
|
context.type == UpViewRechargeType.EliteCarbonTicket or
|
|
context.type == UpViewRechargeType.DemonCrystal or
|
|
context.type == UpViewRechargeType.LightRing or
|
|
context.type == UpViewRechargeType.ActPower or
|
|
context.type == UpViewRechargeType.AdventureAlianInvasionTicket or
|
|
context.type == UpViewRechargeType.ChangeNameCard or
|
|
context.type == UpViewRechargeType.MonsterCampTicket or
|
|
context.type == UpViewRechargeType.HourGlass or
|
|
context.type == UpViewRechargeType.XingYao or
|
|
context.type == UpViewRechargeType.DingKunShenChu or
|
|
context.type == UpViewRechargeType.yuxulundaoTicket
|
|
then
|
|
self.commonPurchase:OnShow(context)
|
|
elseif context.type == UpViewRechargeType.SpiritTicket or
|
|
context.type == UpViewRechargeType.GhostRing or
|
|
context.type == UpViewRechargeType.ElementDrawCardTicket
|
|
then
|
|
self.specialPurchase:OnShow(context)
|
|
elseif context.type==UpViewRechargeType.Gold then
|
|
self.coinPurchase:OnShow(context)
|
|
self.title.text = Language[11669]
|
|
self.help:SetActive(true)
|
|
end
|
|
end
|
|
|
|
function QuickPurchasePanel:OnClose()
|
|
self.commonPurchase:OnHide()
|
|
self.specialPurchase:OnHide()
|
|
self.coinPurchase:OnHide()
|
|
end
|
|
|
|
function QuickPurchasePanel:GetRemainBuyTimes(Id)
|
|
local limitBuyTimes = ShopManager.GetShopItemLimitBuyCount(Id)
|
|
if limitBuyTimes == -1 then
|
|
return math.huge
|
|
else
|
|
local hadBuyTimes = ShopManager.GetShopItemHadBuyTimes(SHOP_TYPE.FUNCTION_SHOP, Id)
|
|
return limitBuyTimes - hadBuyTimes
|
|
end
|
|
end
|
|
|
|
function QuickPurchasePanel:GetConfigData(Id)
|
|
local storeConfig = ConfigManager.GetConfigData(ConfigName.StoreConfig, Id)
|
|
assert(storeConfig, string.format("ConfigName.StoreConfig not find Id:%s", Id))
|
|
return storeConfig
|
|
end
|
|
|
|
function QuickPurchasePanel:GetCostTextColor(flag)
|
|
return flag and ColorDef[1] or ColorDef[2]
|
|
end
|
|
|
|
return QuickPurchasePanel |