Ver Fonte

bug 修复

lilei há 4 anos atrás
pai
commit
5d5609500c
1 ficheiros alterados com 24 adições e 0 exclusões
  1. 24 0
      pages/index/index.vue

+ 24 - 0
pages/index/index.vue

@@ -84,6 +84,8 @@
 			}
 		},
 		onLoad() {
+			// 检查更新
+			this.checkUpdate()
 			// 查询购物车列表
 			this.getCartList()
 			// 刷新购物车列表
@@ -124,6 +126,28 @@
 			})
 		},
 		methods: {
+			checkUpdate(){
+				const updateManager = uni.getUpdateManager();
+				updateManager.onCheckForUpdate(function (res) {
+				  // 请求完新版本信息的回调
+				  console.log(res.hasUpdate);
+				});
+				updateManager.onUpdateReady(function (res) {
+				  uni.showModal({
+				    title: '更新提示',
+				    content: '新版本已经准备好,是否重启应用?',
+				    success(res) {
+				      if (res.confirm) {
+				        // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+				        updateManager.applyUpdate();
+				      }
+				    }
+				  });
+				});
+				updateManager.onUpdateFailed(function (res) {
+				  // 新的版本下载失败
+				});
+			},
 			// 获取用户信息
 			getUserInfo(){
 				getUserInfo().then(res => {