| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- local UIShopGoldBuyTips = class("UIShopGoldBuyTips")
- local exchangeIconKey = 310
- local exchangeCostKey = 308
- local exchangeRewardKey = 309
- local exchangeIcon
- local exchangeCosts
- local exchangeRewards
- function UIShopGoldBuyTips:ctor()
- end
- function UIShopGoldBuyTips:InitGo(host,uiGo)
- self.host = host
- self.viewLua = CommonUtil.BindGridViewItem2Lua(self.host, "UIShopGoldBuyTips", uiGo)
-
- self:InitPanel()
- end
- function UIShopGoldBuyTips:InitPanel()
- exchangeIcon = GlobalConfig.Instance:GetConfigStrValue(exchangeIconKey)
- local val = GlobalConfig.Instance:GetConfigStrValue(exchangeCostKey)
- if val ~= "" and val ~= nil then
- exchangeCosts = CommonUtil.DeserializeGlobalStrToTable(val)
- end
- local val = GlobalConfig.Instance:GetConfigStrValue(exchangeRewardKey)
- if val ~= "" and val ~= nil then
- exchangeRewards = CommonUtil.DeserializeGlobalStrToTable(val)
- end
- end
- function UIShopGoldBuyTips:AddEventListener()
- end
- function UIShopGoldBuyTips:RemoveEventListener()
- end
- function UIShopGoldBuyTips:AddUIEventListener()
- self.host.uiBase:AddButtonUniqueEventListener(self.viewLua.btnClose.button, self, self.OnClickCloseBtn)
- self.host.uiBase:AddButtonUniqueEventListener(self.viewLua.AnyBtn.button, self, self.OnClickCloseBtn)
- self.host.uiBase:AddButtonUniqueEventListener(self.viewLua.btnBuy.button, self, self.OnClickBuyBtn)
- end
- function UIShopGoldBuyTips:Show()
- self:AddEventListener()
- if not exchangeCosts then
- self.viewLua.textTitle.text.text = ''
- self.viewLua.buyLimitTxt.text.text = ''
- self.viewLua.presentPrice.number.text.text = ''
- self.viewLua.image.image.enabled = false
- self.viewLua.image.image.sprite = nil
- return
- end
- if exchangeIcon then
- CommonUtil.LoadIcon(self, exchangeIcon, function(sprite)
- if sprite then
- self.viewLua.image.image.sprite = sprite
- self.viewLua.image.image.enabled = true
- end
- end)
- end
- local rewards = exchangeRewards
- local reward
- local contentStr = ""
- if rewards then
- for i = 1, #rewards do
- reward = rewards[i]
- local id = tonumber(reward[1])
- local num = tonumber(reward[2])
- contentStr = contentStr..'+' .. num
- local itemCfgData = ManagerContainer.CfgMgr:GetItemById(id)
- if itemCfgData then
- contentStr = contentStr .. tostring(itemCfgData.Name)
- end
- if i < #reward then
- contentStr = contentStr ..'\n'
- end
- end
- end
- self.viewLua.goldText.text.text = contentStr
- local price = 0
- if exchangeCosts and exchangeCosts[1] then
- price = tonumber(exchangeCosts[1][2])
- end
- if price <= 0 then
- self.viewLua.presentPrice.number.text.text = string.formatbykey('Free')
- else
- self.viewLua.presentPrice.number.text.text = tostring(price)
- end
- self.viewLua:SetActive(true)
- end
- function UIShopGoldBuyTips:OnClickCloseBtn()
- self:Hide()
- end
- function UIShopGoldBuyTips:OnClickBuyBtn()
- ManagerContainer.DataMgr.ShopDataMgr:SendRedBagExchangeReq()
- self:Hide()
- end
- function UIShopGoldBuyTips:Hide()
- self:RemoveEventListener()
- self.viewLua:SetActive(false)
- self:Clear()
- end
- function UIShopGoldBuyTips:Clear()
- end
- function UIShopGoldBuyTips:Dispose()
- self:Hide()
- self.host = nil
- self.viewLua = nil
- end
- return UIShopGoldBuyTips
|