* 检测当前的小程序
* 是否是最新版本,是否需要下载、更新
*/
checkUpdateVersion() {
if (Taro.canIUse("getUpdateManager")) {
const updateManager = Taro.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
console.log("新版本", res);
if (res.hasUpdate) {
updateManager.onUpdateReady(function () {
updateManager.applyUpdate();
});
updateManager.onUpdateFailed(function () {
Taro.showModal({
title: "已经有新版本喽~",
content: "请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~",
});
});
}
});
} else {
Taro.showModal({
title: "溫馨提示",
content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。",
});
}
}
onLaunch() {
console.log('onLaunch');
this.checkUpdateVersion()
}