Commit 7b5f3d67 by chenzhenan

强制更新

parent 7ca97388
...@@ -155,5 +155,42 @@ App({ ...@@ -155,5 +155,42 @@ App({
// }) // })
// } // }
},
onShow(){
this.checkUpdateVersion()
},
checkUpdateVersion() {
//判断微信版本是否 兼容小程序更新机制API的使用
if (wx.canIUse('getUpdateManager')) {
//创建 UpdateManager 实例
const updateManager = wx.getUpdateManager();
console.log('是否进入模拟更新');
//检测版本更新
updateManager.onCheckForUpdate(function (res) {
console.log('是否获取版本',res);
// 请求完新版本信息的回调
if (res.hasUpdate) {
console.log('是否有版本');
//监听小程序有版本更新事件
updateManager.onUpdateReady(function () {
//TODO 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 ( 此处进行了自动更新操作)
updateManager.applyUpdate();
})
updateManager.onUpdateFailed(function () {
// 新版本下载失败
wx.showModal({
title: '已经有新版本喽~',
content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~',
})
})
} }
})
} else {
//TODO 此时微信版本太低(一般而言版本都是支持的)
wx.showModal({
title: '溫馨提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},
}) })
\ No newline at end of file
...@@ -33,7 +33,7 @@ Page({ ...@@ -33,7 +33,7 @@ Page({
otype:false otype:false
}, },
onLoad: function (options) { onLoad: function (options) {
this.checkUpdateVersion() //this.checkUpdateVersion()
var that = this; var that = this;
// var fenxiang = options.fenxiang; // var fenxiang = options.fenxiang;
var userInfo = wx.getStorageSync('userInfo') var userInfo = wx.getStorageSync('userInfo')
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
"checkSiteMap": true, "checkSiteMap": true,
"uploadWithSourceMap": true, "uploadWithSourceMap": true,
"compileHotReLoad": false, "compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true, "useMultiFrameRuntime": true,
"useApiHook": true, "useApiHook": true,
"useApiHostProcess": false, "useApiHostProcess": true,
"babelSetting": { "babelSetting": {
"ignore": [], "ignore": [],
"disablePlugins": [], "disablePlugins": [],
...@@ -31,12 +32,14 @@ ...@@ -31,12 +32,14 @@
}, },
"enableEngineNative": false, "enableEngineNative": false,
"useIsolateContext": true, "useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false, "userConfirmedBundleSwitch": false,
"packNpmManually": false, "packNpmManually": false,
"packNpmRelationList": [], "packNpmRelationList": [],
"minifyWXSS": true "minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"minifyWXML": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.17.0", "libVersion": "2.17.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment