123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- ---@class KLTradeGoodsItem:UIKmlLuaPanelBase
- ---@field view KLTradeGoodsItemView
- local KLTradeGoodsItem = class(UIKmlLuaPanelBase)
- local this = KLTradeGoodsItem
- ---创建时调用一次
- function this:Init()
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.btn_goods_item, self, self.ItemOnClick)
- end
- function this:ItemOnClick()
- if self.clickFun then
- self.clickFun(self.buyUI, self)
- return
- end
- --SL:OpenTips(nil,self.itemData.itemcfgid)
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TRADE_GOODS_INFO, { self.itemData.itemid, self.itemData.ownid })
- GUI:UIPanel_Open("dev/outui/Trade/Panel/KLTradeBuy/KLTradeBuyPanel", nil, nil, self.itemData)
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- end
- ---@class KLTradeGoodsItemData
- ---@field timename string
- ---@field itemname string
- ---@field count number
- ---@field price number
- ---@field itemcfgid number
- ---@field cointype number
- ---@field time number
- ---@field preordercount number @预订数量
- ---@field publicity string 公示区时为1
- ---@field itemid number
- ---@field type number
- ---@field entrysize number 词条数量
- ---@param itemData KLTradeGoodsItemData
- function this:UpdateData(itemData)
- self.itemData = itemData
- GUI:SetOnPrefabControlLoaded(self.view.scroll_text_template, function()
- GUI:Text_setString(self.view.txt_item_name, itemData.itemname)
- end)
- GUI:Item_setItemId(self.view.item, itemData.itemcfgid)
- if itemData.itemcfgid == EMonthType.MonthCardTime then
- GUI:Item_UpdataData(self.view.item, { itemcount = 1 })
- GUI:SetActive(self.view.monthCardText, true)
- GUI:Text_setString(self.view.monthCardText, itemData.count .. "天")
- else
- GUI:SetActive(self.view.monthCardText, false)
- GUI:Item_UpdataData(self.view.item, { itemcount = itemData.count })
- end
- --GUI:Image_loadTexture(self.view.img_coin_type,self:GetCoinIcon(tonumber(itemData.cointype)),"Atlas/UIBagPanel.spriteatlas")
- local totalPrice = itemData.totalprice
- local ownCount = 0
- local unit = ""
- if itemData.cointype == "30030305" then
- ownCount = InfoManager.monthCardInfo:GetMonthCardDayTime()
- unit = "天"
- else
- ownCount = SL:GetBagItemCount(tonumber(itemData.cointype))
- end
- GUI:Text_setTextColor(self.view.txt_price, ownCount >= totalPrice and "#1ADD1F" or "#FF2323")
- GUI:Text_setString(self.view.txt_price, tostring(totalPrice) .. unit)
- GUI:Image_loadTexture(self.view.img_coin_type, tostring(itemData.cointype), "Atlas/UIBagPanel.spriteatlas")
- --GUI:Text_setString(self.view.txt_price, tostring(totalPrice))
- if itemData.publicity == 1 then
- GUI:SetActive(self.view.img_favor_count, true)
- local peroreder = table.count(itemData.peroreder)
- if peroreder >= 1 then
- GUI:Image_loadTexture(self.view.img_favor_count, "ty_ico_star", "Atlas/TS_Common.spriteatlas")
- GUI:Text_setString(self.view.txt_favor_count, tostring(peroreder))
- else
- GUI:Image_loadTexture(self.view.img_favor_count, "ty_ico_star_bg", "Atlas/TS_Common.spriteatlas")
- GUI:Text_setString(self.view.txt_favor_count, "")
- end
- else
- GUI:SetActive(self.view.img_favor_count, false)
- end
- local roleId = SL:GetMetaValue(EMetaVarGetKey.UID)
- if tostring(roleId) == itemData.ownid then
- GUI:setVisible(self.view.icon_career, true)
- local job = SL:GetMetaValue(EMetaVarGetKey.JOB)
- GUI:Image_loadTexture(self.view.icon_career, "1" .. tostring(job), "Atlas/MUIcon.spriteatlas")
- else
- GUI:setVisible(self.view.icon_career, false)
- end
- self:Tick()
- self:ShowQualityUI()
- self:UpdateBuyClickFun(nil, nil)
- end
- function this:UpdateBuyClickFun(clickFun, ui)
- self.clickFun = clickFun
- self.buyUI = ui
- end
- function this:ShowQualityUI()
- if self.qualityItem then
- self.qualityItem:SetData(self.itemData.itemcfgid, self.itemData.entrysize)
- else
- GUI:UIPanel_Open("dev/ui/Common/Item/KLEquipQualityEntry/KLEquipQualityEntryItem",
- self.view.root, self, { cfgId = self.itemData.itemcfgid, entryCount = self.itemData.entrysize }, true,
- function(qualityItem)
- self.qualityItem = qualityItem
- end)
- end
- end
- --[[
- function this:GetCoinIcon(coinType)
- if coinType == 10010001 then
- return "img_bag_01"
- elseif coinType == 10020001 then
- return "img_bag_02"
- elseif coinType == 10030001 then
- return "img_bag_03"
- elseif coinType == 10040001 then
- return "img_bag_04"
- end
- end
- ]]
- function this:Close()
- if self.qualityItem then
- GUI:UIPanel_Close(nil, self.qualityItem)
- self.qualityItem = nil
- end
- end
- function this:Tick()
- if not self.itemData or not self.itemData.time then
- return false
- end
- self.itemData.time = self.itemData.time - 1
- if self.itemData.time <= 0 then
- GUI:Text_setString(self.view.txt_count_down, "")
- return true
- else
- if self.itemData.time <= 3 * 60 * 60 or self.itemData.publicity == "1" then
- local timeInfo = SL:SecondToHMS(math.floor(self.itemData.time))
- local timeStr = string.format("%02s:%02s:%02s", timeInfo.h, timeInfo.m, timeInfo.s)
- GUI:Text_setString(self.view.txt_count_down, self.itemData.timename .. " " .. timeStr)
- else
- GUI:Text_setString(self.view.txt_count_down, "")
- end
- end
- end
- return this
|