local EventSystem = require('Event/EventSystem') local reserved_gift_pb = require 'Proto.reserved_gift_pb' local ReservedGift_Model = {} local private = {} private.GiftState = { Default = 0, UnLock = 1, Open = 2, Finish = 3, } function ReservedGift_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageReservedGiftGetAward, private.ReservedGiftGetAwardResponse) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.PopUpView) private.ReservedGiftState = private.GiftState.UnLock private.IsPopUp = true end function ReservedGift_Model.GetIsShowReservedGift() return private.ReservedGiftState == private.GiftState.Open and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.ReservedGift) end --region ************** 协议 *********** function ReservedGift_Model.SyncReservedGiftState(state) local formerReservedGiftState = private.ReservedGiftState if state > 0 then private.ReservedGiftState = state end if state == private.GiftState.Finish then CTL.PushInterface.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIWelfareReservedGift, false) EventSystem.Dispatch(EventID.UI_ReservedGift_CloseView) end end -- 预约豪礼领奖req function ReservedGift_Model.ReservedGiftGetAwardRequest(id) local msg = reserved_gift_pb.ReservedGiftGetAwardReq() NetManager.SendMessage(MessageEnums.MessageReservedGiftGetAward, msg) end function private.ReservedGiftGetAwardResponse(msgResp) logging.log(LTAG.LOG, "--ReservedGiftGetAwardResponse--------") end function private.PopUpView(fucId, isUnlock) if fucId == MDL.Unlock.FunctionType.ReservedGift and isUnlock and private.ReservedGiftState == private.GiftState.Open and private.IsPopUp then -- 未登录交给登录打脸图处理 if CTL.PushInterface.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIWelfareReservedGift, true) then private.IsPopUp = false end end end --endregion ****************** 协议 *************** return ReservedGift_Model