<script>
import md5 from '@/common/md5.js';
export default {
	globalData: {
		shareUrl: 'https://xnh.xazhima.com/prod-api/wap/business/weixin/',
		globalTimestamp: Date.now().toString(),
		secret: 'AirQK_weichat_app_zhima',
		selectedIndex: 0,
		isSider: false,
		user_id: '',
		open_id: '',
		user_status: '',
		user_name: '',
		user_phone: '',
		user_headUrl: '',
		globalAuth: false,
		session_key: '',
		isAndroid: false,
		user_department: '',
		user_real_name: ''
	},
	onLaunch: function () {
		console.log('App Launch');
		// let equType = uni.getSystemInfoSync().platform;
		//  switch(equType){
		//     case 'android':
		//        console.log('运行Android上')
		// 		setTimeout(()=>{
		// 			getApp().globalData.isAndroid = true
		// 		},100)
		//        break;
		//     case 'ios':
		//        console.log('运行iOS上');
		//        break;
		//     default:
		//        console.log('运行在开发者工具上')
		//        break;
		// }
		this.loginLoad();
	},
	onShow: function () {
		console.log('App Show');
		// uni.hideTabBar({})
	},
	onHide: function () {
		console.log('App Hide');
	},
	methods: {
		loginLoad() {
			let that = this;
			uni.login({
				success(res) {
					that.loginRequest(res.code);
				}
			});
		},
		loginRequest(codeRes) {
			let that = this;
			let url = getApp().globalData.shareUrl + 'login/' + codeRes;
			uni.request({
				url: url,
				method: 'GET',
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},

				success: (res) => {
					console.log(res);
					if (res.data.code === 200) {
						uni.setStorageSync('openid', res.data.data.openid)
						getApp().globalData.open_id = res.data.data.openid;
						getApp().globalData.session_key = res.data.data.session_key;
						that.$isResolve();
						//	uni.hideLoading()
					}
				},
				fail: () => {
					console.log('连接失败');
				}
			});
		}
	}
};
</script>

<style lang="scss">
/*每个页面公共css */
@import '@/common/uni.css';
page {
	height: 100%;
	background: #f3f3f3;
	&:before {
		content: '';
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		z-index: 1;
		height: 1rpx;
		background: #e0e0e0;
	}
}
button::after {
	display: none;
}
* {
	touch-action: none;
}
.display-flex-start {
	display: flex;
	align-items: center;
}
.display-flex-center {
	display: flex;
	justify-content: center;
	align-items: center;
}
.display-flex-end {
	display: flex;
	justify-content: flex-end;
	align-items: center;
}
.display-between {
	display: flex;
	justify-content: space-between;
}
.display-around {
	display: flex;
	justify-content: space-around;
}
.display-between-column {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}
.display-around-column {
	display: flex;
	flex-direction: column;
	justify-content: space-around;
}
.display-evenly-column {
	display: flex;
	flex-direction: column;
	justify-content: space-evenly;
}
.display-wrap {
	flex-wrap: wrap;
}
.items-center {
	align-items: center;
}
.margin-top-10 {
	margin-top: 10%;
}
.shareParent {
	width: 100%;
	height: 100%;
	position: fixed;
}
.margin-right-10 {
	margin-right: 10rpx;
}
.margin-top-1 {
	margin-top: 1%;
}
.margin-right-0 {
	margin-right: 0 !important;
}
.color-666 {
	color: #666666;
}
.color-999 {
	color: #999;
}
.width-55 {
	width: 55%;
}
</style>
