<script>
|
|
|
export default {
|
onLaunch: function() {
|
// #ifdef MP-WEIXIN
|
this.updateApp()
|
// #endif
|
console.log('App Launch')
|
},
|
onShow: function() {
|
|
console.log('App Show')
|
},
|
onHide: function() {
|
console.log('App Hide')
|
},
|
methods:{
|
updateApp() {
|
const updateManager = uni.getUpdateManager();
|
console.log('updateManager',updateManager)
|
updateManager.onCheckForUpdate(function (res) {
|
// 请求完新版本信息的回调
|
console.log(res);
|
});
|
|
updateManager.onUpdateReady(function (res) {
|
uni.showModal({
|
title: '更新提示',
|
content: '新版本已经准备好,是否重启应用?',
|
showCancel: false,
|
success(res) {
|
if (res.confirm) {
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
updateManager.applyUpdate();
|
} else if (res.cancel) {
|
console.log('用户点击取消,不更新');
|
}
|
}
|
});
|
|
});
|
|
updateManager.onUpdateFailed(function (res) {
|
// 新的版本下载失败
|
uni.showModal({
|
title: '已经有新版本了哟~',
|
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
|
})
|
});
|
}
|
|
|
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
@import "./static/iconfont.css";
|
/*每个页面公共css */
|
@import "uni_modules/uview-ui/index.scss";
|
|
page{
|
background-color: #f8f8f8 !important;
|
}
|
</style>
|