<template>
	<view class="loading-page">
		<view class="loading-content">
			<view class="loading-spinner"></view>
			<text>{{ $t('common.loading') }}</text>
		</view>
	</view>
</template>

<script setup>
	import { onMounted } from 'vue'
	import { useI18n } from '@/utils/i18n.js'

	const { t: $t } = useI18n()

	onMounted(() => {
		// 获取当前语言设置
		const currentLang = uni.getStorageSync('language') || 'zh-CN'
		
		// 根据语言跳转到对应页面
		const targetPage = currentLang === 'en-US' 
			? '/pages/legal/agreement-en'
			: '/pages/legal/agreement-zh'
		
		console.log('当前语言:', currentLang, '跳转到:', targetPage)
		
		// 使用 redirectTo 替换当前页面
		uni.redirectTo({
			url: targetPage,
			fail: (err) => {
				console.error('跳转失败:', err)
				// 如果跳转失败，默认跳转到中文版
				uni.redirectTo({
					url: '/pages/legal/agreement-zh'
				})
			}
		})
	})
</script>

<style lang="scss" scoped>
	.loading-page {
		min-height: 100vh;
		background: #f8f8f8;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.loading-content {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 24rpx;
	}
	
	.loading-spinner {
		width: 60rpx;
		height: 60rpx;
		border: 4rpx solid #f0f0f0;
		border-top: 4rpx solid #07c160;
		border-radius: 50%;
		animation: spin 1s linear infinite;
	}
	
	@keyframes spin {
		0% { transform: rotate(0deg); }
		100% { transform: rotate(360deg); }
	}
	
	text {
		font-size: 28rpx;
		color: #666;
	}
	
	.legal-page {
		min-height: 100vh;
		background: #f8f8f8;
		padding: 24rpx 24rpx 40rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;

		.header {
			margin-bottom: 16rpx;
			.title {
				font-size: 40rpx;
				font-weight: 600;
				color: #222;
				margin-bottom: 8rpx;
			}
			.subtitle {
				font-size: 24rpx;
				color: #888;
			}
		}

		.content {
			// width: 100%;
			background: #fff;
			border-radius: 16rpx;
			padding: 16rpx 20rpx;
			flex: 1;
			min-height: 0;
			box-sizing: border-box;
			box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.04);
		}

		.h1 { font-size: 30rpx; font-weight: 600; color: #222; margin: 18rpx 0 12rpx; }
		.p { font-size: 26rpx; color: #444; line-height: 1.8; margin-bottom: 10rpx; }
		.bold { font-weight: 600; color: #222; }

		.footer {
			text-align: center;
			margin-top: 16rpx;
			font-size: 24rpx;
			color: #888;
		}
	}
</style>


