miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_XiaoYaoYouItem...

87 lines
2.9 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.

----- 归元弹窗 -----
local this = {}
--传入父脚本模块
local parent
--层级
local sortingOrder = 0
--传入不定参
local _args = {}
local itemviews = {}
local itemId = 0
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
function this:InitComponent(gameObject)
this.titleText = Util.GetGameObject(gameObject, "TitleText"):GetComponent("Text")
this.bodyText = Util.GetGameObject(gameObject, "BodyText"):GetComponent("Text")
this.cancelBtn = Util.GetGameObject(gameObject, "CancelBtn")
this.confirmBtn = Util.GetGameObject(gameObject, "ConfirmBtn")
Util.GetGameObject(this.confirmBtn,"Text"):GetComponent("Text").text = "使用"
this.tipText = Util.GetGameObject(gameObject, "tipText"):GetComponent("Text")
this.addBtn = Util.GetGameObject(gameObject, "addBtn")
this.root = Util.GetGameObject(gameObject, "Root/Content")
end
function this:BindEvent()
Util.AddClick(this.cancelBtn,function()
parent:ClosePanel()
end)
Util.AddClick(this.confirmBtn,function()
local count = 1
if BagManager.GetItemCountById(itemId) > 0 then
ShopManager.RequestBuyShopItem(7, 10033, count, function()
PopupTipPanel.ShowTip("恢复50点云游值")
Timer.New(function()
LogGreen("BagManager.GetItemCountById(UpViewRechargeType.YunYouVle)--------------:"..BagManager.GetItemCountById(UpViewRechargeType.YunYouVle))
Game.GlobalEvent:DispatchEvent(GameEvent.XiaoYao.RefreshEventShow)
this:OnShow(parent,98)
end,1):Start()
end,0)
else
PopupTipPanel.ShowTip("云游宝玉不足")
end
end)
Util.AddClick(this.addBtn,function()
UIManager.OpenPanel(UIName.ShopBuyPopup, 7,10032)
end)
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.RefreshPanel)--监听背包信息改变刷新 用于回春散数量刷新
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.RefreshPanel)
end
function this.RefreshPanel()
this:OnShow(parent,98)
end
function this:OnShow(_parent,...)
parent=_parent
sortingOrder =_parent.sortingOrder
local args = {...}
itemId = args[1]
this.titleText.text=itemConfig[itemId].Name
this.bodyText.text = itemConfig[itemId].ItemDescribe
this.tipText.text = "剩余数量:"..BagManager.GetItemCountById(itemId)
for i,v in pairs(itemviews) do
v.gameObject:SetActive(false)
end
if not itemviews[1] then
itemviews[1] = SubUIManager.Open(SubUIConfig.ItemView,this.root.transform)
end
itemviews[1].gameObject:SetActive(true)
itemviews[1]:OnOpen(false,{itemId,0},1,false)
end
function this:OnClose()
end
function this:OnDestroy()
itemviews={}
end
return this