|
|
@@ -17,6 +17,38 @@ App({
|
|
|
this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ // 检测小程序更新
|
|
|
+ this.checkUpdate();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 检测小程序更新
|
|
|
+ checkUpdate: function() {
|
|
|
+ // 获取更新管理器实例
|
|
|
+ const updateManager = wx.getUpdateManager();
|
|
|
+
|
|
|
+ // 检查是否支持checkForUpdate方法
|
|
|
+ if (updateManager.checkForUpdate) {
|
|
|
+ // 检查是否有更新版本
|
|
|
+ updateManager.checkForUpdate({
|
|
|
+ success: function(res) {
|
|
|
+ // 有新版本
|
|
|
+ if (res.hasUpdate) {
|
|
|
+ console.log('检测到新版本,开始下载');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当下载完成后触发
|
|
|
+ updateManager.onUpdateReady(function() {
|
|
|
+ updateManager.applyUpdate();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 当下载失败时触发
|
|
|
+ updateManager.onUpdateFailed(function() {
|
|
|
+ console.log('更新下载失败');
|
|
|
+ });
|
|
|
},
|
|
|
initSocket() {
|
|
|
let that = this;
|