12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- const DWTool = require('./utils/DWTool');
- cc.Class({
- extends: cc.Component,
- properties: {
- game: cc.Node,
- },
- onLoad() {
- if (!CC_WECHATGAME) {
- Global.user = {
- uid: DWTool.getUrlParam('uid'),
- token: DWTool.getUrlParam('token'),
- nick: '游客',
- avatar: "",
- gender: 1
- }
- } else {
- switch (cc.sys.platform) {
- case cc.sys.WECHAT_GAME:
- Global.channel = 'weixin';
- break;
- case cc.sys.QQ_PLAY:
- Global.channel = 'qq';
- break;
- }
- }
- if (CC_WECHATGAME) {
- // cc.game.setFrameRate(40); // 微信环境下强制游戏改为40帧的方法
- window.wx.postMessage({ //初始化的时候关闭子域刷新
- messageType: 8,
- });
- }
- this.game.active = true;
- },
- onUpdateGame() {
- if (CC_WECHATGAME) {
- const updateManager = wx.getUpdateManager();
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- console.log(res.hasUpdate)
- })
- updateManager.onUpdateReady(function () {
- wx.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success: function (res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- updateManager.onUpdateFailed(function () {
- // 新的版本下载失败
- })
- }
- }
- });
|