<template>
	<view class="page">
		<!-- #ifdef APP -->
		<statusBar></statusBar>
		<!-- #endif -->
		
		<!-- 导航栏 -->
		<uni-nav-bar 
			:fixed="true" 
			:statusBar="true" 
			title="AI销冠系统" 
			leftIcon="left" 
			@clickLeft="goBack"
			color="#333"
			backgroundColor="#FFFFFF">
		</uni-nav-bar>
		
		<view class="content">
			<!-- 标签页 -->
			<view class="tabs">
				<view 
					class="tab-item" 
					:class="{ active: activeTab === 'practice' }"
					@click="switchTab('practice')">
					<text>场景</text>
				</view>
				<view 
					class="tab-item" 
					:class="{ active: activeTab === 'training' }"
					@click="switchTab('training')">
					<text>陪练</text>
				</view>
				<view 
					class="tab-item" 
					:class="{ active: activeTab === 'quality' }"
					@click="switchTab('quality')">
					<text>质检</text>
				</view>
				<view 
					class="tab-item" 
					:class="{ active: activeTab === 'material' }"
					@click="switchTab('material')">
					<text>素材</text>
				</view>
			</view>
			
			<!-- 场景tab -->
			<practice-tab v-if="activeTab === 'practice'" @switch-to-training="handleSwitchToTraining"></practice-tab>
			
			<!-- 陪练tab -->
			<training-tab v-if="activeTab === 'training'" @refresh-training-list="handleRefreshTrainingList"></training-tab>
			
			<!-- 质检tab -->
			<scroll-view 
				class="tab-content" 
				scroll-y 
				v-if="activeTab === 'quality'">
				<view class="champion-card">
					<text class="champion-title">质检</text>
					<text class="champion-desc">这里是质检相关的内容展示区域</text>
				</view>
			</scroll-view>
			
			<!-- 素材tab -->
			<material-tab v-if="activeTab === 'material'"></material-tab>
		</view>
	</view>
</template>

<script>
	// #ifdef APP
	import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
	// #endif
	import PracticeTab from "./components/practice-tab.vue";
	import TrainingTab from "./components/training-tab.vue";
	import MaterialTab from "./components/material-tab.vue";
	
	export default {
		// #ifdef APP
		components: {
			statusBar,
			PracticeTab,
			TrainingTab,
			MaterialTab
		},
		// #endif
		// #ifndef APP
		components: {
			PracticeTab,
			TrainingTab,
			MaterialTab
		},
		// #endif
		data() {
			return {
				activeTab: 'practice'
			}
		},
		onLoad() {
			// 页面加载时，如果默认是场景tab页，子组件会自动加载数据
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
			switchTab(tab) {
				this.activeTab = tab;
			},
			handleSwitchToTraining() {
				// 处理从场景tab切换到陪练tab的事件
				this.switchTab('training');
			},
			handleRefreshTrainingList() {
				// 处理刷新陪练列表的事件
				// 切换到陪练tab（如果不在的话）
						this.switchTab('training');
			}
		}
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}
	
	.page {
		min-height: 100vh;
		background-color: #F5F5F5;
	}
	
	.content {
		padding-top: 0; /* 移除padding-top，因为tab页和内容区域都使用绝对定位 */
		margin-top: 0;
		position: relative;
		min-height: 100vh; /* 确保content有足够高度 */
	}
	
	/* 隐藏导航栏占位区域，避免产生空白 */
	::v-deep .uni-navbar__placeholder {
		display: none !important;
	}
	
	/* 标签页 */
	.tabs {
		display: flex;
		background-color: #FFFFFF;
		border-bottom: 1px solid #E0E0E0;
		padding: 0 16rpx;
		margin-top: 0;
		position: absolute;
		top: 88rpx; /* 导航栏高度 */
		left: 0;
		right: 0;
		z-index: 1;
	}
	
	.tab-item {
		padding: 24rpx 32rpx;
		position: relative;
		flex-shrink: 0;
	}
	
	.tab-item text {
		font-size: 30rpx;
		color: #666;
	}
	
	.tab-item.active text {
		color: #333;
		font-weight: 500;
	}
	
	.tab-item.active::after {
		content: '';
		position: absolute;
		bottom: 0;
		left: 32rpx;
		right: 32rpx;
		height: 4rpx;
		background-color: #007AFF;
		border-radius: 2rpx;
	}
	
	.champion-card {
		width: 100%;
		box-sizing: border-box;
		background-color: #FFFFFF;
		border-radius: 16rpx;
		padding: 32rpx;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		min-height: 400rpx;
	}
	
	.champion-title {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 20rpx;
	}
	
	.champion-desc {
		font-size: 28rpx;
		color: #999;
	}
</style>