源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.7 KiB

  1. LimitGiftModel = LimitGiftModel or BaseClass(BaseVo, true)
  2. local LimitGiftModel = LimitGiftModel
  3. LimitGiftModel.REQUEST_INFO = "LimitGiftModel.REQUEST_INFO"
  4. LimitGiftModel.OPEN_LIMIT_GIFT_VIEW = "LimitGiftModel.OPEN_LIMIT_GIFT_VIEW"--打开主界面
  5. LimitGiftModel.UPDATE_LIMIT_GIFT_VIEW = "LimitGiftModel.UPDATE_LIMIT_GIFT_VIEW"--更新主界面
  6. LimitGiftModel.REQUEST_INFO = "LimitGiftModel.REQUEST_INFO"--请求协议
  7. LimitGiftModel.SubID = {
  8. RUNE = 1,--御魂
  9. Peak = 2,
  10. Extreme = 3,
  11. Rune = 4,
  12. }
  13. function LimitGiftModel:__init()
  14. LimitGiftModel.Instance = self
  15. self.login_red = {}--登陆红点
  16. self:Reset()
  17. end
  18. function LimitGiftModel:Reset()
  19. self.view_info = {}--界面信息
  20. end
  21. function LimitGiftModel:getInstance()
  22. if LimitGiftModel.Instance == nil then
  23. LimitGiftModel.Instance = LimitGiftModel.New()
  24. end
  25. return LimitGiftModel.Instance
  26. end
  27. function LimitGiftModel:CheckMainIconRedDot()
  28. local show = false
  29. if self.login_red then
  30. show = true
  31. else
  32. for k,v in pairs(self.red_dot_info) do
  33. if v == true then
  34. show = v
  35. break
  36. end
  37. end
  38. end
  39. GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 331003, show)
  40. end
  41. --检查限购礼包红点
  42. function LimitGiftModel:CheckLimitGiftRedDot( )
  43. return self.red_dot_info
  44. end
  45. --检测限购礼包活动图标是否需要开启[兼顾设置限购礼包活动内部的活动列表]
  46. function LimitGiftModel:CheckIconBoolOpen()
  47. self.act_base_list = {} --限购礼包活动内部的活动列表
  48. local all_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.LIMIT_GIFT) or {}
  49. all_list = DeepCopy(all_list)
  50. local server_time = TimeUtil:getServerTime()
  51. local my_level = RoleManager.Instance.mainRoleInfo.level
  52. self.red_dot_info = {}--红点信息
  53. for k,v in pairs(all_list) do
  54. local open_level = Config.Modulesub["331@3"].open_lv or 1
  55. for l,w in pairs(v.condition_list) do
  56. if type(w) == "table" and w[1] == "role_lv" then
  57. open_level = tonumber(w[2])
  58. end
  59. end
  60. if server_time > v.stime and v.etime > server_time then
  61. if my_level >= open_level and GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.LIMIT_GIFT) then
  62. v.sort_index = v.sub_type or 999
  63. self.red_dot_info[v.sub_type] = v.is_first_open == 1
  64. if not self.red_dot_info[v.sub_type] then
  65. local award_data = CustomActivityModel:getInstance():getOneActRewardList(v.base_type,v.sub_type)
  66. if award_data then
  67. for ii,vv in pairs(award_data.reward_list) do
  68. local conditon = vv.condition_list
  69. if conditon and not self.red_dot_info[v.sub_type] then
  70. local cur_price = nil
  71. for iii,vvv in ipairs(conditon) do
  72. if vvv[1] == "limit_cost" then
  73. cur_price = tonumber(vvv[2])
  74. break
  75. end
  76. end
  77. self.red_dot_info[v.sub_type] = vv.status == 1 and cur_price == 0
  78. end
  79. end
  80. end
  81. end
  82. table.insert(self.act_base_list, v)
  83. end
  84. end
  85. end
  86. if self.login_red == nil then
  87. for k,v in pairs(all_list) do
  88. local award_data = CustomActivityModel:getInstance():getOneActRewardList(v.base_type,v.sub_type)
  89. if award_data and award_data.reward_list then
  90. for ii,vv in pairs(award_data.reward_list) do
  91. if not self.login_red then
  92. self.login_red = vv.status ~= 2
  93. elseif self.login_red then
  94. break
  95. end
  96. end
  97. end
  98. end
  99. end
  100. --排序
  101. local function sort_func(a, b)
  102. return a.sort_index < b.sort_index
  103. end
  104. table.sort(self.act_base_list, sort_func)
  105. -- if #self.act_base_list > 0 then
  106. -- ActivityIconManager:getInstance():addIcon(331003, -1)
  107. -- else
  108. -- ActivityIconManager:getInstance():deleteIcon(331003)
  109. -- end
  110. -- self:CheckMainIconRedDot()
  111. self:Fire(LimitGiftModel.UPDATE_LIMIT_GIFT_VIEW)
  112. end
  113. --获得活动信息列表
  114. function LimitGiftModel:GetTabInfo( )
  115. self.act_base_list = {} --限购礼包活动内部的活动列表
  116. local all_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.LIMIT_GIFT) or {}
  117. all_list = DeepCopy(all_list)
  118. -- print("huangcong:LimitGiftModel [start:92] :", TableSize(all_list))
  119. -- PrintTable(all_list)
  120. local server_time = TimeUtil:getServerTime()
  121. local my_level = RoleManager.Instance.mainRoleInfo.level
  122. for k,v in pairs(all_list) do
  123. local open_level = Config.Modulesub["331@3"].open_lv or 1
  124. for l,w in pairs(v.condition_list) do
  125. if type(w) == "table" and w[1] == "role_lv" then
  126. open_level = tonumber(w[2])
  127. end
  128. end
  129. if server_time > v.stime and v.etime > server_time then
  130. if my_level >= open_level and GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.LIMIT_GIFT) then
  131. v.sort_index = v.sub_type or 999
  132. table.insert(self.act_base_list, v)
  133. end
  134. end
  135. end
  136. return self.act_base_list
  137. end