local FirstCharge_Model = {} local private = {} local first_charge_gift_pb = require('Proto/first_charge_gift_pb') local EventSystem = require('Event/EventSystem') local firstChargeEventList = {BIManager.EventName.FirstTopup_1, BIManager.EventName.FirstTopup_2, BIManager.EventName.FirstTopup_3} local CHARGE_APPEAR_KEY = "CHARGE_APPEAR_PREF" private.hasInit = false function FirstCharge_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageReceiveFirstChargeGift, private.OnFirstChargeGiftResp) EventSystem.Regist(EventID.DeepLink_Event,private.OnDeepLink) end function FirstCharge_Model.GetFirstChargeInfo() return private.firstChargeInfo end function FirstCharge_Model.SyncFirstChargeInfo(info) if private.hasInit == false then CTL.FirstCharge.InitShowState() private.hasInit = true end private.firstChargeInfo = info private.hasCharge = info and #info.gifts > 0 or false if private.HasUnlockFirstChargeShow() == false then --未首充过,监听解锁条件,自动弹出首充界面 EventSystem.Regist(EventID.UI_UpdatePlayerChange, private.OnPlayerChange) end private.UpdateRedPoint() EventSystem.Dispatch(EventID.UI_Update_FirstChargeInfo) end function FirstCharge_Model.HasCharge() return private.hasCharge end function private.HasUnlockFirstChargeShow() local triggerId = DataSheetManager.ConstData:GetDataByID("FirstChargeAppear").IntValue if FirstCharge_Model.HasEntry() and MDL.Unlock.IsTriggerIdComplete(triggerId) and private.hasCharge == false then return PersistentData.PlayerData:Get(CHARGE_APPEAR_KEY,0) == 0 end return false end function private.OnPlayerChange() if private.HasUnlockFirstChargeShow() then EventSystem.UnRegist(EventID.UI_UpdatePlayerChange, private.OnPlayerChange) CTL.HomeMain.AddTownHomeDelayFuncNoUI(CTL.FirstCharge.OpenFirstCharge) PersistentData.PlayerData:Set(CHARGE_APPEAR_KEY, 1, true) end end function private.UpdateRedPoint() if private.firstChargeInfo then for i, v in ipairs(private.firstChargeInfo.gifts) do local redKey = CTL.RedPoint.RedPointKey["FirstCharge_Tab" .. v.giftType] if v.isFinish == true then CTL.RedPoint.RemoveRedPoint(redKey) else local hasUnGet = false for _,received in ipairs(v.dayReceived) do if received == false then hasUnGet = true break end end if hasUnGet then CTL.RedPoint.AddRedPoint(redKey) else CTL.RedPoint.RemoveRedPoint(redKey) end end end end end --是否能显示 支付宝首充 国服、IOS、官网 function FirstCharge_Model.IsNeedShowAlipay() --玩法解锁 if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.FirstChargeAlipay) then return false end --没有首充过 才显示 这个界面 if FirstCharge_Model.HasCharge() then return false end --国服、IOS、官网 if (UNITY_IOS or UNITY_EDITOR) and GameAppInfo.IsChinesePackage() and SDKUtil.ChannelID == LuaConst.SDKChannelId.Hero_iOS then return true end return false end --玩家领取首充界面中的所有奖励后,首充入口消失 function FirstCharge_Model.HasEntry() if not FirstCharge_Model.IsNeedShowAlipay() then if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.FirstCharge) then return false end end if private.firstChargeInfo == nil then return true end local gifts = private.firstChargeInfo.gifts local maxCount = DataSheetManager.FirstCharge:GetDataCount() if #gifts < maxCount then return true end --是否全部领取完 local isAllFinish = true for _, v in ipairs(gifts) do if v.isFinish == false then isAllFinish = false break end end return not isAllFinish end function FirstCharge_Model.FirstChargeGiftReq(giftType) private.awardGiftType = giftType local msg = first_charge_gift_pb.ReceiveFirstChargeGiftReq() msg.giftType = giftType NetManager.SendMessage(MessageEnums.MessageReceiveFirstChargeGift, msg) end function private.OnFirstChargeGiftResp(msgResp) if private.awardGiftType then for i, v in ipairs(private.firstChargeInfo.gifts) do if v.giftType == private.awardGiftType then --越南需求的埋点 if #v.dayReceived > 0 then EventSystem.Dispatch(EventID.BI_ClientEvent, BIManager.EventName.user_napdau_, string.format("%s_%s", private.awardGiftType, #v.dayReceived)) elseif #v.dayReceived == 0 then --最后一档 isFinish = true ,领完奖 #v.dayReceived 为 0 EventSystem.Dispatch(EventID.BI_ClientEvent, BIManager.EventName.user_napdau_, string.format("%s_%s", private.awardGiftType, "3")) end --其他地区如果是领的第一个,打点 if v.isFinish == false then if (#v.dayReceived == 1 and v.dayReceived[1] == true) or (#v.dayReceived > 1 and v.dayReceived[2] == false) then BIManager.DispatchBIClientEvent(firstChargeEventList[private.awardGiftType]) end end break end end end end function FirstCharge_Model.GetLastSelectTab() return private.lastSelectTab end function FirstCharge_Model.SetLastSelectTab(tab) private.lastSelectTab = tab end --IAE扩展 function private.OnDeepLink(key) if key ~= LuaConst.Deeplink.FirstChargeAlipay then return end --在强制引导时不打开首充界面,清掉deeplink存储 if CTL.PlayerGuide.IsForceGuiding() then return end if FirstCharge_Model.HasEntry() and FirstCharge_Model.IsNeedShowAlipay() then --在城镇里 if BattleDataGetter.IsOnlineTownLevel() then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIFirstChargeAlipayPanel) then CTL.FirstCharge.OpenFirstCharge() end --提示红包领取成功 CTL.Tips.AddTipsMsg(Const_IDS.IDS_Alipay_Back) end end end return FirstCharge_Model