<template>
	<view class="mine-container">
	
		<!-- 顶部用户信息区域 -->
		<view class="user-header">
			<StatusBarPlaceholder></StatusBarPlaceholder>
			
			<!-- 背景装饰 -->
			<view class="header-bg-decoration"></view>
			
			<view class="header-content">
				<view class="user-info">
					<view class="avatar-wrapper">
						<image class="avatar" src="/static/avatar-default.png" mode="aspectFill" />
					</view>
					<view class="user-details">
						<view class="name-row">
							<text class="user-name">赵建平</text>
							<text class="user-role">销售经理</text>
						</view>
						<text class="company-name">浙江舒博特网络科有限公司</text>
					</view>
				</view>
				<view class="qr-btn" @click="showCard">
					<uni-icons type="qrcode" size="28" color="#ffffff"></uni-icons>
					<text class="qr-text">我的名片</text>
				</view>
			</view>
		</view>

		<!-- 线索数据卡片 -->
		<view class="data-card">
			<view class="card-header">
				<text class="card-title">线索数据</text>
			</view>
			<view class="data-row">
				<view class="data-item">
					<text class="data-value">1,266</text>
					<text class="data-label">线索总数</text>
				</view>
				<view class="data-item highlight">
					<text class="data-value orange">65</text>
					<text class="data-label">本月新增</text>
				</view>
				<view class="data-item">
					<text class="data-value">126</text>
					<text class="data-label">我的线索</text>
				</view>
			</view>
		</view>

		<!-- 客户数据卡片 -->
		<view class="data-card">
			<view class="card-header">
				<text class="card-title">客户数据</text>
				<uni-icons type="eye" size="20" color="#999999"></uni-icons>
			</view>
			<view class="data-row">
				<view class="data-item">
					<text class="data-value">1,088</text>
					<text class="data-label">客户总数</text>
				</view>
				<view class="data-item highlight">
					<text class="data-value orange">123</text>
					<text class="data-label">本月新增</text>
				</view>
				<view class="data-item">
					<text class="data-value">235</text>
					<text class="data-label">我的客户</text>
				</view>
			</view>
		</view>

		<!-- 商机数据卡片 -->
		<view class="data-card">
			<view class="card-header">
				<text class="card-title">商机数据</text>
				<uni-icons type="eye" size="20" color="#999999"></uni-icons>
			</view>
			<view class="data-row">
				<view class="data-item">
					<text class="data-value">1,366</text>
					<text class="data-label">商机总数</text>
				</view>
				<view class="data-item highlight">
					<text class="data-value orange">63</text>
					<text class="data-label">本月新增</text>
				</view>
				<view class="data-item">
					<text class="data-value">86</text>
					<text class="data-label">我的商机</text>
				</view>
			</view>
		</view>

		<!-- 功能菜单 -->
		<view class="menu-card">
			<view class="menu-item" @click="navigateTo('guide')">
				<view class="menu-icon-wrapper">
					<uni-icons type="help" size="22" color="#667eea"></uni-icons>
				</view>
				<text class="menu-text">使用指南</text>
				<uni-icons type="right" size="16" color="#cccccc"></uni-icons>
			</view>
			<view class="menu-divider"></view>
			<view class="menu-item" @click="navigateTo('service')">
				<view class="menu-icon-wrapper">
					<uni-icons type="paperclip" size="22" color="#667eea"></uni-icons>
				</view>
				<text class="menu-text">联系客服</text>
				<uni-icons type="right" size="16" color="#cccccc"></uni-icons>
			</view>
			<view class="menu-divider"></view>
			<view class="menu-item" @click="navigateTo('about')">
				<view class="menu-icon-wrapper">
					<uni-icons type="gear" size="22" color="#667eea"></uni-icons>
				</view>
				<text class="menu-text">关于我们</text>
				<uni-icons type="right" size="16" color="#cccccc"></uni-icons>
			</view>
			<view class="menu-divider"></view>
			<view class="menu-item logout-item" @click="handleLogout">
				<view class="menu-icon-wrapper">
					<uni-icons type="closeempty" size="22" color="#ff4d4f"></uni-icons>
				</view>
				<text class="menu-text logout-text">退出登录</text>
				<uni-icons type="right" size="16" color="#cccccc"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref ,onMounted} from 'vue'
import  StatusBarPlaceholder from "@/components/status-bar-placeholder/index.vue"
import { logout } from '@/api/login.js'

const navigateTo = (page) => {
	uni.showToast({
		title: ``,
		icon: 'none'
	})
}

// 显示名片
const showCard = () => {
	uni.showToast({
		title: '我的名片',
		icon: 'none'
	})
}

