KLShapeShiftCardShopItem.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ---@class KLShapeShiftCardShopItem:UIKmlLuaPanelBase
  2. ---@field view KLShapeShiftCardShopItemView
  3. local KLShapeShiftCardShopItem = class(UIKmlLuaPanelBase)
  4. local this = KLShapeShiftCardShopItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---注册UI事件和服务器消息
  9. function this:RegistEvents()
  10. GUI:AddOnClickEvent(self.view.img_item_click, self, self.ItemOnClick)
  11. end
  12. ---界面显示时调用一次
  13. function this:Show()
  14. end
  15. ---创建或者刷新界面数据时调用
  16. function this:Refresh()
  17. end
  18. ---@param data cfg_card_shop_column
  19. function this:RefreshUI(data)
  20. self.noBuy = false
  21. local redPointShow = false
  22. if data.condition == 0 then
  23. GUI:setVisible(self.view.item_tips, false)
  24. else
  25. if data.condition > SL:GetMetaValue(EMetaVarGetKey.LEVEL) then
  26. GUI:setVisible(self.view.item_tips, true)
  27. GUI:Text_setString(self.view.item_tips, "角色Lv." .. data.condition .. "后开启")
  28. self.noBuy = true
  29. else
  30. GUI:setVisible(self.view.item_tips, false)
  31. redPointShow = true
  32. end
  33. end
  34. self.consumeId = data.exchangeConsume[1]
  35. self.consumeCost = data.exchangeConsume[2]
  36. if SL:GetBagItemCount(self.consumeId) < self.consumeCost then
  37. GUI:Text_setString(self.view.text_cost, "<color=#FF2323>" .. self.consumeCost .. "</color>")
  38. if redPointShow then
  39. redPointShow = false
  40. end
  41. else
  42. GUI:Text_setString(self.view.text_cost, "<color=#E6E600>" .. self.consumeCost .. "</color>")
  43. end
  44. ---@type cfg_item_column
  45. local item_tbl = SL:GetConfig("cfg_item", data.exchangeAdd[1])
  46. GUI:Text_setString(self.view.text_name, item_tbl.name)
  47. GUI:Text_setTextColor(self.view.text_name, tostring(item_tbl.color))
  48. GUI:Item_setItemId(self.view.item_cost, self.consumeId)
  49. GUI:Item_setItemId(self.view.item_is, data.exchangeAdd[1])
  50. GUI:setVisible(self.view.item_equip_redPoint, redPointShow)
  51. self.itemData = data
  52. end
  53. function this:ItemOnClick()
  54. if self.noBuy then
  55. SL:TipMessage(SL:GetConfig('cfg_string', 449).text, 1, NoticeType.NoticeMid)--"等级不足",
  56. return
  57. end
  58. GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardBuy/KLShapeShiftCardBuyPanel", nil, nil, self.itemData, true)
  59. end
  60. function this:Close()
  61. end
  62. return this