|
|
- CommonModel = CommonModel or BaseClass(BaseVo, true)
- local CommonModel = CommonModel
-
- -- 右侧通用邀请弹窗的邀请类型
- CommonModel.InviteTipsType = {
- GuildSpellList = 1, -- 社团拼单邀请
- Team = 2, -- 组队
- Crusade = 3, -- 组队讨伐
- GuardinThree = 4, --绝地守卫
- EventTips = 5, -- 活动tips
- }
-
- function CommonModel:__init()
- CommonModel.Instance = self
- self:Reset()
- end
-
- function CommonModel:Reset()
- self.list_act_notice = {}
- self.act_clock_mask_list = {}
-
- self.invite_data_cache = {} -- 邀请信息总缓存
- self.event_invite_cache = {} -- 活动开启邀请tips缓存
-
- self.act_tip_data_cache = {} -- 活动tips缓存
- -- 活动通用弹窗界面使用,上线后一段时间内活动预告界面不开启倒计时和不自动进入活动
- self.activity_login_time = TimeUtil:getServerTime() + 10
- end
-
- function CommonModel:getInstance()
- if CommonModel.Instance == nil then
- CommonModel.Instance = CommonModel.New()
- end
- return CommonModel.Instance
- end
-
- --存储活动提示信息
- function CommonModel:AddActivityNotice( module_id,sub_id,act_start_time,fixed_str,is_loading )
- for k,v in pairs(self.list_act_notice) do
- --过滤掉重复调用的tip缓存
- if v.module_id == module_id and v.sub_id == sub_id then
- return
- end
- end
- table.insert( self.list_act_notice, {
- module_id = module_id,
- sub_id = sub_id,
- act_start_time = act_start_time,--此参数暂时无用,被CommonController的EventName.SCENE_LOAD_VIEW_COMPLETE替代了
- fixed_str = fixed_str,
- is_loading = is_loading
- })
- -- 根据情况判断是否弹出活动邀请tips
- self:ShowInviteTipInSpercificScene(module_id, sub_id)
- end
-
- --获取一个活动提示数据
- function CommonModel:GetActivityNotictOneInfo( delete_module_id,delete_sub_id )
- --传值代表取出数据删除,不传表示取出列表第一个数据
- delete_sub_id = delete_sub_id or 0
- -------------------------
- if delete_module_id then
- local result_data = false
- local new_tab = {}
- for k,v in pairs(self.list_act_notice) do
- if v.module_id == delete_module_id and (v.sub_id == delete_sub_id) then
- --从列表里面找到重复的,清理掉
- result_data = v
- else
- table.insert( new_tab, v )
- end
- end
- self.list_act_notice = new_tab
- return result_data
- else
- if self.list_act_notice[1] then
- return table.remove(self.list_act_notice,1)
- end
- end
- -------------------------
- return false
- end
-
- --设置活动提示倒计时屏蔽
- function CommonModel:GetActClockMaskList( module_id,sub_id )
- return self.act_clock_mask_list[(module_id or 0).."@"..(sub_id or 0)]
- end
- function CommonModel:SetActClockMaskList( module_id,sub_id )
- self.act_clock_mask_list[(module_id or 0).."@"..(sub_id or 0)] = true
- end
- --多开活动类,要加一个重置mask的接口
- function CommonModel:ReSetActClockMaskList( module_id,sub_id )
- self.act_clock_mask_list[(module_id or 0).."@"..(sub_id or 0)] = false
- end
-
- -- 通用邀请界面相关
- -- 缓存邀请信息
- function CommonModel:PushInviteDataCache(data)
- self.invite_data_cache = self.invite_data_cache or {}
- if data and data.invite_type then
- self.invite_data_cache[#self.invite_data_cache+1] = data
- end
- end
- function CommonModel:GetInviteDataCacheCount( )
- return TableSize(self.invite_data_cache)
- end
- -- 推出最早的邀请信息 only_get_data:只拿数据,不退出列表
- function CommonModel:PopInviteDataCache(only_get_data)
- if self:GetInviteDataCacheCount() > 0 then
- if only_get_data then
- return self.invite_data_cache[1]
- else
- return table.remove(self.invite_data_cache, 1)
- end
- else
- return nil
- end
- end
-
- -- 在特定场景中,如果活动开始,则需要弹出一个活动邀请的tips
- function CommonModel:ShowInviteTipInSpercificScene(module_id, sub_id)
- if not module_id or not sub_id then return end
- local key = module_id .. "@" .. sub_id
- if self.event_invite_cache[key] then return end
- -- 不仅只会弹出一次,而且无论是否在特定场景都要记录这个状态
- self.event_invite_cache[key] = true
- -- 场景判断相关
- local scene_mgr = SceneManager:getInstance()
- local is_in_guildScene = scene_mgr:IsGuildScene() -- 社团场景
- local is_in_bossDeserted = scene_mgr:IsBossDesertedScene() -- 幻魔星域
- local is_in_bossHome = scene_mgr:IsBossHomeScene() -- boss之家
- -- 不在特定场景内,则不弹出tips
- if not is_in_guildScene
- and not is_in_bossDeserted
- and not is_in_bossHome then
- return
- end
- -- 特定场景内,一些活动不需要弹出邀请tips
- if is_in_guildScene then
- if module_id == 400 or module_id == 406 or module_id == 408 then -- 社团场景内的活动不需要在社团场景内弹出邀请tips
- return
- end
- end
- -- 获取活动配置
- local ac_data
- for k, v in pairs(Config.Ac) do
- if v.module == module_id and v.module_sub == sub_id then
- ac_data = v
- break
- end
- end
- if ac_data then
- self:Fire(EventName.OPEN_SPERCIFIC_SCENE_ACT_TIPVIEW, true, ac_data)
- end
- end
-
- --调用之前检查上次场景是否需要过滤此次调用
- function CommonModel:MaskOpenActTip( module_id,sub_id )
- local last_scene = SceneManager.Instance:GetLastSceneId()
- -------------------------
- if module_id == 418 then
- -- 温泉
- return SceneManager.Instance:IsBeachScene(last_scene)
- elseif module_id == 600 then
- --无尽
- return SceneManager.Instance:IsEndlessScene(last_scene)
- elseif module_id == 601 then
- --跨国团战
- return SceneManager.Instance:IsCSGWarScene(last_scene)
- end
- return false
- end
-
- function CommonModel:PushActTipDataCache( act_data )
- self.act_tip_data_cache = self.act_tip_data_cache or {}
- for k,v in pairs(self.act_tip_data_cache) do--相同的数据就别进来捣乱了
- if v.winId == act_data.winId
- and (v.act_sub_type~=nil and v.act_sub_type == act_data.act_sub_type)
- and v.subId == act_data.subId then
- return
- end
- end
- self.act_tip_data_cache[#self.act_tip_data_cache + 1] = act_data
- end
-
- function CommonModel:GetActTipDataCacheCount( )
- return TableSize(self.act_tip_data_cache)
- end
-
- --清除最早的信息
- function CommonModel:PopActTipDataCache( )
- if self:GetActTipDataCacheCount() > 0 then
- return table.remove(self.act_tip_data_cache, 1)
- else
- return nil
- end
- end
-
- ----------活动提醒弹窗相关-start---------
- function CommonModel:PushActRemindTipDataCache( act_data )
- self.act_remind_tip_data_cache = self.act_remind_tip_data_cache or {}
- for k,v in pairs(self.act_remind_tip_data_cache) do--相同的数据就别进来捣乱了
- if v.winId == act_data.winId
- -- and (v.act_sub_type~=nil and v.act_sub_type == act_data.act_sub_type)
- and v.sub_type == act_data.sub_type then
- return
- end
- end
- self.act_remind_tip_data_cache[#self.act_remind_tip_data_cache + 1] = act_data
- end
-
- function CommonModel:GetActRemindTipDataCacheCount( )
- return TableSize(self.act_remind_tip_data_cache)
- end
-
- --清除最早的信息
- function CommonModel:PopActRemindTipDataCache( )
- if self:GetActRemindTipDataCacheCount() > 0 then
- return table.remove(self.act_remind_tip_data_cache, 1)
- else
- return nil
- end
- end
- ----------活动提醒弹窗相关-end-----------
|