<template>
	<view class="city-page">
		<view class="city-list" v-if="recordList.length">
			<view class="city-card" v-for="item in recordList" :key="item.id">
				<view class="card-head">
					<text class="center-name">{{ item.centerName }}</text>
					<text class="status-tag" :class="statusClass(item.status)">
						{{ statusLabel(item.status) }}
					</text>
				</view>
				<text class="meta">开通原因：{{ item.reason || '暂无' }}</text>
				<text class="meta">开通时间：{{ item.openTime }}</text>
			</view>
		</view>
		<view class="empty" v-else>暂无城市记录</view>

		<view class="footer-bar">
			<view class="footer-btn" @click="goApply">开通新城市</view>
		</view>
	</view>
</template>

<script>
import { MOCK_CITY_RECORDS, CITY_STATUS_MAP } from './mock.js'

export default {
	data() {
		return {
			recordList: [],
		}
	},
	onShow() {
		this.loadList()
	},
	methods: {
		loadList() {
			this.recordList = [...MOCK_CITY_RECORDS]
		},
		statusLabel(status) {
			return CITY_STATUS_MAP[status]?.label || status
		},
		statusClass(status) {
			return CITY_STATUS_MAP[status]?.class || ''
		},
		goApply() {
			uni.navigateTo({ url: '/workbench/city/apply' })
		},
	},
}
</script>

<style lang="scss" scoped>
.city-page {
	min-height: 100vh;
	background: #f5f5f5;
	padding: 24rpx 24rpx 140rpx;
	box-sizing: border-box;
}

.city-list {
	display: flex;
	flex-direction: column;
	gap: 20rpx;
}

.city-card {
	background: #fff;
	border-radius: 12rpx;
	padding: 28rpx 32rpx;
}

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

.center-name {
	flex: 1;
	font-size: 30rpx;
	color: #333;
	font-weight: 600;
	line-height: 1.4;
	padding-right: 16rpx;
}

.status-tag {
	flex-shrink: 0;
	font-size: 22rpx;
	padding: 4rpx 12rpx;
	border-radius: 6rpx;

	&.opened {
		color: #333;
		background: #f0f0f0;
	}

	&.pending {
		color: #666;
		background: #f5f5f5;
		border: 1rpx solid #ddd;
	}

	&.rejected {
		color: #999;
		background: #fafafa;
		border: 1rpx solid #eee;
	}
}

.meta {
	display: block;
	font-size: 26rpx;
	color: #999;
	line-height: 1.6;
}

.empty {
	text-align: center;
	padding: 120rpx 0;
	font-size: 28rpx;
	color: #999;
}

.footer-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 20rpx 32rpx;
	padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
	background: #fff;
	border-top: 1rpx solid #eee;
}

.footer-btn {
	height: 88rpx;
	line-height: 88rpx;
	text-align: center;
	background: #333;
	color: #fff;
	font-size: 32rpx;
	border-radius: 12rpx;
}
</style>
