<template>
	<view id="welcome">
		<view class="title">
			欢迎进入<br/>海创微联
		</view> 
		<view class="btn-box">
			<button type="default" @click="goLogin">立即体验</button>
		</view>
		<view class="count-down" @click="goLogin">跳过&nbsp;{{countdown}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 倒计时
				countdown:3,
				timer:null
			}
		},
		onLoad() {
			// 倒计时三秒
			clearInterval(this.timer);
			this.countdown=3;
			this.timer = setInterval(()=>{
				if(this.countdown==1){
					clearInterval(this.timer)
					this.goLogin()
					
				}else{
					this.countdown--;
				}
			},1000)
		},
		onShow() {
			
		},
		// 离开页时关闭定时器(主要防止重复跳转)
		 beforeDestroy() {
			clearInterval(this.timer);
			this.timer = null;
		},
		methods:{
			// 跳转登录页
			goLogin(){
				// 关闭当前页面防止跳回
				uni.reLaunch({
					url:'./login' 
				})
			}
		}
	}
</script>

<style scoped lang="less">
	#welcome{
		height: 100vh;
		background:#57b7ff url(https://am-img.gkiiot.com/iotos/app/img/welcome/welcome.jpg) no-repeat;
		// background-size: 100% 101%;
		
		padding-top: 59vh;
		/*  #ifdef  APP-PLUS  */
		background:#57b7ff url(data:image/jpeg;base64,[encoded data, 87384 characters]) no-repeat;		
		/*  #endif  */
		background-size: 100% auto;
		text-align: center;
	}
	.title{
		width: 357rpx;
		height: 236rpx;
		font-size: 67rpx;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 118rpx;
		margin: 0 auto;
	}
	.btn-box{
		margin-top: 80rpx;
		text-align: center;
		button{
			width: 350rpx;
			height: 120rpx;
			background: #FFFFFF;
			border: 1px solid #FFFFFF;
			border-radius: 60rpx;
			font-size: 42rpx;
			font-weight: 400;
			color: #000000;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
	.count-down{
		position: fixed;
		top: calc(var(--status-bar-height) + 20px);
		margin-top: 20rpx;
		left: 20rpx;
		padding: 10rpx 15rpx;
		border-radius: 20rpx;
		background: rgba(0,0,0,.5);
		color: #fff;
	}
</style>
