<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">
			<!-- AI功能横幅 -->
			<view class="ai-banner">
				<text class="banner-text">AI让销售过程和团队管理更透明</text>
			</view>
			
			<!-- 标签页 -->
			<view class="tabs">
				<view 
					class="tab-item" 
					:class="{ active: activeTab === 'status' }"
					@click="switchTab('status')">
					<text>服务状态</text>
				</view>
				<view 
					class="tab-item" 
					:class="{ active: activeTab === 'performance' }"
					@click="switchTab('performance')">
					<text>服务表现</text>
				</view>
			</view>
			
			<!-- 服务状态列表 -->
			<scroll-view class="service-status-list" scroll-y v-if="activeTab === 'status'">
				<view 
					class="service-card" 
					v-for="(item, index) in serviceStatusList" 
					:key="index"
					@click="viewServiceDetail(item)">
					<view class="card-header">
						<view class="staff-info">
							<view class="staff-avatar">
								<text class="avatar-text">{{ item.staffName.charAt(0) }}</text>
							</view>
							<text class="staff-name">{{ item.staffName }}</text>
						</view>
						<view class="service-status">
							<uni-icons type="bars" size="16" color="#007AFF"></uni-icons>
							<text>服务中</text>
						</view>
					</view>
					
					<view class="customer-tags">
						<view 
							class="tag-item" 
							:class="'tag-' + tag.color"
							v-for="(tag, tagIndex) in item.tags" 
							:key="tagIndex">
							<text>{{ tag.text }}</text>
						</view>
					</view>
					
					<!-- AI提醒 -->
					<view class="ai-alert" v-if="item.alert" :class="item.alert.type === 'risk' ? 'alert-risk-box' : 'alert-reminder-box'">
						<view class="alert-header">
							<view class="alert-icon">
								<view class="icon-circle"></view>
							</view>
							<text class="alert-title">{{ item.alert.title }}</text>
						</view>
						<view class="alert-content" :class="item.alert.type === 'risk' ? 'alert-risk-text' : 'alert-reminder-text'">
							<text v-if="item.alert.type === 'risk'">{{ item.alert.message }}</text>
							<view v-else class="alert-list">
								<view class="alert-item" v-for="(msg, msgIndex) in item.alert.messages" :key="msgIndex">
									<text>{{ msg }}</text>
								</view>
							</view>
						</view>
					</view>
					
					<view class="service-duration">
						<text>已服务 {{ item.duration }} 分钟</text>
					</view>
				</view>
			</scroll-view>
			
			<!-- 服务表现内容 -->
			<view class="performance-content" v-if="activeTab === 'performance'">
				<text class="empty-text">服务表现内容</text>
			</view>
		</view>
	</view>
</template>

