const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
// console.log(res.hasUpdate);
// 請求完新版本信息的回調
if (res.hasUpdate) {
updateManager.onUpdateReady(function () {
wx.showModal({
showCancel: false,
title: "更新提示",
content: "新版本已就緒,將自動重啓應用",
success(res) {
if (res.confirm) {
// 新的版本已經下載好,調用 applyUpdate 應用新版本並重啓
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function () {
// 新的版本下載失敗
wx.showModal({
showCancel: false,
title: "已有新版本",
content: "請重啓微信"
});
});
}
});