<template>
</template>
<script>
	import Api from '@/common/js/api.js'
	export default {
		globalData: {  
		    systemInfo: null,
			tableCode: null,
			shopId: null,
			queueId: null,
		},  
		onLaunch: function(options) {
			if ( options.query&&options.query.qrCode ) {
				if (this.getQueryString(options.query.qrCode, 'code')) {
					this.globalData.tableCode = this.getQueryString(options.query.qrCode, 'code')
				}
				if (this.getQueryString(options.query.qrCode, 'shopId')) {
					this.globalData.shopId = this.getQueryString(options.query.qrCode, 'shopId')
				}
				if (this.getQueryString(options.query.qrCode, 'queueId')) {
					this.globalData.queueId = this.getQueryString(options.query.qrCode, 'queueId')
				}
			}
			if ( uni.getStorageSync("NAME") && !uni.getStorageSync("NAME").data) {
				uni.cache.clear();
			}
			// #ifdef MP-WEIXIN
			uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect());
			// #endif
			uni.cache.set('NAME', '零点八零');
			if (!uni.cache.get('token')) {
				this.$store.dispatch("loginEvent")
			}
			
		},
		onLoad() {
		},
		onShow: function() {
			// 获取导航栏信息
			wx.getSystemInfo({
				success: res => {
				  this.globalData.systemInfo = res;
				}
			}) 
			this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
			// #ifdef MP-WEIXIN
			// 当向小程序后台请求完新版本信息，会进行回调。res: {hasUpdate: true, version: 1.0.0}
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(function(res) {
				if (res.hasUpdate) { // 有更新
					uni.showLoading({
						title: '更新中...'
					}); // 开始下载前，显示Loading
				}
			});
			// 当新版本下载完成，会进行回调
			updateManager.onUpdateReady(function() {
				uni.hideLoading(); // 关闭 Loading 
				uni.showModal({ // 弹确认框（强制更新）
					title: '更新提示',
					content: '更新完毕，是否重启？',
					success: function(res) {
						if (res.confirm) {
							updateManager.applyUpdate(); // 强制小程序重启并使用新版本。
						}
					}
				})
			});
			// 当新版本下载失败，会进行回调
			updateManager.onUpdateFailed(function() {
				uni.hideLoading(); // 关闭 Loading 
				uni.showToast({
					title: '更新失败，稍后再试...',
					icon: "error"
				});
			});
			// #endif

		},
		onHide: function() {
			// console.log('App Hide');
		},
		methods: {
			getQueryString(url, name) { //解码
				var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
				var r = url.substr(1).match(reg)
				if (r != null) {
					return r[2]
				}
				return null;
			},
		}
	};
</script>

<style lang="scss">
	@import '@/uni_modules/uview-ui/index.scss';
	/* #ifndef APP-PLUS-NVUE */
	@import './common/css/uni.scss';
	/* #endif */
	/* uni.scss */
	@import './common/css/flex.css';

	page,
	view,
	scroll-view,
	swiper,
	swiper-item,
	match-media,
	movable-area,
	movable-view,
	cover-view,
	cover-image,
	icon,
	text,
	rich-text,
	progress,
	button,
	checkbox-group,
	editor,
	form,
	input,
	label,
	picker,
	picker-view,
	radio-group,
	slider,
	switch,
	textarea,
	navigator,
	audio,
	camera,
	image,
	video,
	live-player,
	live-pusher,
	map,
	canvas,
	web-view {
		box-sizing: border-box;
	}

	input {
		height: auto;
	}

	image {
		display: block;
	}

	page {
		background-color: #F6F6F6!important;
	}

	text {
		font-size: 28upx;
		color: #333;
	}

	@font-face {
		font-family: 'BebasNeue-Regular';
		src: url('./static/font/BebasNeue-Regular.woff');
	}

	.num {
		font-family: 'BebasNeue-Regular';
	}
</style>