58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
|
// app.js
|
||
|
|
||
|
App({
|
||
|
checkUpdate(){
|
||
|
wx.showLoading({
|
||
|
title: '加载中..',
|
||
|
mask: true
|
||
|
})
|
||
|
//微信小程序用户及时更新到最新版本
|
||
|
const updateManager = wx.getUpdateManager()
|
||
|
updateManager.onCheckForUpdate(function (res) {
|
||
|
// 请求完新版本信息的回调
|
||
|
console.log('是否有新版本: ', +res.hasUpdate)
|
||
|
if (!res.hasUpdate) {
|
||
|
wx.hideLoading()
|
||
|
}
|
||
|
})
|
||
|
updateManager.onUpdateReady(function () {
|
||
|
wx.hideLoading()
|
||
|
wx.showModal({
|
||
|
title: '更新提示',
|
||
|
content: '新版本已经准备好,是否重启应用?',
|
||
|
showCancel: false,
|
||
|
success: function (res) {
|
||
|
if (res.confirm) {
|
||
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||
|
updateManager.applyUpdate()
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
updateManager.onUpdateFailed(function () {
|
||
|
wx.hideLoading();
|
||
|
wx.showModal({
|
||
|
title: '提示',
|
||
|
content: '检查到有新版本,但下载失败,请检查网络后重试',
|
||
|
showCancel: false
|
||
|
})
|
||
|
})
|
||
|
setTimeout(wx.hideLoading, 5000)
|
||
|
|
||
|
},
|
||
|
onLaunch() {
|
||
|
// this.checkUpdate()
|
||
|
// let token = wx.getStorageSync('token')
|
||
|
// if(!token){
|
||
|
// wx.reLaunch({
|
||
|
// url: './pages/login/index'
|
||
|
// })
|
||
|
// }
|
||
|
},
|
||
|
globalData: {
|
||
|
userInfo: null,
|
||
|
url: 'https://sh.lidinghb.com',
|
||
|
imgUrl: 'https://sh.lidinghb.com/support/shouhou/',
|
||
|
}
|
||
|
})
|