<template>
	<view class="mine-page">
		<view class="profile-card">
			<image class="avatar" :src="avatar" mode="aspectFill"></image>
			<view class="profile-info">
				<text class="name">{{ name }}</text>
				<text class="desc">Attractor 用户</text>
			</view>
		</view>

		<view class="menu-section">
			<view class="menu-item" @click="goToDevice">
				<view class="left">
					<uni-icons type="gear" size="20" color="#1f9f9a"></uni-icons>
					<text class="label">我的设备</text>
				</view>
				<uni-icons type="right" size="16" color="#94a3b8"></uni-icons>
			</view>

			<view class="menu-item" @click="goToNotice">
				<view class="left">
					<uni-icons type="notification" size="20" color="#1f9f9a"></uni-icons>
					<text class="label">公告中心</text>
				</view>
				<uni-icons type="right" size="16" color="#94a3b8"></uni-icons>
			</view>

			<view class="menu-item" @click="goToUsageRecord">
				<view class="left">
					<uni-icons type="calendar" size="20" color="#1f9f9a"></uni-icons>
					<text class="label">使用记录</text>
				</view>
				<uni-icons type="right" size="16" color="#94a3b8"></uni-icons>
			</view>

			<view class="menu-item" @click="goToDeviceGuide">
				<view class="left">
					<uni-icons type="help" size="20" color="#1f9f9a"></uni-icons>
					<text class="label">设备说明</text>
				</view>
				<uni-icons type="right" size="16" color="#94a3b8"></uni-icons>
			</view>

			<view class="menu-item" @click="resetDeviceFactory">
				<view class="left">
					<uni-icons type="reload" size="20" color="#ef4444"></uni-icons>
					<text class="label danger">恢复出厂</text>
				</view>
				<uni-icons type="right" size="16" color="#94a3b8"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: 'Attractor_001',
				avatar: '/static/images/app_icon_pack_schemeA_tealLogo/master_1024.png'
			}
		},
		methods: {
			goToDevice() {
				uni.navigateTo({
					url: '/pages/devices/master'
				})
			},
			goToNotice() {
				uni.switchTab({
					url: '/pages/work/index'
				})
			},
			goToUsageRecord() {
				uni.navigateTo({
					url: '/pages/mine/help/index'
				})
			},
			goToDeviceGuide() {
				uni.navigateTo({
					url: '/pages/mine/about/index'
				})
			},
			resetDeviceFactory() {
				uni.showModal({
					title: '恢复出厂',
					content: '确认恢复出厂设置吗？该操作无法撤销。',
					confirmText: '确认恢复',
					confirmColor: '#ef4444',
					success: res => {
						if (res.confirm) {
							uni.showToast({ title: '已提交恢复指令', icon: 'none' })
						}
					}
				})
			}
		}
	}
</script>

<style scoped>
	.mine-page {
		min-height: 100vh;
		background: #f4f7f8;
		padding: 24rpx;
		box-sizing: border-box;
	}

	.profile-card {
		background: #ffffff;
		border-radius: 20rpx;
		padding: 24rpx;
		display: flex;
		align-items: center;
		margin-bottom: 18rpx;
		border: 1rpx solid #e7eeef;
	}

	.avatar {
		width: 120rpx;
		height: 120rpx;
		border-radius: 60rpx;
		margin-right: 20rpx;
		background: #f2f4f7;
	}

	.profile-info {
		display: flex;
		flex-direction: column;
	}

	.name {
		font-size: 34rpx;
		font-weight: 700;
		color: #0f172a;
	}

	.desc {
		font-size: 24rpx;
		color: #94a3b8;
		margin-top: 6rpx;
	}

	.menu-section {
		background: #ffffff;
		border-radius: 20rpx;
		border: 1rpx solid #e7eeef;
		padding: 6rpx 0;
	}

	.menu-item {
		height: 92rpx;
		padding: 0 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.menu-item + .menu-item {
		border-top: 1rpx solid #f1f5f9;
	}

	.left {
		display: flex;
		align-items: center;
		gap: 12rpx;
	}

	.label {
		font-size: 28rpx;
		color: #1e293b;
	}

	.label.danger {
		color: #ef4444;
		font-weight: 600;
	}

</style>
