var sysT = require('tools/sys-tool.js') const updateManager = wx.getUpdateManager() var businessT = require('tools/business-tool.js') App({ onLaunch: function () { sysT.adaptor() this.getUpdateReady() this.getNetworkStatus() }, onShow: function (e) { //console.log(e) if (e.scene == 1037) { wx.reportAnalytics('source_applet', { source_app_id: e.referrerInfo.appId, }); } }, getUpdateReady: function () { updateManager.onUpdateReady(function () { wx.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', showCancel: false, success: function (res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() } } }) }) }, getNetworkStatus: function () { var that = this wx.getNetworkType({ success: function (res) { // 返回网络类型, 有效值: // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络) that.networkStatus.type = res.networkType if (that.networkStatus.type == 'none') { that.networkStatus.connected = false } else { that.networkStatus.connected = true } businessT.debugLog(that.networkStatus) } }) wx.onNetworkStatusChange(function (res) { that.networkStatus.type = res.networkType that.networkStatus.connected = res.isConnected businessT.debugLog(that.networkStatus) }) }, globalData: { userInfo: null }, networkStatus: { type: 'none', connected: false }, result: [], medical: { s: false, rebate: 0 } })