zhuliu vor 1 Jahr
Ursprung
Commit
ef20c5bfc7
1 geänderte Dateien mit 30 neuen und 1 gelöschten Zeilen
  1. 30 1
      app.js

+ 30 - 1
app.js

@@ -23,7 +23,7 @@ App({
     that.globalData.menuWidth = menuButtonInfo.width;
     wx.setStorageSync('height', that.globalData.navBarHeight)
     this.getPersonRights()
-
+    this.checkVersion()
     //静态图片地址
     var Path = {
       develop: {
@@ -65,4 +65,33 @@ App({
       }
     })
   },
+  checkVersion(){
+    const updateManager = wx.getUpdateManager()  
+    updateManager.onCheckForUpdate(function (res) {  
+      // 请求完新版本信息的回调  
+      if (res.hasUpdate) {  
+        // 有新版本  
+        updateManager.onUpdateReady(function () {  
+          wx.showModal({  
+            title: '更新提示',  
+            content: '新版本已经准备好,是否立即重启应用?',  
+            success: function (res) {  
+              if (res.confirm) {  
+                // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启  
+                updateManager.applyUpdate()  
+              }  
+            }  
+          })  
+        })  
+      
+        updateManager.onUpdateFailed(function () {  
+          // 新版本下载失败  
+          wx.showModal({  
+            title: '更新提示',  
+            content: '新版本下载失败,请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开呦~',  
+          })  
+        })  
+      }  
+    })
+  }
 })