<template>
	<view class="splash-container">
		<!-- 跳过按钮 -->
		<view class="skip-btn" @click="skipToLogin">
			<text class="skip-text">{{ countdown > 0 ? countdown + 's后跳过' : '跳过' }}</text>
		</view>
		
		<!-- 应用图标和名称 -->
		<view class="app-info">
			<view class="app-icon">
				<view class="icon-square">
					<view class="book-icon">
						<view class="book-left"></view>
						<view class="book-right"></view>
						<view class="book-line"></view>
					</view>
				</view>
			</view>
			<text class="app-name">云阅读</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				countdown: 3,
				timer: null
			}
		},
		onLoad() {
			this.startCountdown()
		},
		onUnload() {
			if (this.timer) {
				clearInterval(this.timer)
			}
		},
		methods: {
			startCountdown() {
				this.timer = setInterval(() => {
					this.countdown--
					if (this.countdown <= 0) {
						clearInterval(this.timer)
						this.skipToLogin()
					}
				}, 1000)
			},
			skipToLogin() {
				if (this.timer) {
					clearInterval(this.timer)
				}
				uni.reLaunch({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

<style scoped>
	.splash-container {
		width: 100%;
		height: 100vh;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: relative;
		box-sizing: border-box;
		overflow: hidden;
		padding-top: 30px;
	}
	
	.skip-btn {
		position: absolute;
		top: calc(env(safe-area-inset-top) + 40rpx);
		right: 40rpx;
		padding: 12rpx 24rpx;
		border: 2rpx solid #4FC3F7;
		border-radius: 40rpx;
		background-color: #E0F7FA;
		z-index: 10;
	}
	
	.skip-text {
		font-size: 28rpx;
		color: #00838F;
	}
	
	.app-info {
		display: flex;
		flex-direction: column;
		align-items: center;
		position: absolute;
		bottom: calc(env(safe-area-inset-bottom) + 160rpx);
		left: 50%;
		transform: translateX(-50%);
	}
	
	.app-icon {
		margin-bottom: 35rpx;
	}
	
	.icon-square {
		width: 140rpx;
		height: 140rpx;
		background-color: #4FC3F7;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.book-icon {
		position: relative;
		width: 90rpx;
		height: 70rpx;
	}
	
	.book-left,
	.book-right {
		position: absolute;
		width: 45rpx;
		height: 70rpx;
		background-color: #FFFFFF;
		border-radius: 3rpx 0 0 3rpx;
	}
	
	.book-right {
		right: 0;
		border-radius: 0 3rpx 3rpx 0;
	}
	
	.book-line {
		position: absolute;
		left: 45rpx;
		top: 8rpx;
		width: 2rpx;
		height: 54rpx;
		background-color: #4FC3F7;
	}
	
	.app-name {
		font-size: 44rpx;
		color: #000000;
		font-weight: 600;
	}
</style>


