<template>
	<view class="page">
		<!-- #ifdef APP -->
		<statusBar></statusBar>
		<!-- #endif -->
		
		<!-- 导航栏 -->
		<uni-nav-bar 
			:fixed="true" 
			:statusBar="true" 
			:border="false"
			title="工作台" 
			color="#333"
			backgroundColor="#FFFFFF">
		</uni-nav-bar>
		
		<view class="content" :style="{ paddingTop: contentTop }">
			<view class="scene-grid">
				<view 
					class="scene-card" 
					v-for="scene in scenes" 
					:key="scene.id"
					@click="navigateToScene(scene)">
					<view class="scene-icon">
						<uni-icons :type="scene.icon" size="40" :color="scene.color"></uni-icons>
					</view>
					<text class="scene-title">{{ scene.title }}</text>
					<text class="scene-desc">{{ scene.desc }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// #ifdef APP
	import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
	// #endif
	
	function getSystemInfo() {
		try {
			const systemInfo = uni.getSystemInfoSync();
			return {
				statusBarHeight: systemInfo.statusBarHeight || 20,
			};
		} catch (e) {
			return {
				statusBarHeight: 20,
			};
		}
	}

	export default {
		// #ifdef APP
		components: {
			statusBar
		},
		// #endif
		data() {
			const systemInfo = getSystemInfo();
			const totalNavbarHeight = systemInfo.statusBarHeight * 2 + 44 * 2;
			return {
				contentTop: totalNavbarHeight + 'rpx',
				scenes: [
					{
						id: 'meeting',
						title: '会议场景',
						desc: '会议总结',
						icon: 'calendar',
						color: '#2A68FF',
						navItems: [
							{ title: '总结', path: '/pages/meeting_summary/meeting_summary' }
						]
					},
					{
						id: 'general_sales',
						title: '通用销售场景',
						desc: '通用销售场景功能',
						icon: 'grid',
						color: '#4ECDC4',
						navItems: [
							{ title: '销售准备', path: '/pages/general_sales/prepare/prepare' },
							{ title: '销售过程', path: '/pages/general_sales/process/process' },
							{ title: '销售总结', path: '/pages/general_sales/summary/summary' }
						]
					},
					{
						id: 'furniture_sales',
						title: '家具销售场景',
						desc: '家具销售场景功能',
						icon: 'list',
						color: '#FFA07A',
						navItems: [
							{ title: '销售准备', path: '/pages/furniture_sales/prepare/prepare' },
							{ title: '销售过程', path: '/pages/furniture_sales/process/process' },
							{ title: '销售总结', path: '/pages/furniture_sales/summary/summary' }
						]
					},
					{
						id: 'car_sales',
						title: '汽车销售场景',
						desc: '汽车销售场景功能',
						icon: 'settings',
						color: '#95E1D3',
						navItems: [
							{ title: '销售准备', path: '/pages/car_sales/prepare/prepare' },
							{ title: '销售过程', path: '/pages/car_sales/process/process' },
							{ title: '销售总结', path: '/pages/car_sales/summary/summary' }
						]
					}
				]
			}
		},
		onLoad() {
		},
		methods: {
			navigateToScene(scene) {
				// 跳转到场景详情页面，传递场景信息
				uni.navigateTo({
					url: `/pages-subpackage/workspace/scene-detail?scene=${encodeURIComponent(JSON.stringify(scene))}`
				});
			}
		}
	}
</script>

<style scoped>
	.page {
		min-height: 100vh;
		background-color: #F5F5F5;
	}
	
	.content {
		padding-left: 24rpx;
		padding-right: 24rpx;
		padding-bottom: 24rpx;
		box-sizing: border-box;
	}
	
	.scene-grid {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 24rpx;
	}
	
	.scene-card {
		background: #FFFFFF;
		border-radius: 24rpx;
		padding: 32rpx 24rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		box-shadow: 0 2rpx 16rpx rgba(0, 0, 0, 0.06);
		transition: all 0.3s;
	}
	
	.scene-card:active {
		transform: scale(0.98);
		box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
	}
	
	.scene-icon {
		margin-bottom: 16rpx;
		width: 96rpx;
		height: 96rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: linear-gradient(135deg, rgba(42, 104, 255, 0.1) 0%, rgba(42, 104, 255, 0.05) 100%);
		border-radius: 24rpx;
	}
	
	.scene-title {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		margin-bottom: 12rpx;
		text-align: center;
	}
	
	.scene-desc {
		font-size: 24rpx;
		color: #666;
		text-align: center;
		line-height: 1.4;
	}
</style>
