<script>
export default {
	onLaunch: function() {
		console.log('App Launch');
		if (uni.getStorageSync('token')) {
			uni.reLaunch({
				url: '/pages/index/index'
			});
		}
		wx.hideShareMenu();
		uni.hideShareMenu(); //去除分享
	},
	onShow: function() {
		console.log('App Show');
		this.phone();
		this.getSystemInfo();
		this.configuration();
		wx.hideShareMenu();
		uni.hideShareMenu(); //去除分享
	},
	onHide: function() {
		console.log('App Hide');
	},
	methods: {
		phone() {
			// 获取手机系统信息
			const info = uni.getSystemInfoSync();
			// 设置状态栏高度(H5顶部无状态栏小程序有状态栏需要撑起高度)
			// 除了h5 app mp-alipay的情况下执行
			// #ifndef H5 || APP-PLUS || MP-ALIPAY
			// 获取胶囊的位置
			const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
			// console.log(menuButtonInfo);
			// (胶囊底部高度 - 状态栏的高度) + (胶囊顶部高度 - 状态栏内的高度) = 导航栏的高度
			this.globalData.navBarHeight = menuButtonInfo.bottom - info.statusBarHeight + (menuButtonInfo.top - info.statusBarHeight) + info.statusBarHeight;
			// #endif
		},
		configuration() {
			let hostUrl = '';
			switch (process.env.UNI_BASE_ENV) {
				case 'development':
					hostUrl = process.env.UNI_BASE_URL;
					break;
				case 'uat':
					hostUrl = process.env.UNI_BASE_URL;
					break;
				case 'production':
					hostUrl = process.env.UNI_BASE_URL;
					break;
			}
			console.log('app.vue配置:', process.env.UNI_BASE_ENV, process.env.UNI_BASE_URL);
		},
		getSystemInfo() {
			let self = this;
			uni.getSystemInfo({
				success: function(res) {
					// console.log(res.statusBarHeight);
					self.globalData.statusBarHeight = res.statusBarHeight || 0;
				}
			});
		}
	},
	globalData: {
		navBarHeight: null,
		statusBarHeight: 0
	}
};
</script>

<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import '@/uni_modules/uview-ui/index.scss';
@import url("@/utils/common.css");
</style>
<style>
/*每个页面公共css */
@import '@/utils/both.css';
page{
	padding-bottom: constant(safe-area-inset-bottom);
	padding-bottom: env(safe-area-inset-bottom);
}
</style>