123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- const BuildingManager = require("../utils/BuildingManager");
- const ShareAction = require('./ShareAction');
- const Notikey = require('../utils/GameEnum').GameNotificationKey;
- const DWTool = require('./utils/DWTool');
- var Global = Global || {}
- Global = {
- // 建筑管理
- BuildingManager: BuildingManager.instance,
- debug: false,
- /**
- * 点击别人分享的链接需要进行的操作 加好友
- */
- 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: []
- };
- // 开发模式下快速切换 正式 or 测试 环境
- if(CC_DEV && DWTool.getUrlParam('debug') != null) {
- Global.debug = !!~~DWTool.getUrlParam('debug');
- }
- Global.socketUrl = Global.debug ?
- 'wss://test-message-allstar.duowan.com/connect' : 'wss://message-allstar.duowan.com/connect';
- window.Global = Global;
- 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()));
- });
- }
|