<template>
	<view class="achievement-page">
		<navbar title="读者成就设置" leftClick @leftClick="$utils.navigateBack" />
		<view class="achievement-card">
			<view class="card-title-row">
				<view class="card-title">阅读成就设置</view>
				<view v-if="isPending" class="pending-tag">设置审核中</view>
			</view>
			<view class="achievement-list">
				<view class="achievement-item">
					<image class="badge-img"
						src="https://tse3-mm.cn.bing.net/th/id/OIP-C.wUsFZgl70iE4tI7b_HKaKgHaHa?w=166&h=180&c=7&r=0&o=5&dpr=1.1&pid=1.7"
						mode="aspectFill" />
					<view class="input-area">
						<view class="label-row">
							<text class="required">*</text>
							<text class="label">一级成就名称</text>
						</view>
						<input class="input" v-model="level1" placeholder="请输入" placeholder-class="input-placeholder" />
					</view>
				</view>
				<view class="divider"></view>
				<view class="achievement-item">
					<image class="badge-img"
						src="https://tse3-mm.cn.bing.net/th/id/OIP-C.wUsFZgl70iE4tI7b_HKaKgHaHa?w=166&h=180&c=7&r=0&o=5&dpr=1.1&pid=1.7"
						mode="aspectFill" />
					<view class="input-area">
						<view class="label-row">
							<text class="required">*</text>
							<text class="label">二级成就名称</text>
						</view>
						<input class="input" v-model="level2" placeholder="请输入" placeholder-class="input-placeholder" />
					</view>
				</view>
				<view class="divider"></view>
				<view class="achievement-item">
					<image class="badge-img"
						src="https://tse3-mm.cn.bing.net/th/id/OIP-C.wUsFZgl70iE4tI7b_HKaKgHaHa?w=166&h=180&c=7&r=0&o=5&dpr=1.1&pid=1.7"
						mode="aspectFill" />
					<view class="input-area">
						<view class="label-row">
							<text class="required">*</text>
							<text class="label">三级成就名称</text>
						</view>
						<input class="input" v-model="level3" placeholder="请输入" placeholder-class="input-placeholder" />
					</view>
				</view>
			</view>
		</view>
		<view class="bottom-btn-area">
			<button class="submit-btn" :disabled="isPending" :class="{disabled: isPending, pending: isPending}"
				@click="submit">
				{{ isPending ? '设置' : '提交申请' }}
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				level1: '',
				level2: '',
				level3: '',
				isPending: false
			}
		},
		methods: {
			submit() {
				if (!this.level1 || !this.level2 || !this.level3) {
					uni.showToast({
						title: '请填写所有成就名称',
						icon: 'none'
					})
					return
				}
				this.isPending = true
				// 可根据需要添加实际提交逻辑
			}
		}
	}
</script>

<style scoped lang="scss">
	.achievement-page {
		min-height: 100vh;
		background: #f7f8fa;
		display: flex;
		flex-direction: column;
	}

	.achievement-card {
		background: #fff;
		border-radius: 20rpx;
		margin: 40rpx 32rpx 0 32rpx;
		padding: 32rpx 24rpx;
		box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, 0.04);
	}

	.card-title-row {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.card-title {
		font-size: 32rpx;
		font-weight: bold;
		margin-bottom: 32rpx;
	}

	.achievement-list {
		display: flex;
		flex-direction: column;
		gap: 0;
	}

	.achievement-item {
		display: flex;
		align-items: flex-start;
		padding: 18rpx 0 10rpx 0;
	}

	.badge-img {
		width: 72rpx;
		height: 72rpx;
		margin-right: 20rpx;
		border-radius: 50%;
		background: #f5f5f5;
		object-fit: cover;
		border: 2rpx solid #fff;
		box-shadow: 0 2rpx 8rpx 0 rgba(0, 0, 0, 0.04);
	}

	.input-area {
		margin-top: 15rpx;
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
	}

	.label-row {
		display: flex;
		align-items: center;
		margin-bottom: 6rpx;
	}

	.required {
		color: #e23d3d;
		font-size: 28rpx;
		margin-right: 4rpx;
	}

	.label {
		font-size: 28rpx;
		color: #222;
		font-weight: bold;
	}

	.input {
		width: 100%;
		border: none;
		border-bottom: 1.5rpx solid #ececec;
		font-size: 28rpx;
		background: transparent;
		padding: 8rpx 0 6rpx 0;
		margin-bottom: 2rpx;
	}

	.input-placeholder {
		color: #d2d2d2;
		font-size: 26rpx;
	}

	.divider {
		height: 1rpx;
		background: #f3f3f3;
		margin: 0 0 0 92rpx;
	}

	.bottom-btn-area {
		margin-top: auto;
		padding: 48rpx 32rpx 32rpx 32rpx;
		background: transparent;
	}

	.submit-btn {
		width: 100%;
		height: 88rpx;
		background: #0a2e6d;
		color: #fff;
		font-size: 32rpx;
		border-radius: 44rpx;
		font-weight: bold;
		letter-spacing: 2rpx;
		transition: background 0.2s;
	}

	.submit-btn.disabled {
		background: #807a7a;
		color: #fff;
	}

	.submit-btn.pending {
		background: #0a226d;
		color: #fff;
	}

	.pending-tag {
		background: #807a7a;
		color: #fff;
		font-size: 24rpx;
		border-radius: 10rpx;
		padding: 6rpx 24rpx;
		margin-left: 20rpx;
		margin-bottom: 32rpx;
	}
</style>