diff --git a/App.vue b/App.vue index 10e9b6f2..965fd79a 100644 --- a/App.vue +++ b/App.vue @@ -31,9 +31,11 @@ } that.checkForUpdates() // #endif - // #ifndef APP-PLUS + // #ifdef MP-WEIXIN + // 版本更新 that.handleCityList() that.handleCooperationUrl() + that.updataWeiXin() // #endif console.log('App Launch') }, @@ -170,6 +172,33 @@ this.$store.commit("changeCooperationUrl", res.data); }) }, + // 微信小程序更新 + updataWeiXin() { + let that = this + const updateManager = uni.getUpdateManager() + // 请求完新版本信息的回调 + updateManager.onCheckForUpdate(function(res) { + console.log("是否有新版本", res.hasUpdate) + }) + updateManager.onUpdateReady(function() { + uni.showModal({ + title: '更新提示', + content: '新版本已经准备好,是否重启应用?', + success: function(res) { + if (res.confirm) { + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate() + } + } + }) + }) + updateManager.onUpdateFailed(function() { + uni.showModal({ + title: '新版本更新失败', + content: '请退出并移除小程序,重新打开...', + }) + }) + } } } diff --git a/index.html b/index.html index 98837dce..002d2ed9 100644 --- a/index.html +++ b/index.html @@ -17,5 +17,6 @@
+