KLItemGetPathItem.lua 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ---@class KLItemGetPathItem:UIKmlLuaPanelBase
  2. ---@field view KLItemGetPathItemView
  3. local KLItemGetPathItem = class(UIKmlLuaPanelBase)
  4. local this =KLItemGetPathItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. function this:InitData(data)
  9. ---1:快捷购买类型#货币id#价格#图标文件名
  10. ---2:界面跳转类型#图标文件名#界面显示名称#脚本命令
  11. ---@type {itemCfg:cfg_item_column,quickshopping:string[],callBack:function,ui:UIKmlLuaPanelBase}
  12. self.data = data
  13. if self.data then
  14. if self.data.quickshopping[1] == "1" then
  15. local type = self.data.quickshopping[1]
  16. local needCostId = self.data.quickshopping[2]
  17. local cost = self.data.quickshopping[3]
  18. local item = SL:GetConfig("cfg_item",tonumber(needCostId))
  19. GUI:Text_setString(self.view.buyBtn, "购买")
  20. GUI:Text_setString(self.view.costCount, cost)
  21. GUI:Text_setString(self.view.costItemName, item.name)
  22. local colorCfg = SL:GetConfig("cfg_color",tonumber(item.color))
  23. GUI:Text_setTextColor(self.view.costItemName, colorCfg.color)
  24. GUI:setVisible(self.view.gainTxt, false)
  25. local item = GUI:Item_Create(self.view.itemModel, {
  26. width = "60",
  27. height = "60",
  28. itemid = self.data.itemCfg.id,
  29. mfixsize = "80,80"
  30. })
  31. local item = GUI:Item_Create(self.view.costModel, {
  32. width = "40",
  33. height = "40",
  34. itemid = needCostId,
  35. mfixsize = "40,40",
  36. bgtype = 0,
  37. })
  38. else
  39. GUI:Text_setString(self.view.gainTxt, self.data.quickshopping[3])
  40. GUI:Text_setString(self.view.buyBtn, "前往")
  41. GUI:setVisible(self.view.costCount, false)
  42. GUI:setVisible(self.view.costItemName, false)
  43. GUI:setVisible(self.view.costModel, false)
  44. GUI:setVisible(self.view.itemModel, false)
  45. end
  46. end
  47. end
  48. ---创建或者刷新界面数据时调用
  49. function this:Refresh()
  50. local pos = GUI:GetAnchoredPosition(self.view.gainTxt)
  51. SL:Log("获取途径-pos:".. pos.x .. "," .. pos.y)
  52. end
  53. ---注册UI事件和服务器消息
  54. function this:RegistEvents()
  55. GUI:AddOnClickEvent(self.view.buyBtn,self,self.BtnOnClick)
  56. end
  57. function this:BtnOnClick()
  58. if self.data.quickshopping[1] == "1" then
  59. local needCostId = tonumber(self.data.quickshopping[2])
  60. local costCount = tonumber(self.data.quickshopping[3])
  61. local ownCount = SL:GetBagItemCount(needCostId)
  62. local result = SL:ShortcutDO({"buyGoods",needCostId,costCount,self.data.itemCfg.id})
  63. if not result then
  64. return
  65. end
  66. --GUI:UIPanel_Close('dev/ui/Common/Panel/KLItemGetPath/KLItemGetPathPanel')
  67. else
  68. GUI:CloseAllUIWithoutMainUI()
  69. local tempShortcut = {self.data.quickshopping[4],self.data.quickshopping[5],self.data.quickshopping[6],self.data.quickshopping[7]}
  70. if self.data.ui then
  71. GUI:UIPanel_Close(nil,self.data.ui)
  72. end
  73. GUI:UIPanel_Close('dev/ui/Common/Panel/KLItemGetPath/KLItemGetPathPanel')
  74. SL:ShortcutDO(tempShortcut)
  75. SL:CloseTips()
  76. end
  77. if self.data.callBack then
  78. self.data.callBack()
  79. end
  80. end
  81. function this:Close()
  82. end
  83. return this