Commit dbc90391 authored by 和慭琛's avatar 和慭琛

新增 检查更新 逻辑

parent 04807755
...@@ -101,6 +101,9 @@ ...@@ -101,6 +101,9 @@
}, },
onLaunch: function() { onLaunch: function() {
this.checkUpdate()
var that=this var that=this
uni.getStorage({ uni.getStorage({
key: 'token', key: 'token',
...@@ -118,6 +121,34 @@ ...@@ -118,6 +121,34 @@
}, },
onShow: function() {}, onShow: function() {},
methods: { methods: {
//检查更新
checkUpdate: function () {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新版本下载失败
})
},
async getBaseInfo(vm,callBack){ async getBaseInfo(vm,callBack){
uni.showLoading({ uni.showLoading({
title:'加载中……' title:'加载中……'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment