local Questionnaire_Model = {} local private = {} local EventSystem = require('Event/EventSystem') local questionnair_reward_pb = require 'Proto.questionnair_reward_pb' local QuestionnaireKey = "Questionnaire" function Questionnaire_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageQuestionnairReward, private.QuestionnairRewardResp) private.questionnaireReward = {} private.questionnaireId = nil end function Questionnaire_Model.SetQuestionnaireReward(list, isDispatchEvent) for i, v in ipairs(list) do if v > 0 then private.questionnaireReward[v] = true end end if isDispatchEvent then EventSystem.Dispatch(EventID.UI_QuestionnaireRewardRefresh, true) end end function Questionnaire_Model.GetValidQuestionnaireIdList() --检测是否领过奖 local list = {} for i, v in DataSheetManager.Questionnaire:GetEnumerator() do if not private.questionnaireReward[v.ID] then if v.SeverOpenDays ~= nil and #v.SeverOpenDays > 0 then -- 因为开服天数这个值测试的时候一直有问题,服务器为了运营埋点自动 +1,合战区又导致这个值变动,所以直接用开服时间戳自己计算。 local diffTimeStamp = UTL.Time.GetServerTimestamp() - MDL.Player.GetServerOpenTs() local leftTimeLimit = (v.SeverOpenDays[1] - 1) * UTL.Time.TotalSecondsOneDay local rightTimeLimit = (v.SeverOpenDays[2] - 1) * UTL.Time.TotalSecondsOneDay -- 左闭右开 if diffTimeStamp >= leftTimeLimit and diffTimeStamp 0 then for __, channelId in ipairs(questionnaireCfg.ChannelShow) do if sdkChannelId == channelId then return true end end return false end for __, channelId in ipairs(questionnaireCfg.ChannelHide) do if sdkChannelId == channelId then return false end end return true end -- 是否显示调查问卷 function Questionnaire_Model.IsShowQuestionnaire() local state = MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Questionnaire) and GameAppInfo.IsChinesePackage() return state end function Questionnaire_Model.ChangeRedPointStateById(id) local tb = PersistentData.PlayerData:Get(QuestionnaireKey) if tb == nil then tb = {} end tb[id] = 1 PersistentData.PlayerData:Set(QuestionnaireKey, tb, true) end --根据问卷ID判断是否显示红点 function Questionnaire_Model.IsShowQuestionnaireRedPointById(id) --没解锁不显示红点 if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Questionnaire) then return false end local tb = PersistentData.PlayerData:Get(QuestionnaireKey) local state = 0 if tb ~= nil then state = tb[id] if state == nil then state = 0 end end if state == 1 then --等于1代表点过了 return false else return true end end -- 是否显示调查问卷红点 function Questionnaire_Model.IsShowQuestionnaireRedPoint() --没解锁不显示红点 if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Questionnaire) then return false end local validList = MDL.Questionnaire.GetValidQuestionnaireIdList() if validList and #validList > 0 then for i, v in ipairs(validList) do if Questionnaire_Model.IsShowQuestionnaireRedPointById(v.ID) then return true end end end return false end function Questionnaire_Model.SetQuestionnaireId(id) private.questionnaireId = id end function Questionnaire_Model.GetQuestionnaireId() return private.questionnaireId end function Questionnaire_Model.QuestionnairRewardReq(questionnaireId) local msg = questionnair_reward_pb.QuestionnairRewardReq() msg.questId = questionnaireId NetManager.SendMessage(MessageEnums.MessageQuestionnairReward, msg) end function private.QuestionnairRewardResp(msgResp) if msgResp.Resp.Code == 0 then private.questionnaireReward[msgResp.questId] = true EventSystem.Dispatch(EventID.UI_QuestionnaireRewardRefresh, true) end end return Questionnaire_Model