diff --git a/App.vue b/App.vue index d4f6022..36ba049 100644 --- a/App.vue +++ b/App.vue @@ -4,6 +4,42 @@ doctorId:'', doctoridStorageKey:'doctor_id' }, + + onShow: function() { + var updateManager = uni.getUpdateManager(); + updateManager.onCheckForUpdate(function(res) { + console.log("是否有最近版本", res.hasUpdate) + }); + + updateManager.onUpdateReady(function(res) { + uni.showModal({ + title: '更新提示', + content: '新版本已经准备好,是否重启应用?', + showCancel: false, + success(res) { + if (res.confirm) { + updateManager.applyUpdate(); + } + } + }); + }); + + updateManager.onUpdateFailed(function(res) { + uni.showModal({ + title: '提示', + content: '新版小程序下载失败\n请自行退出程序,手动卸载本程序,再运行', + confirmText: "知道了", + showCancel: false, + success(res) { + wx.exitMiniProgram({ + success: () => { + console.log('退出小程序成功'); + } + }); + } + }); + }); + }, onLaunch: function(option) { console.log(option, 'option===='); var did = false @@ -82,7 +118,6 @@ } }, - onShow: function() {}, onHide: function() {} }