UIWeekPackRechargeInfo.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. --- Generated by EmmyLua(https://github.com/EmmyLua)
  2. --- Created by admin.
  3. --- DateTime: 2024/11/7 10:08
  4. ---@class UIWeekPackRechargeInfo
  5. UIWeekPackRechargeInfo = class()
  6. local this = UIWeekPackRechargeInfo
  7. function this:ctor()
  8. end
  9. function this:Reset()
  10. end
  11. function this:Init()
  12. self:InitData()
  13. self:RegistMessages()
  14. self.WeekPackAllData = SL:GetConfigTable("cfg_WeeklyGiftPack")
  15. self.WeekPackData = {}
  16. end
  17. function this:InitData()
  18. end
  19. function this:RegistMessages()
  20. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_ACTION, self.RES_RECHARGE_ACTION, self)
  21. SL:RegisterLUAEvent(LUA_EVENT_WEEKPACK_RECHARGE_COUNT_CHANGE, this.LUA_EVENT_WEEKPACK_RECHARGE_COUNT_CHANGE, self)
  22. end
  23. --服务器发送礼包组消息后刷新礼包组的数据
  24. function this:RES_RECHARGE_ACTION(_, message)
  25. if tonumber(message.type)~=6 then --类型6
  26. return
  27. end
  28. self.WeekPackData = {}
  29. if message then
  30. local itemInfo = {}
  31. local itemCountInfo = {}
  32. local buycount = 0 --剩余次数
  33. local totalcount = 0
  34. for k , v in ipairs(self.WeekPackAllData) do
  35. if v.Packagetype == tonumber(message.data.group) and this:IsOpenJudge(v.conditionid)then
  36. itemInfo = {}
  37. itemInfo.id = v.id
  38. itemInfo.Price = v.Price
  39. itemInfo.Packagename= v.Packagename
  40. itemInfo.Packagetype = v.Packagetype
  41. itemInfo.conditionid = v.conditionid
  42. itemInfo.Limited =tonumber(v.Limited)
  43. itemInfo.Rewards = v.Rewards
  44. itemInfo.rebate = v.rebate
  45. itemInfo.canBuy = true
  46. itemInfo.RechargeId = 0
  47. itemInfo.Countkey = 0
  48. buycount = 0
  49. totalcount = 0
  50. for key,value in pairs(message.data.recharge_ids) do
  51. itemCountInfo = SL:GetConfig('cfg_recharge',tonumber(value))
  52. if itemCountInfo.parameter == v.id then
  53. itemInfo.RechargeId = tonumber(value)
  54. itemInfo.Countkey = itemCountInfo.Countkey
  55. buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(itemCountInfo.Countkey)
  56. if buycount < 1 then
  57. itemInfo.canBuy = false
  58. end
  59. break
  60. end
  61. end
  62. table.insert(self.WeekPackData,itemInfo)
  63. end
  64. end
  65. end
  66. local isDailyPackRedPoint = false
  67. for k,v in pairs(self.WeekPackData) do
  68. if v.Price== 0 and v.canBuy then
  69. isDailyPackRedPoint = true
  70. end
  71. end
  72. InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_WeekDailyPack",isDailyPackRedPoint)
  73. SL:onLUAEvent(LUA_EVENT_WEEKPACK_RECHARGE_CHANGE)
  74. end
  75. --Count刷新
  76. function this:LUA_EVENT_WEEKPACK_RECHARGE_COUNT_CHANGE()
  77. local isDailyPackRedPoint = false
  78. local buycount = 0 --剩余次数
  79. local totalcount = 0
  80. for k,v in pairs(self.WeekPackData) do
  81. buycount = 0
  82. totalcount = 0
  83. v.canBuy = true
  84. buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(v.Countkey)
  85. if buycount < 1 then
  86. v.canBuy = false
  87. end
  88. if v.Price== 0 and v.canBuy then
  89. isDailyPackRedPoint = true
  90. end
  91. end
  92. InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_WeekDailyPack",isDailyPackRedPoint)
  93. SL:onLUAEvent(LUA_EVENT_WEEKPACK_RECHARGE_CHANGE)
  94. end
  95. function this:IsOpenJudge(condition)
  96. local isShow = condition == "" or ConditionManager.Check4D(condition)
  97. ---if else 可特殊处理页签显示隐藏
  98. return isShow
  99. end