Commit 26f11c2b authored by Damon's avatar Damon

强制更新逻辑

parent b2e6c383
...@@ -69,15 +69,15 @@ export default { ...@@ -69,15 +69,15 @@ export default {
// 应用初始化(全局只触发一次) // 应用初始化(全局只触发一次)
AnalysysAgent.registerSuperProperty("platform", "self-support"); AnalysysAgent.registerSuperProperty("platform", "self-support");
this.getSystemInfo(); this.getSystemInfo();
// 版本更新
await this.updateApp();
// 系统自动登录::每次运行小程序重新获取用户信息 // 系统自动登录::每次运行小程序重新获取用户信息
await this.autoLogin(); await this.autoLogin();
//this.deleteTempImg() //this.deleteTempImg()
}, },
onShow: async function () { onShow: async function () {
// 版本更新
await this.updateApp();
// 应用启动,或从后台进入前台显示 // 应用启动,或从后台进入前台显示
if (this.uploadTask.length > 0) { if (this.uploadTask.length > 0) {
upload.uploadImageTask(this) upload.uploadImageTask(this)
...@@ -171,29 +171,50 @@ export default { ...@@ -171,29 +171,50 @@ export default {
/* 版本更新 */ /* 版本更新 */
async updateApp() { async updateApp() {
// 版本更新 if (uni.canIUse('getUpdateManager')) {
const updateManager = uni.getUpdateManager(); // 版本更新
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function (res) { updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调 // 请求完新版本信息的回调
}); console.log("update", res)
});
updateManager.onUpdateReady(function (res) { updateManager.onUpdateReady(function (res) {
uni.showModal({ uni.showModal({
title: "更新提示", title: "更新提示",
content: "新版本已经准备好,是否重启应用?", content: "新版本已经准备好,是否重启应用?",
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate(); updateManager.applyUpdate()
} } else if (res.cancel) {
}, //如果需要强制更新,则给出二次弹窗
uni.showModal({
title: '温馨提示~',
content: '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~',
success: function (res) {
updateManager.applyUpdate()
}
})
}
},
});
}); });
});
updateManager.onUpdateFailed(function (res) { updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败 // 新的版本下载失败
}); uni.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
})
});
} else {
uni.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
}, },
/* ------------------------- 数据埋点begin ------------------------------ */ /* ------------------------- 数据埋点begin ------------------------------ */
......
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