Files
yshopb2c-uniapp/App.vue

92 lines
2.5 KiB
Vue
Raw Normal View History

2020-03-15 13:59:43 +08:00
<script>
2020-09-14 21:01:28 +08:00
import Vue from 'vue'
2020-12-20 16:23:02 +08:00
// #ifdef H5
2021-04-10 15:42:46 +08:00
var VConsole = require('@/utils/vconsole.min.js')
2020-12-20 16:23:02 +08:00
// #endif
2020-09-14 21:01:28 +08:00
export default {
2021-04-10 15:42:46 +08:00
onLaunch: function () {
2020-09-14 21:01:28 +08:00
const updateManager = uni.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate)
})
// 下载新版本
updateManager.onUpdateReady(function () {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 重启应用
updateManager.applyUpdate()
}
2021-04-10 15:42:46 +08:00
},
2020-09-14 21:01:28 +08:00
})
})
// 新版本下载失败
updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败
uni.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
})
})
},
onShow: function () {
2021-04-10 15:42:46 +08:00
console.log('App Show')
2020-09-14 21:01:28 +08:00
},
onHide: function () {
2021-04-10 15:42:46 +08:00
console.log('App Hide')
2020-09-14 21:01:28 +08:00
},
mounted() {
2020-12-20 16:23:02 +08:00
// #ifdef H5
2021-04-10 15:42:46 +08:00
var vConsole = new VConsole()
console.log('开启调试')
2020-12-20 16:23:02 +08:00
// #endif
2021-04-10 15:42:46 +08:00
this.setAppInfo()
2020-09-14 21:01:28 +08:00
},
methods: {
// 获取系统栏高度
async setAppInfo() {
2021-04-10 15:42:46 +08:00
let that = this
2020-09-14 21:01:28 +08:00
return new Promise((resolve, reject) => {
uni.getSystemInfo({
success: function (e) {
2021-04-10 15:42:46 +08:00
Vue.prototype.StatusBar = e.statusBarHeight
2020-09-14 21:01:28 +08:00
// #ifdef H5
2021-04-10 15:42:46 +08:00
Vue.prototype.CustomBar = e.statusBarHeight + 45
2020-09-14 21:01:28 +08:00
// #endif
// #ifdef APP-PLUS
2021-04-10 15:42:46 +08:00
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50
2020-09-14 21:01:28 +08:00
} else {
2021-04-10 15:42:46 +08:00
Vue.prototype.CustomBar = e.statusBarHeight + 45
2020-09-14 21:01:28 +08:00
}
// #endif
// #ifdef MP-WEIXIN
2021-04-10 15:42:46 +08:00
let custom = wx.getMenuButtonBoundingClientRect()
Vue.prototype.Custom = custom
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight
2020-09-14 21:01:28 +08:00
// #endif
},
2021-04-10 15:42:46 +08:00
})
})
},
2020-09-14 21:01:28 +08:00
// 自动登录
2021-04-10 15:42:46 +08:00
async autoLogin(data) {},
2020-09-14 21:01:28 +08:00
},
2021-04-10 15:42:46 +08:00
}
2020-03-15 13:59:43 +08:00
</script>
2020-09-14 21:01:28 +08:00
<style lang="less">
2020-09-14 21:01:28 +08:00
/*每个页面公共css */
2021-04-10 15:42:46 +08:00
@import 'animate.css';
@import './assets/iconfont/iconfont.css';
@import './assets/css/base.less';
@import './assets/css/reset.less';
@import './assets/css/style.less';
2020-09-14 21:01:28 +08:00
</style>