<template>
	<view class="screen-container">
		<image class="bg" src="../../static/img/screen/screen-bg.png" mode="scaleToFill"/>
		<button  v-if="unregistered"  @click="changeTabBar"   class="btn" >
			马上进入
		</button>
		<button  v-else class="btn" open-type="getPhoneNumber" @getphonenumber="getInfoPhoneNumber">
			授权绑定
		</button>
	</view>
</template>
<script>
	import http from '@/shopro/request/index';
	import store from '@/shopro/store';
	import {
		mapActions,
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {
				unregistered:false,
				tabBarVal: '步数',
				registerPopup:true,
				form:{name:'xxx'},
				tips: '获取',
				seconds: 10
			}
		},
		computed: {
			...mapGetters(['userInfo','todayNum'])
		},
		methods: {
			...mapActions(['getPhoneNumber','registerInfoFn','getWeRunDataFn','authCheck','getUserInfo']),
			// 切换底部tab;
			changeTabBar(){
				if(this.unregistered){
					uni.navigateTo({
						url: '/pages/h5/index',
					})
				}
			},
			// 获取手机号
			async getInfoPhoneNumber (e) {
				console.log(e)
				let number = await this.getPhoneNumber(e);
				let register = await this.registerInfoFn();
				if(register){ //注册成功
					this.unregistered = true;
				}
			},
			async getAuth(){
				let token = uni.getStorageSync('token');
				// 如果有缓存信息
				if (token) {
					let auth = await this.authCheck();
					if(auth == 0) {
						this.unregistered = true;
						
					}else if(auth == 2001){
						this.unregistered = false;
					}
				} else { 
					let getUserInfo = await this.getUserInfo();
				}
			}
		},
		onHide(){
		},
		onShow() {
			// uni.hideTabBar();
		},
		onReady() {
			this.getAuth();
		}
	}
</script>

<style lang="scss" scoped>
	.screen-container{
		// position: fixed;
		position: absolute;
		width: 100%;
		height: 100%;
		top:0;
		left: 0;
		right: 0;
		bottom: 0;
		.bg{
			width: 100%;
			height: 100%;
		}
		.btn{
			position: absolute;
			transform: translateX(-50%);
			left:50%;
			bottom: 100rpx;
			width: 640rpx;
			height: 100rpx;
			line-height: 100rpx;
			background-color: #fff;
			color:red;
			border-radius: 30rpx;
			font-size: 50rpx;
			font-weight: 400;
			color: #ff6427;
			box-shadow: 0 10px 15px 0 rgba(255, 255, 255, 0.2);
		}
	}

</style>
