KLUIMonthGainItemTipsPanel.lua 2.7 KB

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