// ��出登��const handleLogout = () => {
	uni.showModal({
		title: '提示',
		content:'缺人要退出登录吗?',
		success: async (res) => {
			if (res.confirm) {
				try {
					// 调用��出登录接��					await logout({})
					
					// 清除本地存储
					uni.removeStorageSync('token')
					uni.removeStorageSync('userInfo')
					uni.removeStorageSync('code')
					
					// 提示成功
					uni.showToast({
						title: '操作成功',
						icon: 'success'
					})
					
					// 延迟跳转到登录页
					setTimeout(() => {
						uni.reLaunch({
							url: '/pages/login/login'
						})
					}, 1500)
				} catch (error) {
					console.error('退出登录失败', error)
					uni.showToast({
						title: '退出登录失败,请重试',
						icon: 'none'
					})
				}
			}
		}
	})
}
</script>

<style lang="scss" scoped>
.mine-container {
	min-height: 100vh;
	background: #f5f6f8;
}

// 顶部用户信息区域
.user-header {
	background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
	padding: 0 40rpx 160rpx;
	padding-top: calc(var(--status-bar-height) + 20rpx);
	position: relative;
	overflow: hidden;
	
	// 背景光晕装饰
	.header-bg-decoration {
		position: absolute;
		top: -100rpx;
		right: -100rpx;
		width: 400rpx;
		height: 400rpx;
		background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
		border-radius: 50%;
	}
	
	.header-content {
		position: relative;
		z-index: 2;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
	}
	
	.user-info {
		display: flex;
		align-items: center;
		flex: 1;
		
		.avatar-wrapper {
			flex-shrink: 0;
			margin-right: 24rpx;
			position: relative;
			
			.avatar {
				width: 128rpx;
				height: 128rpx;
				border-radius: 50%;
				border: 4rpx solid rgba(255, 255, 255, 0.4);
				box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.15);
				background: #ffffff;
			}
		}
		
		.user-details {
			flex: 1;
			
			.name-row {
				display: flex;
				align-items: center;
				margin-bottom: 12rpx;
				
				.user-name {
					font-size: 36rpx;
					font-weight: 600;
					color: #ffffff;
					text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
				}
				
				.user-role {
					font-size: 22rpx;
					color: #ffffff;
					background: rgba(255, 255, 255, 0.25);
					padding: 4rpx 16rpx;
					border-radius: 20rpx;
					margin-left: 16rpx;
					font-weight: 500;
				}
			}
			
			.company-name {
				font-size: 24rpx;
				color: rgba(255, 255, 255, 0.85);
				display: block;
				text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
			}
		}
	}
	
	.qr-btn {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		background: rgba(255, 255, 255, 0.2);
		padding: 16rpx 20rpx;
		border-radius: 24rpx;
		backdrop-filter: blur(10rpx);
		border: 1rpx solid rgba(255, 255, 255, 0.3);
		box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
		
		.qr-text {
			font-size: 20rpx;
			color: #ffffff;
			margin-top: 4rpx;
			text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
		}
	}
}

// 数据卡片
.data-card {
	background: #ffffff;
	margin: 20rpx 40rpx;
	padding: 32rpx;
	border-radius: 24rpx;
	box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
	
	.card-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;
	}
	
	.card-title {
		font-size: 28rpx;
		font-weight: 600;
		color: #333333;
	}
	
	.data-row {
		display: flex;
		justify-content: space-between;
		
		.data-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			flex: 1;
			position: relative;
			
			.data-value {
				font-size: 40rpx;
				font-weight: 600;
				color: #333333;
				margin-bottom: 12rpx;
				font-family: DIN, 'DIN Alternate', sans-serif;
			}
			
			.data-label {
				font-size: 24rpx;
				color: #999999;
			}
			
			&.highlight .data-value {
				color: #ff6b35;
			}
			
			&:not(:last-child)::after {
				content: '';
				position: absolute;
				right: 0;
				top: 50%;
				transform: translateY(-50%);
				width: 1rpx;
				height: 60rpx;
				background: #f0f0f0;
			}
		}
	}
}

// 功能菜单
.menu-card {
	background: #ffffff;
	margin: 20rpx 40rpx;
	padding: 0 32rpx;
	border-radius: 24rpx;
	box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
	
	.menu-item {
		display: flex;
		align-items: center;
		padding: 32rpx 0;
		
		.menu-icon-wrapper {
			width: 60rpx;
			height: 60rpx;
			border-radius: 16rpx;
			background: rgba(102, 126, 234, 0.08);
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 20rpx;
		}
		
		.menu-text {
			flex: 1;
			font-size: 28rpx;
			color: #333333;
		}
	}
	
	.menu-divider {
		height: 1rpx;
		background: #f0f0f0;
	}
	
	// ��出登录样��	.logout-item {
		.menu-icon-wrapper {
			background: rgba(255, 77, 79, 0.08);
		}
		
		.menu-text {
			color: #ff4d4f;
			
			&.logout-text {
				color: #ff4d4f;
			}
		}
	}
}
</style>
