KLCommonGainItemShowPanel.lua 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ---@class KLCommonGainItemShowPanel:UIKmlLuaPanelBase
  2. ---@field view KLCommonGainItemShowPanelView
  3. local KLCommonGainItemShowPanel = class(UIKmlLuaPanelBase)
  4. local this = KLCommonGainItemShowPanel
  5. function this:AsyncLoadUI()
  6. end
  7. ---创建时调用一次
  8. function this:Init()
  9. self.closeTime = 3
  10. GUI:DataListInitData(self.view.rewards, function()
  11. return table.count(self.info)
  12. end, function(realIndex)
  13. return self:DataListItemGetFunc(realIndex)
  14. end, function(realIndex, kmlcontrol)
  15. return self:DataListItemInitFunc(realIndex, kmlcontrol)
  16. end, function(realIndex, kmlcontrol)
  17. return self:DataListItemUpdateFunc(realIndex, kmlcontrol)
  18. end)
  19. end
  20. ---创建或者刷新界面数据时调用
  21. function this:Refresh()
  22. if self.args and self.args.reward then
  23. self.info = self.args.reward
  24. if table.count(self.info) > 6 then
  25. local h= math.ceil(table.count(self.info)/6) * 70 + math.floor(table.count(self.info)/6) * 10
  26. GUI:setContentSize(self.view.scrollviewList,900,h)
  27. end
  28. if self.args.str then
  29. GUI:Text_setString(self.view.showTxt, self.args.str)
  30. else
  31. GUI:Text_setString(self.view.showTxt, "")
  32. end
  33. GUI:DataListUpdateData(self.view.rewards)
  34. --到达时间后关闭
  35. self.timer=SL:Schedule(self.timer,self.closeTime, 1,1,function()
  36. self:ClosePanel()
  37. end)
  38. end
  39. end
  40. function this:DataListItemGetFunc(realIndex)
  41. end
  42. function this:DataListItemInitFunc(realIndex, kmlcontrol)
  43. end
  44. function this:DataListItemUpdateFunc(realIndex, kmlcontrol)
  45. local data = self.info[realIndex + 1]
  46. local item = GUI:GetChildControl(self.view.rewards, realIndex, 'item')
  47. local count = data.count
  48. if type(data.count) == "number" then
  49. count = math.floor(data.count)
  50. end
  51. GUI:Item_UpdataData(item, {
  52. itemid = data.cfgId,
  53. itemcustomcount = count,
  54. })
  55. GUI:AddOnClickEvent(item, self, function()
  56. SL:OpenTips("", tonumber(data.cfgId))
  57. end)
  58. end
  59. ---注册UI事件和服务器消息
  60. function this:RegistEvents()
  61. GUI:AddOnClickEvent(self.view.CloseBG, self, self.ClosePanel)
  62. end
  63. function this:ClosePanel()
  64. GUI:UIPanel_Close("dev/outui/OperateActivity/Panel/KLCommonGainItemShow/KLCommonGainItemShowPanel")
  65. end
  66. function this:SetTitle(type, atlas, src)
  67. if atlas ~= nil and src ~= nil then
  68. GUI:Image_loadTexture(self.view.title, src, atlas)
  69. elseif type == 0 then
  70. GUI:Image_loadTexture(self.view.title, "title_Reward", "Atlas/UIMisc.spriteatlas")
  71. else
  72. GUI:Image_loadTexture(self.view.title, "title_TaskReward", "Atlas/UIMisc.spriteatlas")
  73. end
  74. end
  75. function this:Close()
  76. if self.timer then
  77. SL:UnSchedule(self.timer)
  78. end
  79. self.timer = nil
  80. self.info = {}
  81. end
  82. return this