<template>
	<button v-show="false" open-type="getPhoneNumber" @getphonenumber="userlogin"> </button>
</template>
<script>
	export default {
		onLaunch: function() {
			// #ifdef MP-WEIXIN
			uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect());
			// #endif
			uni.cache.set('NAME', '零点八零');
			this.userlogin()
		},
		onLoad(){
		},
		onShow: function() {
			this.$store.dispatch("HeightActions"); //获取随时获取页面的高度

		},
		onHide: function() {
			// console.log('App Hide');
		},
		methods:{
			async userlogin(reslange) {
				var resdataa = reslange
				uni.login({
					provider: 'weixin',
					success: async (data) => {
						try {
							uni.getUserInfo({
								provider: 'weixin',
								success: async (infoRes) => {
									uni.cache.set('weixincode', data.code);
									let res = await this.api.userwxlogin({
										code: uni.cache.get('weixincode'), //临时登录凭证
										rawData: infoRes.rawData,
										// signature: infoRes.signature,
										// iv: infoRes.detail.iv,
										// encryptedData: infoRes.detail
										// 	.encryptedData
									})
									if (res.code == 0) {
										uni.cache.set('token', res.data.token);
										uni.cache.set('miniAppOpenId', res.data.userInfo
											.miniAppOpenId)
										uni.cache.set('userInfo', res.data.userInfo);
									}
								},
								fail: (err) => {}
							});
						} catch (e) {}
					}
				});
			
			},
			
		}
	};
</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: #F9F9F9;
	}

	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>