|
@@ -2,7 +2,7 @@
|
|
|
export default {
|
|
|
onLaunch: function() {
|
|
|
wx.onAppRoute(function(res) {
|
|
|
- console.log('route',res)
|
|
|
+
|
|
|
let pages = getCurrentPages()
|
|
|
let view = pages[pages.length - 1]
|
|
|
if(view) {
|
|
@@ -15,7 +15,38 @@
|
|
|
console.log('App Launch')
|
|
|
},
|
|
|
onShow: function() {
|
|
|
- console.log('App Show')
|
|
|
+
|
|
|
+ const updateManager = uni.getUpdateManager();
|
|
|
+
|
|
|
+ updateManager.onCheckForUpdate(function (res) {
|
|
|
+ // 请求完新版本信息的回调
|
|
|
+ console.log(res);
|
|
|
+ });
|
|
|
+
|
|
|
+ updateManager.onUpdateReady(function (res) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '更新提示',
|
|
|
+ content: '新版本已经准备好,是否重启应用?',
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
+ updateManager.applyUpdate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ updateManager.onUpdateFailed(function (res) {
|
|
|
+ debugger
|
|
|
+ // 新的版本下载失败
|
|
|
+ console.log('download error')
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '新版小程序下载失败\n请自行退出程序,手动卸载本程序,再运行',
|
|
|
+ confirmText: "知道了"
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
onHide: function() {
|
|
|
console.log('App Hide')
|