1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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,
-
- shareUid: -1,
-
- ver: 1,
- os: 1,
- channel: CC_WECHATGAME ? "weixin" : "LuciferChannel",
- user: null,
- homeUpdate: true,
- wechatScoreKey: 'starCount',
-
- 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 () {
-
- updateManager.applyUpdate()
- })
- updateManager.onUpdateFailed(function () {
-
- })
- }
- console.log('Global onShow' + JSON.stringify(query) + '======================================');
- if (query != undefined && query != null) {
- if (query.uid != undefined) {
-
- 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()));
- });
- }
|