local MonthCard_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local MonthCardDailyRedPoint = "MonthCardDailyRedPoint" local CrossDayTimeId = 1 local CrossDayHMS = DataSheetManager.TimeRefresh:GetDataByID(CrossDayTimeId).HMS local AllMonthCardState = "AllMonthCardState" function MonthCard_Controller.CheckAllMonthCardShopRedPoint() -- 获取上次存储的所有月卡是否激活状态 local lastTimeAllMonthCardState = PersistentData.PlayerData:Get(AllMonthCardState, false) -- 获取当前全部月卡激活状态 local allMonthCardActive = MonthCard_Controller.IsAllMonthCardActive() -- 如果上次不是所有月卡都激活 同时 这次所有月卡都激活了 需要重新显示红点 if allMonthCardActive and not lastTimeAllMonthCardState then if MDL.RedPoint.GetOneTimeRedPointInfoByType(MDL.RedPoint.RedPointType.MonthCard) ~= 0 then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.MonthCard, 0) end end -- 本地储存月卡激活状态 if allMonthCardActive ~= lastTimeAllMonthCardState then PersistentData.PlayerData:Set(AllMonthCardState, allMonthCardActive, true) end if MDL.RedPoint.GetOneTimeRedPointInfoByType(MDL.RedPoint.RedPointType.MonthCard) == 0 then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PayMallBase_DoubleMonthCard) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PayMallBase_DoubleMonthCard) end end function MonthCard_Controller.IsAllMonthCardActive() for i, v in DataSheetManager.MonthCard:GetEnumerator() do if not MonthCard_Controller.IsMonthCardActive(v.MonthCardID) then return false end end return true end function MonthCard_Controller.IsMonthCardShopActive() for i, v in MDL.OperationActivity.StoreTypeData:GetEnumerator() do if v.enum == CTL.PayMall.ShopMainTabEnum.MonthCard then return MDL.Shop.GetShopTypeInfoByTabID(v.TabID) end end end function MonthCard_Controller.IsMonthCardActive(monthCardId) local monthCardInfo = MDL.MonthCard.GetMonthCardInfoById(monthCardId) local endTime = monthCardInfo and monthCardInfo.endTime or 0 if endTime - UTL.Time.GetServerTimestamp() >= 0 then return true end return false end function MonthCard_Controller.IsShowMonthCardRedPoint() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.MonthCard) then return MonthCard_Controller.IsHasMonthCardReward() or MonthCard_Controller.IsShowDailyRedPoint() end return false end function MonthCard_Controller.IsHasMonthCardReward() for i, v in pairs(MDL.MonthCard.GetMonthCardInfo()) do if v.todayReward then return true end end return false end function MonthCard_Controller.IsShowDailyRedPoint() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.MonthCard) then return UTL.Time.OsDateOriginal("%w", (UTL.Time.GetServerTimestamp() - CrossDayHMS)) ~= PersistentData.PlayerData:Get(MonthCardDailyRedPoint) end end --月卡需要每天登陆的时候有一个红点,用当前时间的day,即天数记录,如果不一致则需要显示红点。在打开界面的时候置成当前天数,记录在客户端。 function MonthCard_Controller.SetDailyRedPointRecord() local oldValue = PersistentData.PlayerData:Get(key) local newValue = UTL.Time.OsDateOriginal("%w", (UTL.Time.GetServerTimestamp() - CrossDayHMS)) if oldValue ~= newValue then PersistentData.PlayerData:Set(MonthCardDailyRedPoint,newValue,true) EventSystem.Dispatch(EventID.UI_MonthCard_SetDailyRedPointRecord) end end return MonthCard_Controller