KLTradeSalesItem.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ---@class KLTradeSalesItem:UIKmlLuaPanelBase
  2. ---@field view KLTradeSalesItemView
  3. ---@field goodsItem KLTradeGoodsItem
  4. ---@field goods boolean
  5. ---@field goodsInfo
  6. local KLTradeSalesItem = class(UIKmlLuaPanelBase)
  7. local this = KLTradeSalesItem
  8. ---创建时调用一次
  9. function this:Init()
  10. end
  11. ---注册UI事件和服务器消息
  12. function this:RegistEvents()
  13. end
  14. function this:UpdateUI(data)
  15. if table.count(data) > 0 then
  16. GUI:setVisible(self.view.null_panel, false)
  17. GUI:setVisible(self.view.have_panel, true)
  18. self.goods = true
  19. if not self.goodsItem then
  20. self.goodsItem = GUI:UIPanel_Open("dev/outui/Trade/Item/KLTradeGoods/KLTradeGoodsItem", self.view.have_panel, self, nil, true)
  21. end
  22. GUI:setContentSize(self.goodsItem.view.KLTradeGoodsItem,200,195)
  23. GUI:setContentSize(self.goodsItem.view.btn_goods_item, 200, 195)
  24. self.goodsInfo = data
  25. self.goodsItem:UpdateData(data)
  26. GUI:AddOnClickEvent(self.goodsItem.view.btn_goods_item, self, self.Click)
  27. self.tickTimer = SL:Schedule(self.tickTimer, 0, 1, -1, function()
  28. return self.goodsItem:Tick()
  29. end)
  30. end
  31. end
  32. function this:Remove()
  33. if self.tickTimer then
  34. SL:UnSchedule(self.tickTimer)
  35. self.tickTimer = nil
  36. end
  37. self.goods = false
  38. self.goodsInfo = {}
  39. GUI:setVisible(self.view.null_panel, true)
  40. GUI:setVisible(self.view.have_panel, false)
  41. end
  42. function this:IsGoods()
  43. return self.goods
  44. end
  45. function this:Click()
  46. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_TRADE_GOODS_INFO, {self.goodsInfo.itemid, self.goodsInfo.ownid })
  47. GUI:UIPanel_Open("dev/outui/Trade/Panel/KLTradeRemove/KLTradeRemovePanel", _, _, { cfgId = self.goodsInfo.itemcfgid, id = self.goodsInfo.itemid, type = self.goodsInfo.cointype, price = self.goodsInfo.unitPrice })
  48. end
  49. ---创建或者刷新界面数据时调用
  50. function this:Refresh()
  51. self.goods = false
  52. self.goodsItem = nil
  53. end
  54. function this:Close()
  55. if self.tickTimer then
  56. SL:UnSchedule(self.tickTimer)
  57. self.tickTimer = nil
  58. end
  59. if self.goodsItem then
  60. end
  61. self.goodsItem = GUI:UIPanel_Close("dev/outui/Trade/Item/KLTradeGoods/KLTradeGoodsItem", self.goodsItem)
  62. end
  63. return this