|
|
- LimitGiftModel = LimitGiftModel or BaseClass(BaseVo, true)
- local LimitGiftModel = LimitGiftModel
-
- LimitGiftModel.REQUEST_INFO = "LimitGiftModel.REQUEST_INFO"
- LimitGiftModel.OPEN_LIMIT_GIFT_VIEW = "LimitGiftModel.OPEN_LIMIT_GIFT_VIEW"--打开主界面
- LimitGiftModel.UPDATE_LIMIT_GIFT_VIEW = "LimitGiftModel.UPDATE_LIMIT_GIFT_VIEW"--更新主界面
- LimitGiftModel.REQUEST_INFO = "LimitGiftModel.REQUEST_INFO"--请求协议
-
- LimitGiftModel.SubID = {
- RUNE = 1,--御魂
- Peak = 2,
- Extreme = 3,
- Rune = 4,
- }
-
- function LimitGiftModel:__init()
- LimitGiftModel.Instance = self
- self.login_red = {}--登陆红点
- self:Reset()
- end
-
- function LimitGiftModel:Reset()
- self.view_info = {}--界面信息
- end
-
- function LimitGiftModel:getInstance()
- if LimitGiftModel.Instance == nil then
- LimitGiftModel.Instance = LimitGiftModel.New()
- end
- return LimitGiftModel.Instance
- end
-
- function LimitGiftModel:CheckMainIconRedDot()
- local show = false
- if self.login_red then
- show = true
- else
- for k,v in pairs(self.red_dot_info) do
- if v == true then
- show = v
- break
- end
- end
- end
- GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 331003, show)
- end
-
- --检查限购礼包红点
- function LimitGiftModel:CheckLimitGiftRedDot( )
- return self.red_dot_info
- end
-
- --检测限购礼包活动图标是否需要开启[兼顾设置限购礼包活动内部的活动列表]
- function LimitGiftModel:CheckIconBoolOpen()
- self.act_base_list = {} --限购礼包活动内部的活动列表
- local all_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.LIMIT_GIFT) or {}
- all_list = DeepCopy(all_list)
- local server_time = TimeUtil:getServerTime()
- local my_level = RoleManager.Instance.mainRoleInfo.level
-
- self.red_dot_info = {}--红点信息
- for k,v in pairs(all_list) do
- local open_level = Config.Modulesub["331@3"].open_lv or 1
- for l,w in pairs(v.condition_list) do
- if type(w) == "table" and w[1] == "role_lv" then
- open_level = tonumber(w[2])
- end
- end
- if server_time > v.stime and v.etime > server_time then
- if my_level >= open_level and GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.LIMIT_GIFT) then
- v.sort_index = v.sub_type or 999
- self.red_dot_info[v.sub_type] = v.is_first_open == 1
- if not self.red_dot_info[v.sub_type] then
- local award_data = CustomActivityModel:getInstance():getOneActRewardList(v.base_type,v.sub_type)
- if award_data then
- for ii,vv in pairs(award_data.reward_list) do
- local conditon = vv.condition_list
- if conditon and not self.red_dot_info[v.sub_type] then
- local cur_price = nil
- for iii,vvv in ipairs(conditon) do
- if vvv[1] == "limit_cost" then
- cur_price = tonumber(vvv[2])
- break
- end
- end
- self.red_dot_info[v.sub_type] = vv.status == 1 and cur_price == 0
- end
- end
- end
- end
- table.insert(self.act_base_list, v)
- end
- end
- end
- if self.login_red == nil then
- for k,v in pairs(all_list) do
- local award_data = CustomActivityModel:getInstance():getOneActRewardList(v.base_type,v.sub_type)
- if award_data and award_data.reward_list then
- for ii,vv in pairs(award_data.reward_list) do
- if not self.login_red then
- self.login_red = vv.status ~= 2
- elseif self.login_red then
- break
- end
- end
- end
- end
- end
-
- --排序
- local function sort_func(a, b)
- return a.sort_index < b.sort_index
- end
- table.sort(self.act_base_list, sort_func)
- -- if #self.act_base_list > 0 then
- -- ActivityIconManager:getInstance():addIcon(331003, -1)
- -- else
- -- ActivityIconManager:getInstance():deleteIcon(331003)
- -- end
- -- self:CheckMainIconRedDot()
- self:Fire(LimitGiftModel.UPDATE_LIMIT_GIFT_VIEW)
- end
-
- --获得活动信息列表
- function LimitGiftModel:GetTabInfo( )
- self.act_base_list = {} --限购礼包活动内部的活动列表
- local all_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.LIMIT_GIFT) or {}
- all_list = DeepCopy(all_list)
- -- print("huangcong:LimitGiftModel [start:92] :", TableSize(all_list))
- -- PrintTable(all_list)
- local server_time = TimeUtil:getServerTime()
- local my_level = RoleManager.Instance.mainRoleInfo.level
-
- for k,v in pairs(all_list) do
- local open_level = Config.Modulesub["331@3"].open_lv or 1
- for l,w in pairs(v.condition_list) do
- if type(w) == "table" and w[1] == "role_lv" then
- open_level = tonumber(w[2])
- end
- end
- if server_time > v.stime and v.etime > server_time then
- if my_level >= open_level and GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.LIMIT_GIFT) then
- v.sort_index = v.sub_type or 999
- table.insert(self.act_base_list, v)
- end
- end
- end
- return self.act_base_list
- end
|