<template>
	<view class="container launch-container">
		<view class="lauch-min">
			<image src="@/static/logo2.png" class="logo"></image>
			<!-- <view class="logo-tit"><text class="logo-tit-first">Horizon</text><text>Insights</text></view> -->
		</view>
		<template v-if="!isLogin">
			<button class="goLogin" @click="Login">去登录</button>
			<view class="warn_txt">
				●请登录后查看,仅限内部员工使用
			</view>
		</template>
	</view>
</template>

<script>
	import {User} from '@/config/api.js';
	export default {
		data() {
			return {
				isLogin:false,
			};
		},
		methods:{
			Login() {
				setTimeout(function () {
				  uni.redirectTo({
				  	url:'/pages/login/login'
				  })
				}, 500);
			}
		},
		onLoad() {
			// 判断是否有token缓存
			let token  = this.$db.get('token');
			if(!token) {
				// setTimeout(function () {
				//   uni.redirectTo({
				//   	url:'/pages/login/login'
				//   })
				// }, 2000);
				this.isLogin = false
			}else {
				// 校验token
				User.checkToken().then(res => {
					if(res.Ret === 200) {
						this.isLogin = true;
						setTimeout(function () {
						  uni.redirectTo({
							url:'/pages/index/index'
						  })
						}, 2000);
					}else {
						this.isLogin = false;
						this.$util.toast(res.Msg);
						this.$db.del('token');
						this.$db.del('account');
					}
				}).catch(err => {
					this.$toast(err)
				})
			}
		}
	}
</script>

<style lang="scss">
.launch-container {
	background-color: #3385FF;
	.lauch-min {
		width: 100%;
		position: absolute;
		top: 40%;
		left: 0;
		transform: translateY(-50%);
		.logo {
			display: block;
			width: 582rpx;
			height: 404rpx;
			margin: 0 auto 50rpx;
		}
		.logo-tit {
			text-align: center;
			font-size: 78rpx;
			color: #fff;
			text {
				display: inline-block;
			}
			.logo-tit-first {
				margin-right: 50rpx;
			}
		}
	}
	.goLogin {
		width: 400rpx;
		height: 90rpx;
		line-height: 90rpx;
		position: absolute;
		left: 50%;
		bottom: 15%;
		transform: translateX(-50%);
		color: #fff;
		font-size: 38rpx;
		background-color: #3385FF;
		border:1rpx solid #fff;
		border-radius: 90rpx;
	}
	.warn_txt {
		width: 100%;
		font-size: 26rpx;
		color: #fff;
		position: absolute;
		left: 0;
		bottom: 8%;
		text-align: center;
	}
		
}
</style>
