<script>
	import Vue from 'vue'
	// import app from './utils/api.js'
	export default {
		onLaunch: function() {
			// 微信登录
			wx.login({
				success({code}) {
					console.log('code:'+code);
					uni.request({
						url:'http://localhost:3001/login2',
						method:'POST',
						data:{code}
					}).then(res=>{
						console.log(res.data);
						uni.setStorageSync('SESSION',res.data)
					})
				}
			})

			uni.setStorageSync('login', '0');
			// uni.setStorageSync('msgLogin', '0');


			uni.getSystemInfo({
				success: function(res) {
					Vue.prototype.screenHeight = res.screenHeight
					Vue.prototype.screenWidth = res.screenWidth
					// console.log(res);
					const tabBarHeight = res.screenHeight - res.windowHeight;
					Vue.prototype.tabBarHeight = tabBarHeight
					if (uni.getMenuButtonBoundingClientRect()) {
						console.log('小程序');
						// 小程序状态栏是指显示电量的那一小部分
						thisWechat(res.statusBarHeight)
					} else {
						console.log('app');
						thisApp(res.statusBarHeight)
					}
				}
			});

			function thisWechat(statusBarHeight) {



				// 获取胶囊位置
				let meunButtonInfo = uni.getMenuButtonBoundingClientRect()
				// console.log(meunButtonInfo);

				Vue.prototype.meunButtonInfo = meunButtonInfo.height

				// 计算出导航栏高度+动态栏
				let allHeight = meunButtonInfo.bottom + (meunButtonInfo.top - statusBarHeight) * 2;
				// console.log(allHeight);
				let navheight;
				Vue.prototype.navheight = allHeight

				// 按钮离顶
				let alltop = meunButtonInfo.top
				Vue.prototype.navTop = alltop

				// 动态栏高度
				let statusHeight
				Vue.prototype.statusHeight = statusBarHeight
			};

			function thisApp(statusBarHeight) {
				// console.log(uni.getSystemInfoSync());
				// 导航栏高度
				// let appAllHeight;console.log();
				// Vue.prototype.appAllHeight=statusBarHeight+44+'px';
				// console.log(statusBarHeight);
				let customBarHeight;
				if (uni.getSystemInfoSync().platform === 'android') {

					customBarHeight = statusBarHeight + 50;

				} else if (uni.getSystemInfoSync().platform === 'ios') {
					// iOS 平台
					// 在这里根据 iOS 平台的特性计算自定义状态栏高度
					// ...
					customBarHeight = statusBarHeight + 45;
				} else {
					// 其他平台
					// ...
					customBarHeight = statusBarHeight;
				}
				// console.log(customBarHeight);
				Vue.prototype.customBar = customBarHeight;
			}

		},
		onShow() {},
		onLoad() {

		}
	}
</script>

<style>
	/*每个页面公共css */
	body {
		background-color: #f0f2f5;
		/* font-family: PingFang SC; */

	}

	view {
		box-sizing: border-box;
		padding: 0;
	}

	/* 公共字体大小类 */

	.one-font {
		font-size: 48rpx;
		line-height: 72rpx;
		font-weight: 600;
	}

	.two-font {
		font-size: 40rpx;
		line-height: 56rpx;
	}

	.twoZ-font {
		font-size: 40rpx;
		line-height: 56rpx;
		font-weight: 500;
	}

	.three-font {
		font-size: 34rpx;
		line-height: 48rpx;
		font-weight: 500;
	}

	.num-font {
		font-size: 36rpx;
		line-height: 56rpx;
		font-weight: 700;
	}

	.bmTit-font {
		font-size: 36rpx;
		line-height: 44rpx;
		font-weight: 500;
	}

	.fNum-font {
		font-size: 44rpx;
		line-height: 56rpx;
		font-weight: 700;
	}

	.zw-font {
		font-size: 34rpx;
		line-height: 48rpx;
	}

	.btn-font {
		font-size: 28rpx;
		line-height: 40rpx;
		font-weight: 600;
	}

	.fwb-font {
		font-size: 28rpx;
		line-height: 40rpx;
		font-size: 400;
	}

	.sZw-font {
		font-size: 26rpx;
		line-height: 42rpx;
		font-size: 400;
	}

	.sBtn-font {
		font-size: 24rpx;
		line-height: 32rpx;
		font-weight: 600;
	}

	.fz-font {
		font-size: 24rpx;
		line-height: 32rpx;
		font-weight: 400;
	}

	.bq-font {
		font-size: 20rpx;
		line-height: 24rpx;
	}

	.bqZ-font {
		font-size: 20rpx;
		line-height: 24rpx;
		font-weight: 600;
	}
</style>