KLLuckyTurnTableItem.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. ---@class KLLuckyTurnTableItem:UIKmlLuaPanelBase
  2. ---@field view KLLuckyTurnTableItemView
  3. local KLLuckyTurnTableItem = class(UIKmlLuaPanelBase)
  4. local this = KLLuckyTurnTableItem
  5. ---创建时调用一次
  6. function this:Init()
  7. self.reward = nil
  8. end
  9. ---注册UI事件和服务器消息
  10. function this:RegistEvents()
  11. end
  12. ---界面显示时调用一次
  13. function this:Show()
  14. end
  15. ---创建或者刷新界面数据时调用
  16. function this:Refresh()
  17. end
  18. function this:SetBgGrey(value)
  19. GUI:Image_setGrey(self.view.BG, value)
  20. end
  21. function this:SetReTimes()
  22. if self.data.num == 999999 then
  23. return
  24. end
  25. if self.reCount - 1 < 0 then
  26. return
  27. end
  28. self.reCount = self.reCount - 1
  29. if self.reCount > 0 then
  30. GUI:Text_setString(self.view.reTimes, "剩余"..tostring(self.reCount).."份")
  31. self:SetBgGrey(false)
  32. else
  33. GUI:Text_setString(self.view.reTimes, "")
  34. self:SetBgGrey(true)
  35. end
  36. end
  37. function this:InitCount(countData)
  38. self.reCount = countData
  39. if self.reCount > 0 and self.data.num ~= 999999 then
  40. GUI:Text_setString(self.view.reTimes,"剩余"..tostring(self.reCount).."份")
  41. self:SetBgGrey(false)
  42. elseif self.data.num ~= 999999 then
  43. GUI:Text_setString(self.view.reTimes, "")
  44. self:SetBgGrey(true)
  45. else
  46. GUI:Text_setString(self.view.reTimes, "")
  47. end
  48. end
  49. function this:UpDataUI(data)
  50. self.data = data
  51. self.careerId = SL:GetMetaValue(EMetaVarGetKey.JOB)
  52. GUI:SetActive(self.view.Selected, false)
  53. GUI:Text_setString(self.view.Count, "")
  54. if self.data.type == 2 then
  55. GUI:SetActive(self.view.Flag, true)
  56. GUI:Image_loadTexture(self.view.BG, "bg_xiyou", "Atlas/QJ5_UITreasureHunt.spriteatlas")
  57. GUI:Image_loadTexture(self.view.Flag, "img_xiyou", "Atlas/QJ5_UITreasureHunt.spriteatlas")
  58. elseif self.data.type == 1 then
  59. GUI:SetActive(self.view.Flag, true)
  60. GUI:Image_loadTexture(self.view.BG, "bg_jipin", "Atlas/QJ5_UITreasureHunt.spriteatlas")
  61. GUI:Image_loadTexture(self.view.Flag, "img_jipin", "Atlas/QJ5_UITreasureHunt.spriteatlas")
  62. else
  63. GUI:SetActive(self.view.Flag, false)
  64. GUI:Image_loadTexture(self.view.BG, "bg_putong", "Atlas/QJ5_UITreasureHunt.spriteatlas")
  65. end
  66. for i, v in pairs(self.data.item) do
  67. if v[1] == self.careerId then
  68. self:ShowCoustIcon(v)
  69. GUI:Text_setString(self.view.Count, tostring(v[3]))
  70. return
  71. end
  72. end
  73. end
  74. ---@param v table @例:{1,800502016,1}
  75. function this:ShowCoustIcon(v)
  76. local data = {
  77. itemid = v[2],
  78. mfixsize = "74,74",
  79. tips = "1",
  80. width = "74",
  81. height = "74",
  82. bgtype = "0"
  83. }
  84. if self.ItemList then
  85. GUI:Item_UpdataData(self.ItemList, data)
  86. else
  87. self.ItemList = GUI:Item_Create(self.view.Point, data)
  88. end
  89. GUI:AddOnClickEvent(self.ItemList, self, function()
  90. SL:OpenTips(nil, data.itemid)
  91. end)
  92. end
  93. function this:ShowSelect()
  94. GUI:SetActive(self.view.Selected, true)
  95. end
  96. function this:HideSelect()
  97. GUI:SetActive(self.view.Selected, false)
  98. end
  99. function this:Hide()
  100. end
  101. function this:Close()
  102. self.ItemList = nil
  103. end
  104. return this