Files
JiaZhiQianYan/App.vue

153 lines
3.0 KiB
Vue

<script>
import { provide } from 'vue'
export default {
onLaunch: function() {
console.log('App Launch')
let windowInfo = uni.getWindowInfo()
provide('statusHeight',windowInfo.statusBarHeight)
provide('windowWidth',windowInfo.windowWidth)
provide('safeAreaTop',windowInfo.safeArea.top)
var safeAreaBottom = windowInfo.safeAreaInsets.bottom
let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
provide('navHeight',menuButtonInfo.bottom + menuButtonInfo.top - windowInfo.statusBarHeight)
provide('menuTop',menuButtonInfo.top)
provide('menuHeight',menuButtonInfo.height)
provide('isiPhoneX',safeAreaBottom==34?true:false)
},
onShow: function() {
console.log('App Show')
this.updateManager()
},
onHide: function() {
console.log('App Hide')
},
globalData:{
mobileReg:/^1[3456789][0-9]{9}$/
},
methods:{
updateManager() {
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(res => {
// 请求完新版本信息的回调
// console.log(res.hasUpdate)
if (res.hasUpdate) {
uni.showModal({
title:'更新提示',
content:'检测到新版本,是否下载新版本并重启小程序?',
success(res) {
if (res.confirm) {
updateManager.onUpdateReady(() => {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,即将重启应用',
showCancel: false,
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
}
},
fail(error) {
}
})
}
updateManager.onUpdateFailed(() => {
// 新的版本下载失败
uni.showModal({
title: '更新提示',
content: '新版本下载失败',
showCancel: false
})
})
})
}
}
}
</script>
<style>
/*每个页面公共css */
.flex
{
display: flex;
align-items: center;
}
.flexCenter
{
display: flex;
align-items: center;
justify-content: center;
}
.flexColumn
{
display: flex;
flex-direction: column;
}
.flexColumnCenter
{
display: flex;
flex-direction: column;
align-items: center;
}
.flex1
{
flex: 1;
}
.flexWrap
{
display: flex;
flex-wrap: wrap;
}
.flexStretch
{
display: flex;
align-items: stretch;
}
.between
{
justify-content: space-between;
}
.flexEnd
{
display: flex;
align-items: center;
justify-content: flex-end;
}
.relative
{
position: relative;
}
.absolute
{
position: absolute;
}
.fixed
{
position: fixed;
}
view,input,textarea,scroll-view,swiper
{
box-sizing: border-box;
}
button
{
background-color: transparent;
}
button::after
{
border: none;
}
::-webkit-scrollbar
{
color: transparent;
width: 0;
}
</style>