<template>
	<view class="my-page">
		<!-- 顶部背景墙 -->
		<view class="header-curve">
			<view class="user-block" @click="goToLogin">
				<image class="user-avatar" src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
					mode="aspectFill"></image>
				<view class="user-info">
					<text class="user-name">点击登录</text>
					<text class="user-desc-text">登录后享受更多权益 🐾</text>
				</view>
				<uni-icons type="right" size="16" color="rgba(100, 70, 20, 0.4)"></uni-icons>
			</view>
			<view class="wave-shape"></view>
		</view>

		<!-- 我的服务订单区 -->
		<view class="cute-card order-wrap">
			<view class="card-head">
				<text class="card-title">我的服务订单</text>
				<view class="card-more" @click="goToOrder('all')">
					<text>查看全部</text>
					<uni-icons type="right" size="12" color="#a39686"></uni-icons>
				</view>
			</view>
			<view class="order-nav">
				<view class="nav-item" v-for="item in orderItems" :key="item.key" @click="goToOrder(item.key)">
					<view class="icon-bulb">
						<image class="custom-icon" :src="item.icon" mode="aspectFit"></image>
					</view>
					<text class="nav-label">{{ item.label }}</text>
				</view>
			</view>
		</view>

		<!-- 主功能网格 -->
		<view class="menu-grid">
			<view class="menu-box" v-for="item in menuItems" :key="item.path" @click="goToMenu(item)">
				<view class="menu-icon-wrap">
					<image class="custom-icon" :src="item.icon" mode="aspectFit"></image>
				</view>
				<text class="menu-text">{{ item.title }}</text>
			</view>
		</view>

		<view class="footer-msg">
			<text>~ 感谢您的陪伴 ~</text>
		</view>

		<custom-tabbar></custom-tabbar>
	</view>
</template>

<script setup>
import { ref } from 'vue'
import customTabbar from '@/components/custom-tabbar/index.vue'

const goToLogin = () => {
	uni.navigateTo({ url: '/pages/login/index' })
}

const goToOrder = (status) => {
	uni.reLaunch({ url: `/pages/order/list/index?status=${status}` })
}

const goToMenu = (item) => {
	if (item.path) {
		uni.navigateTo({ url: item.path })
	}
}

// 订单图标
const orderItems = [
	{ key: 'wait_dispatch', label: '待派单', icon: '/static/icon/order-wait.svg' },
	{ key: 'wait_accept', label: '待接单', icon: '/static/icon/order-accept.svg' },
	{ key: 'serving', label: '服务中', icon: '/static/icon/order-service.svg' },
	{ key: 'done', label: '已完成', icon: '/static/icon/order-done.svg' },
	{ key: 'cancel', label: '已取消', icon: '/static/icon/order-cancel.svg' }
]

// 功能菜单
const menuItems = [
	{ title: '宠物档案', icon: '/static/icon/pet-archive.svg', path: '/pages/my/pet/list/index' },
	{ title: '用户管理', icon: '/static/icon/user-manage.svg', path: '/pages/my/user/list/index' },
	{ title: '我的评价', icon: '/static/icon/review.svg', path: '/pages/my/review/list/index' },
	{ title: '客服中心', icon: '/static/icon/service-center.svg', path: '' },
	{ title: '协议中心', icon: '/static/icon/agreement.svg', path: '/pages/my/agreement/list/index' },
	{ title: '系统设置', icon: '/static/icon/settings.svg', path: '/pages/my/settings/index' }
]
</script>

<style lang="scss" scoped>
.my-page {
	min-height: 100vh;
	background-color: #fcfaf5;
	padding-bottom: 140rpx;
}

.header-curve {
	position: relative;
	background: #f7ca3e;
	padding: 120rpx 40rpx 160rpx;
	overflow: hidden;
}

.user-block {
	display: flex;
	align-items: center;
	position: relative;
	z-index: 2;
}

.user-avatar {
	width: 140rpx;
	height: 140rpx;
	border: 8rpx solid #fff;
	border-radius: 50%;
	background-color: #fff;
}

.user-info {
	flex: 1;
	margin-left: 32rpx;
}

.user-name {
	display: block;
	font-size: 40rpx;
	font-weight: 800;
	color: #5c4314;
	margin-bottom: 12rpx;
	letter-spacing: 2rpx;
}

.user-desc-text {
	display: block;
	font-size: 24rpx;
	color: #5c4314;
	opacity: 0.85;
	font-weight: 600;
}

.wave-shape {
	position: absolute;
	bottom: -80rpx;
	left: 0;
	width: 100%;
	height: 160rpx;
	background: #fcfaf5;
	border-radius: 50%;
	transform: scaleX(1.5);
}

.cute-card {
	background: #fff;
	border-radius: 40rpx;
	padding: 40rpx;
	margin: 0 32rpx;
	box-shadow: 0 12rpx 40rpx rgba(220, 212, 196, 0.4);
	position: relative;
	z-index: 3;
}

.order-wrap {
	margin-top: -60rpx;
	border: 4rpx solid #fffdfa;
}

.card-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 32rpx;
}

.card-title {
	font-size: 30rpx;
	font-weight: 800;
	color: #4a3e2e;
}

.card-more {
	display: flex;
	align-items: center;
	gap: 4rpx;
	font-size: 24rpx;
	color: #a39686;
	font-weight: 600;
}

.order-nav {
	display: flex;
	justify-content: space-between;
}

.nav-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16rpx;
}

.icon-bulb {
	width: 92rpx;
	height: 92rpx;
	background: #fef6df;
	border-radius: 32rpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.menu-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 24rpx;
	padding: 0 32rpx;
	margin-top: 40rpx;
}

.menu-box {
	background: #fff;
	border-radius: 36rpx;
	padding: 36rpx 12rpx;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 24rpx;
	box-shadow: 0 8rpx 24rpx rgba(220, 212, 196, 0.3);
}

.menu-icon-wrap {
	width: 80rpx;
	height: 80rpx;
	border-radius: 50%;
	background: #fef6df;
	display: flex;
	align-items: center;
	justify-content: center;
}

.custom-icon {
	width: 44rpx;
	height: 44rpx;
}

.nav-label, .menu-text {
	font-size: 22rpx;
	font-weight: 700;
	color: #6d5b45;
	text-align: center;
}

.nav-label {
	font-weight: 600;
}

.footer-msg {
	text-align: center;
	margin-top: 60rpx;
	margin-bottom: 40rpx;
	font-size: 24rpx;
	font-weight: 600;
	color: #d1c5b4;
	letter-spacing: 4rpx;
}
</style>
