You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
onLaunch: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
onShow: function() {
|
|
|
|
console.log('App Launch');
|
|
|
|
const updateManager = uni.getUpdateManager();
|
|
|
|
// 检查小程序是否有新版本发布
|
|
|
|
updateManager.onCheckForUpdate(function (res) {
|
|
|
|
// 请求完新版本信息的回调
|
|
|
|
console.log('onCheckForUpdate', res.hasUpdate);
|
|
|
|
});
|
|
|
|
|
|
|
|
// 小程序有新版本,则静默下载新版本,做好更新准备
|
|
|
|
updateManager.onUpdateReady(function (res) {
|
|
|
|
console.log('onUpdateReady', res);
|
|
|
|
uni.showModal({
|
|
|
|
title: '更新提示',
|
|
|
|
content: '新版本已经准备好,点击确定重新启动',
|
|
|
|
showCancel:false,
|
|
|
|
success(res) {
|
|
|
|
if (res.confirm) {
|
|
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
|
updateManager.applyUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
updateManager.onUpdateFailed(function (res) {
|
|
|
|
console.log('onUpdateFailed', res);
|
|
|
|
// 新的版本下载失败
|
|
|
|
uni.showModal({
|
|
|
|
title: '已经有新版本了哟~',
|
|
|
|
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '@/uni_modules/uni-scss/index.scss';
|
|
|
|
</style>
|