<script>
	// #ifdef APP
	import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
	// #endif
	export default {
		// #ifdef APP
		components: {
			statusBar
		},
		// #endif
		data() {
			return {
				activeTab: 'status',
				serviceStatusList: [
					{
						staffName: '三多',
						status: '服务中',
						duration: 60,
						tags: [
							{ text: '首次到访', color: 'blue' },
							{ text: '新房交付', color: 'blue' },
							{ text: '想买床', color: 'orange' }
						],
						alert: {
							type: 'risk',
							title: '投诉风险',
							message: '客户情绪激动,有投诉风险,请及时介入'
						}
					},
					{
						staffName: '雅秋',
						status: '服务中',
						duration: 55,
						tags: [
							{ text: '新婚夫妇', color: 'blue' },
							{ text: '收纳需求', color: 'blue' },
							{ text: '毛坯房', color: 'blue' },
							{ text: '关注环保', color: 'orange' }
						],
						alert: {
							type: 'reminder',
							title: '关单提醒',
							messages: [
								'服务已超过2小时,有关单意向',
								'但价格敏感,提起多次竞品品牌'
							]
						}
					}
				]
			}
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
			switchTab(tab) {
				this.activeTab = tab;
			},
			viewServiceDetail(item) {
				// 查看服务详情
				console.log('查看服务详情', item);
			}
		}
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}
	
	.page {
		min-height: 100vh;
		background-color: #F5F5F5;
	}
	
	.content {
		padding-top: 88rpx;
	}
	
	/* AI功能横幅 */
	.ai-banner {
		background-color: #E3F2FD;
		padding: 24rpx 32rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.banner-text {
		font-size: 28rpx;
		color: #1976D2;
		flex: 1;
	}
	
	.banner-btn {
		font-size: 28rpx;
		color: #1976D2;
		font-weight: 500;
		margin-left: 16rpx;
	}
	
	/* 标签页 */
	.tabs {
		display: flex;
		background-color: #FFFFFF;
		border-bottom: 1px solid #E0E0E0;
		padding: 0 32rpx;
	}
	
	.tab-item {
		padding: 24rpx 32rpx;
		position: relative;
	}
	
	.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;
	}
	
	/* 服务状态列表 */
	.service-status-list {
		height: calc(100vh - 300rpx);
		background-color: #F5F5F5;
		padding: 24rpx 32rpx;
	}
	
	.service-card {
		background-color: #FFFFFF;
		border-radius: 16rpx;
		padding: 32rpx;
		margin-bottom: 24rpx;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	}
	
	.card-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}
	
	.staff-info {
		display: flex;
		align-items: center;
	}
	
	.staff-avatar {
		width: 64rpx;
		height: 64rpx;
		background-color: #2196F3;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 16rpx;
	}
	
	.avatar-text {
		font-size: 32rpx;
		color: #FFFFFF;
		font-weight: 500;
	}
	
	.staff-name {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}
	
	.service-status {
		display: flex;
		align-items: center;
	}
	
	.service-status text {
		font-size: 26rpx;
		color: #007AFF;
		margin-left: 8rpx;
	}
	
	.customer-tags {
		display: flex;
		flex-wrap: wrap;
		margin-bottom: 20rpx;
		gap: 12rpx;
	}
	
	.tag-item {
		padding: 8rpx 16rpx;
		border-radius: 8rpx;
	}
	
	.tag-blue {
		background-color: #E3F2FD;
	}
	
	.tag-blue text {
		font-size: 24rpx;
		color: #1976D2;
	}
	
	.tag-orange {
		background-color: #FFF3E0;
	}
	
	.tag-orange text {
		font-size: 24rpx;
		color: #F57C00;
	}
	
	/* AI提醒 */
	.ai-alert {
		border-radius: 8rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;
	}
	
	.alert-risk-box {
		background-color: #FFF5F5;
	}
	
	.alert-reminder-box {
		background-color: #F5F5F5;
	}
	
	.alert-header {
		display: flex;
		align-items: center;
		margin-bottom: 12rpx;
	}
	
	.alert-icon {
		margin-right: 8rpx;
	}
	
	.icon-circle {
		width: 24rpx;
		height: 24rpx;
		border: 2rpx solid #333;
		border-radius: 50%;
		position: relative;
	}
	
	.icon-circle::after {
		content: '';
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 8rpx;
		height: 8rpx;
		background-color: #333;
		border-radius: 50%;
	}
	
	.alert-title {
		font-size: 28rpx;
		font-weight: 500;
		color: #333;
	}
	
	.alert-content {
		font-size: 26rpx;
		line-height: 1.6;
	}
	
	.alert-risk-text {
		color: #FF5722;
	}
	
	.alert-reminder-text {
		color: #666;
	}
	
	.alert-list {
		display: flex;
		flex-direction: column;
		gap: 8rpx;
	}
	
	.alert-item {
		display: flex;
		align-items: flex-start;
	}
	
	.alert-item::before {
		content: '•';
		margin-right: 8rpx;
		color: #666;
	}
	
	.alert-item text {
		font-size: 26rpx;
		color: #666;
		line-height: 1.6;
	}
	
	.service-duration {
		padding-top: 16rpx;
		border-top: 1px solid #F0F0F0;
	}
	
	.service-duration text {
		font-size: 26rpx;
		color: #999;
	}
	
	/* 服务表现内容 */
	.performance-content {
		padding: 40rpx;
		text-align: center;
	}
	
	.empty-text {
		font-size: 28rpx;
		color: #999;
	}
</style>
