local PushGift_Controller = {} local private = {} local EventSystem = require("Event/EventSystem") function PushGift_Controller.OnStartup() private.specialGiftDic = {} for i, v in DataSheetManager.DirectGiftOrder:GetEnumerator() do local pushGiftId = v.PushGiftID if pushGiftId and pushGiftId > 0 then private.specialGiftDic[pushGiftId] = v.PushGiftRewardID end end private.alreadyJumpShow = {} end --Special指显示在商城直购礼包页签中的定向礼包,与其他定向礼包区别开 function PushGift_Controller.IsSpecialPushGift(activityId, giftId) if private.specialGiftDic[giftId] then local info = MDL.OperationActivity.PushGiftData:GetDataByActivityID_ID(activityId, giftId) if info and info.RewardId == private.specialGiftDic[giftId] then return true end end return false end --处理自动弹出特殊定向礼包界面逻辑 function PushGift_Controller.DealAutoOpenSpecial() if CTL.HotFix.CheckAssetIsReady("PushGift") == false then return end local infoArray = MDL.PushGift.GetPushGiftArray(true) if #infoArray > 0 then for i, v in ipairs(infoArray) do if CTL.PushGift.IsSpecialPushGift(v.activityId, v.giftId) and (not private.alreadyJumpShow[v.giftId] and v.timing == false) then private.alreadyJumpShow[v.giftId] = true CTL.HomeMain.AddTownHomeDelayView(Const_UI_Lua.UIEnum.OperationActivity.UIDirectionalGiftBase, {giftInfo = v, isSpecial = true}) end end end end --处理自动弹出逻辑 function PushGift_Controller.DealAutoOpen() if CTL.HotFix.CheckAssetIsReady("PushGift") == false then return end --已经打开了界面,不处理 if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.OperationActivity.UIDirectionalGiftBase) then return end local giftInfo = MDL.PushGift.GetHighestOrderInfo() if giftInfo then CTL.HomeMain.AddTownHomeDelayFunc(private.AutoPushGift) end end function private.AutoPushGift() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.OperationActivity.UIDirectionalGiftBase) then return end local giftInfo = MDL.PushGift.GetHighestOrderInfo() if giftInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.OperationActivity.UIDirectionalGiftBase, {giftInfo = giftInfo}) end end function PushGift_Controller.OpenView() local pushGiftArray = MDL.PushGift.GetPushGiftArray() if #pushGiftArray > 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.OperationActivity.UIDirectionalGiftBase, {giftInfo = pushGiftArray[1]}) end end function PushGift_Controller.IsShowNewInPayMall() for giftId, giftRewardId in pairs(private.specialGiftDic) do local info = MDL.PushGift.GetPushGiftInfoById(giftId, giftRewardId) if info then if PushGift_Controller.IsNewGift(info.activityId, giftId) then return true end end end return false end function PushGift_Controller.IsShowNewByTabId(tabId) local isSuccess, tabData = DataSheetManager.DirectGiftOrder:TryGetDataByID(tabId) if isSuccess then local giftId = tabData.PushGiftID local info = MDL.PushGift.GetPushGiftInfoById(giftId, tabData.PushGiftRewardID) if info then return PushGift_Controller.IsNewGift(info.activityId, giftId) end end return false end local OldGiftDicKey = "OldPushSpecialGiftDic" function PushGift_Controller.IsNewGift(activityId, giftId) if not private.OldGiftDic then private.OldGiftDic = PersistentData.PlayerData:Get(OldGiftDicKey, {}) end if not private.OldGiftDic[activityId] then return true else return not private.OldGiftDic[activityId][giftId] end end function PushGift_Controller.SetNewGift(activityId, giftId) if not private.OldGiftDic then private.OldGiftDic = PersistentData.PlayerData:Get(OldGiftDicKey, {}) end if not private.OldGiftDic[activityId] then private.OldGiftDic[activityId] = {} end private.OldGiftDic[activityId][giftId] = true PersistentData.PlayerData:Set(OldGiftDicKey, private.OldGiftDic, true) EventSystem.Dispatch(EventID.UI_PushGift_NewGiftChange) end return PushGift_Controller