123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- ---@class KLOpenServerAthleticsGiftItem:UIKmlLuaPanelBase
- ---@field view KLOpenServerAthleticsGiftItemView
- local KLOpenServerAthleticsGiftItem = class(UIKmlLuaPanelBase)
- local this = KLOpenServerAthleticsGiftItem
- ---创建时调用一次
- function this:Init()
- self.ItemList = {}
- self.ShowDataGiftTbl = nil
- self.luaIndex = nil
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.buyButton, self, self.buyButtonOnClick)
- end
- function this:buyButtonOnClick()
- if self.ShowDataGiftTbl and self.luaIndex then
- local buycount, totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(self.ShowDataGiftTbl[self.luaIndex].count)
- if buycount <= 0 then
- SL:TipMessage(SL:GetConfig('cfg_string', 26).text, 1, NoticeType.NoticeMid)--"次数不足",
- return
- end
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_BUY_DISCOUNTS_GIFT, { id = self.ShowDataGiftTbl[self.luaIndex].id })
- end
- end
- ---界面显示时调用一次
- function this:Show()
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- end
- function this:UpdateUI(luaIndex, ShowDataGiftTbl)
- GUI:SetActive(self.view.Red, false)
- self.ShowDataGiftTbl = ShowDataGiftTbl
- self.luaIndex = luaIndex
- local len = 0
- if ShowDataGiftTbl and ShowDataGiftTbl[luaIndex] then
- for i, v in pairs(ShowDataGiftTbl[luaIndex].reward) do
- local itemId = v[1]
- local count = v[2]
- local data = {
- width = "70",
- height = "70",
- itemid = itemId,
- mfixsize = "70,70",
- tips = "1",
- itemcustomcount = count
- }
- if self.ItemList[i] then
- GUI:Item_UpdataData(self.ItemList[i], data)
- else
- self.ItemList[i] = GUI:Item_Create(self.view.gridview85, data)
- end
- GUI:SetActive(self.ItemList[i], true)
- GUI:AddOnClickEvent(self.ItemList[i], self, function()
- SL:OpenTips(nil, itemId)
- end)
- len = len + 1
- end
- for i, v in pairs(self.ItemList) do
- if i > len then
- GUI:SetActive(v, false)
- end
- end
- GUI:Text_setString(self.view.giftCost, ShowDataGiftTbl[luaIndex].name)
- if ShowDataGiftTbl[luaIndex].buyConsume[2] == 0 then
- GUI:SetActive(self.view.giftzuanshi, false)
- GUI:SetActive(self.view.Red, true)
- GUI:Text_setString(self.view.GiftBtnText, "<color=#ffffff>" .. "免费" .. "</color>")
- else
- if ShowDataGiftTbl[luaIndex].buyConsume[1] == 10050001 then
- GUI:Image_loadTexture(self.view.giftzuanshi,"img_bag_05","Atlas/QJ5_OpenServerAthleticsPanel.spriteatlas")
- else
- GUI:Image_loadTexture(self.view.giftzuanshi,"img_bag_04","Atlas/QJ5_OpenServerAthleticsPanel.spriteatlas")
- end
- GUI:SetActive(self.view.giftzuanshi, true)
- GUI:Text_setString(self.view.GiftBtnText, "<color=#ffffff>" .. tostring(ShowDataGiftTbl[luaIndex].buyConsume[2]) .. "</color>")
- end
- local buycount, totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(ShowDataGiftTbl[luaIndex].count)
- local parseTbl = SL:GetConfig("Count_count", ShowDataGiftTbl[luaIndex].count)
- if parseTbl.type == 1 then
- ---1:永久限购
- ---2:每月限购(1号0点)
- ---3:每周限购(周一0点)
- ---4:每日限购(每日0点)
- GUI:Text_setString(self.view.remainCount, "限购:" .. buycount .. "/" .. totalcount)
- elseif parseTbl.type == 2 then
- GUI:Text_setString(self.view.remainCount, "每月限购:" .. buycount .. "/" .. totalcount)
- elseif parseTbl.type == 3 then
- GUI:Text_setString(self.view.remainCount, "每周限购:" .. buycount .. "/" .. totalcount)
- elseif parseTbl.type == 4 then
- GUI:Text_setString(self.view.remainCount, "每日限购:" .. buycount .. "/" .. totalcount)
- end
- if buycount <= 0 then
- GUI:SetActive(self.view.giftzuanshi, false)
- GUI:SetActive(self.view.buyButton, false)
- GUI:Text_setString(self.view.GiftBtnText, "<color=#fe5047>" .. "已售罄" .. "</color>")
- else
- GUI:SetActive(self.view.buyButton, true)
- end
- end
- end
- function this:Close()
- self.ItemList = {}
- self.ShowDataGiftTbl = nil
- self.luaIndex = nil
- end
- return this
|