KLGainItemTipsPanel.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ---@class KLGainItemTipsPanel:UIKmlLuaPanelBase
  2. ---@field view KLGainItemTipsPanelView
  3. ---@field closeTime number @关闭时间
  4. local KLGainItemTipsPanel = class(UIKmlLuaPanelBase)
  5. local this = KLGainItemTipsPanel
  6. ---创建时调用一次
  7. function this:Init()
  8. self.closeTime = 3
  9. end
  10. ---创建或者刷新界面数据时调用
  11. function this:Refresh()
  12. self.closeTime = 3
  13. if not self.info then
  14. self.info = {}
  15. end
  16. local data2Message = {}
  17. for k, v in pairs(self.args) do
  18. if type(v) == "table" then
  19. data2Message[k] = {
  20. cfgId = v["cfgId"],
  21. count = SL:GetSimpleNumber(tonumber(v["count"]), 0),
  22. id = v.id,
  23. }
  24. else
  25. data2Message[#data2Message + 1] = {
  26. cfgId = k,
  27. count = SL:GetSimpleNumber(tonumber(v), 0),
  28. }
  29. end
  30. end
  31. for k, v in pairs(data2Message) do
  32. local tempTable = {
  33. cfgId = v.cfgId,
  34. count = v.count,
  35. id = v.id
  36. }
  37. table.insert(self.info, tempTable)
  38. end
  39. GUI:DataListInitData(self.view.rewards, function()
  40. return table.count(self.info)
  41. end, function(realIndex)
  42. return self:DataListItemGetFunc(realIndex)
  43. end, function(realIndex, kmlcontrol)
  44. return self:DataListItemInitFunc(realIndex, kmlcontrol)
  45. end, function(realIndex, kmlcontrol)
  46. return self:DataListItemUpdateFunc(realIndex, kmlcontrol)
  47. end)
  48. GUI:DataListUpdateData(self.view.rewards)
  49. --到达时间后关闭
  50. self.Schedule1 = SL:ScheduleOnce(self.closeTime,function()
  51. self:ClosePanle()
  52. end)
  53. end
  54. function this:DataListItemGetFunc(realIndex)
  55. end
  56. function this:DataListItemInitFunc(realIndex, kmlcontrol)
  57. end
  58. function this:DataListItemUpdateFunc(realIndex, kmlcontrol)
  59. local data = self.info[realIndex + 1]
  60. --local item = self.view.rewards:GetChildControl(realIndex, "item_")
  61. local item = GUI:GetChildControl(self.view.rewards, realIndex, "item_")
  62. local count = data.count
  63. if type(data.count) == "number" then
  64. count = math.floor(data.count)
  65. end
  66. local itemInfo = SL:GetPosItemInfo("bag", data.cfgId, data.id)
  67. if not itemInfo then
  68. itemInfo = SL:GetPosItemInfo("mail", data.cfgId, data.id)
  69. end
  70. GUI:Item_UpdataData(item, {
  71. itemid = data.cfgId,
  72. itemcustomcount = count,
  73. })
  74. GUI:AddOnClickEvent(item, self, function()
  75. SL:OpenTips("", tonumber(data.cfgId), tonumber(data.id), 0, itemInfo)
  76. end)
  77. end
  78. ---注册UI事件和服务器消息
  79. function this:RegistEvents()
  80. GUI:AddOnClickEvent(self.view.CloseBG,self,self.ClosePanle)
  81. end
  82. function this:ClosePanle()
  83. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLGainItemTips/KLGainItemTipsPanel")
  84. end
  85. function this:SetTitle(type,atlas,src)
  86. if atlas ~= nil and src ~= nil then
  87. GUI:Image_loadTexture(self.view.title,src,atlas)
  88. elseif type == 0 then
  89. GUI:Image_loadTexture(self.view.title,"title_Reward","Atlas/UIMisc.spriteatlas")
  90. else
  91. GUI:Image_loadTexture(self.view.title,"title_TaskReward","Atlas/UIMisc.spriteatlas")
  92. end
  93. GUI:SetActive(self.view.title,true)
  94. end
  95. function this:Close()
  96. if self.Schedule1 then
  97. SL:UnSchedule( self.Schedule1)
  98. self.Schedule1 = nil
  99. end
  100. self.info = {}
  101. end
  102. return this