使用 Promise 解决小程序页面因为需要app.js onLaunch 参数导致的请求失败
app.js onLaunch 的代码
1 "use strict"; 2 Object.defineProperty(exports, "__esModule", { 3 value: true 4 }); 5 const http = require('./utils/http.js'); 6 const api = require('./config.js'); 7 const updateManager = wx.getUpdateManager(); 8 9 App({ 10 onLaunch: function() { 11 updateManager.onCheckForUpdate(function(res) { 12 // 请求完新版本信息的回调 13 console.log('请求完新版本信息的回调'); 14 console.log(res.hasUpdate) 15 }) 16 17 updateManager.onUpdateReady(function() { 18 wx.showModal({ 19 title: '更新提示', 20 content: '新版本已经准备好,是否重启应用?', 21 success(res) { 22 if (res.confirm) { 23 // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 24 updateManager.applyUpdate() 25 } 26 } 27 }) 28 }) 29 30 updateManager.onUpdateFailed(function() { 31 // 新版本下载失败 32 wx.showModal({ 33 title: '提示', 34 content: '新版本下载失败', 35 showCancel: false 36 }) 37 }) 38 var _this = this; 39 _this.GetSystemInfo(); 40 // _this.toLogin(); 41 42 43 }, 44 globalData: { 45 screenWidth: 0, //屏幕宽度 46 screenHeight: 0, //屏幕高度 47 fontSize: 14, //字体大小 48 openid: '', 49 phone: '', 50 shopid: '', //没有openid 退出 51 logined: false, //是否已经获取了手机号 52 nickname: '', //昵称 53 photo: '', //头像 54 editJobStorageKey: 'edit-job-storage', //编辑职能(角色)的缓存 55 isbindrole: false, //是否已经绑定了职能(角色) 56 rolenumber: '', //职能编号