const BuildingManager = require("../utils/BuildingManager"); const ShareAction = require('./ShareAction'); const Notikey = require('../utils/GameEnum').GameNotificationKey; window.Global = { // 建筑管理 BuildingManager: BuildingManager.instance, debug: true, /** * 点击别人分享的链接需要进行的操作 加好友 */ shareType: ShareAction.NONE, /** * 点击别人分享的链接获取到这个用户的uid,默认-1 */ shareUid: -1, //SystemInfo ver: 1, os: 1,//1 android,2 ios channel: CC_WECHATGAME ? "weixin" : "LuciferChannel", user: null, homeUpdate: true, wechatScoreKey: 'starCount', // 开发中的城市Id devCityId: 1, buildRes: null, needLogin: false, friendList: [] }; if (cc.sys.platform === cc.sys.WECHAT_GAME) { wx.onShow(({ query, shareTicket }) => { if (typeof wx.getUpdateManager === 'function') { const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 console.log('hasUpdate: ' + JSON.stringify(res.hasUpdate)); }) updateManager.onUpdateReady(function () { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() }) updateManager.onUpdateFailed(function () { // 新的版本下载失败 }) } console.log('Global onShow' + JSON.stringify(query) + '======================================'); if (query != undefined && query != null) { if (query.uid != undefined) { // Global.processShareAction(query.uid, query.shareType); Global.shareUid = query.uid; Global.shareType = query.shareType; GameEvent.fire(Notikey.ProcessShareAction);//处理通过点击分享链接进入游戏的各种操作,加好友..... } if (shareTicket != undefined && shareTicket != null) { } } let onShowTimestamp = Date.parse(new Date()); let onHideTimestamp = cc.sys.localStorage.getItem("onHideTimestamp"); if (onHideTimestamp !== 0) { let sec = (onShowTimestamp - onHideTimestamp) / 1000; if (sec > 180) { GameEvent.fire(Notikey.HomeReloadData); } else { GameEvent.fire(Notikey.HomeUpdateData, sec); } } console.log("onShowTimestamp: " + onShowTimestamp); console.log("onHideTimestamp: " + onHideTimestamp); }); wx.onHide(() => { console.log('Global onHide ==================================='); cc.sys.localStorage.setItem("onHideTimestamp", Date.parse(new Date())); }); }