// app.js import { hostConfig} from "./utils/config" import router from './utils/router.js' App({ getNetSataus(){ wx.onNetworkStatusChange(function (res) { if(!res.isConnected){ wx.showModal({ title: '提示', showCancel:false, content: '当前网络不佳,请稍后重试', complete: (res) => { } }) } if(res.networkType=="3g" || res.networkType=="2g" || res.networkType=="none"){ wx.showModal({ title: '提示', showCancel:false, content: '当前网络不佳,请稍后重试', complete: (res) => { } }) } }) }, onHide (options) { // Do something when hide. }, onShow:function(){ wx.getSystemInfo({ success: (res) => { // windows | mac为pc端 // android | ios为手机端 console.log('getSystemInfo,', res.platform); if( res.platform=="windows" || res.platform=="mac"){ wx.showModal({ title: '提示', showCancel:false, content: '请使用手机端登录', complete: (res) => { wx.exitMiniProgram() } }) } } }); }, onLaunch: function () { // 获取小程序更新管理器实例 const updateManager = wx.getUpdateManager(); // 监听检查更新事件,当小程序有新版本时会触发此回调 updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 console.log(res.hasUpdate); // 打印是否有新版本 }); // 监听更新准备就绪事件,当新版本下载完成时会触发此回调 updateManager.onUpdateReady(function () { wx.showModal({ title: '更新提示', showCancel:false, content: '小程序版本已经更新,请重新进入!', success(res) { if (res.confirm) { // 用户确认更新,调用 applyUpdate 应用新版本并重启小程序 updateManager.applyUpdate(); } } }); }); updateManager.onUpdateFailed(function () { wx.showModal({ title: '更新失败', content:'已经有新版本了,请您删除当前小程序,重新搜索打开', }); // 新版本下载失败,可以在这里处理失败逻辑,例如提示用户稍后再试 }); }, method: router, hostConfig: hostConfig, globalData: { height: 0 } });