<template>
	<view class="complaint-list-page">
		<nav-bar title="我的评价"></nav-bar>
		<view class="list-container">
			<view class="empty-state" v-if="historyList.length === 0">
				<text>暂无投诉记录</text>
			</view>
			<view v-else class="history-card" v-for="item in historyList" :key="item.id">
				<view class="card-header">
					<text class="order-no">订单号：{{ item.orderNo }}</text>
					<text :class="['status-text', item.status === '已处理' ? 'text-green' : 'text-orange']">{{ item.status
						}}</text>
				</view>
				<view class="card-body">
					<view class="rate-row">
						<text class="label">评价评分：</text>
						<text class="stars">{{ '★'.repeat(item.rating) }}{{ '☆'.repeat(5 - item.rating) }}</text>
					</view>
					<text class="content-text">{{ item.content }}</text>
					<view class="images-preview" v-if="item.images && item.images.length">
						<image v-for="(img, idx) in item.images" :key="idx" :src="img" class="preview-img"
							mode="aspectFill"></image>
					</view>
				</view>
				<view class="card-footer">
					<text class="time">{{ item.time }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue'
import navBar from '@/components/nav-bar/index.vue'
import complaintMockData from '@/mock/complaint.json'

const historyList = ref(complaintMockData)
</script>

<style lang="scss" scoped>
.complaint-list-page {
	min-height: 100vh;
	background: #f7f8fa;
	padding-bottom: 40rpx;
}

.list-container {
	padding: 24rpx;
}

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

.history-card {
	background: #fff;
	border-radius: 24rpx;
	padding: 32rpx;
	margin-bottom: 24rpx;
}

.card-header {
	display: flex;
	justify-content: space-between;
	border-bottom: 1rpx solid #f5f5f5;
	padding-bottom: 20rpx;
	margin-bottom: 24rpx;
	font-size: 26rpx;
}

.order-no {
	color: #666;
}

.status-text {
	font-weight: bold;
}

.text-green {
	color: #4caf50;
}

.text-orange {
	color: #ff9800;
}

.rate-row {
	display: flex;
	align-items: center;
	margin-bottom: 16rpx;
}

.label {
	font-size: 26rpx;
	color: #333;
}

.stars {
	color: #f7ca3e;
	font-size: 28rpx;
	margin-left: 8rpx;
}

.content-text {
	font-size: 28rpx;
	color: #333;
	line-height: 1.5;
	margin-bottom: 20rpx;
}

.images-preview {
	display: flex;
	gap: 16rpx;
	flex-wrap: wrap;
}

.preview-img {
	width: 120rpx;
	height: 120rpx;
	border-radius: 8rpx;
	border: 1rpx solid #eee;
}

.card-footer {
	display: flex;
	justify-content: flex-end;
	border-top: 1rpx solid #f5f5f5;
	padding-top: 20rpx;
}

.time {
	font-size: 24rpx;
	color: #999;
}
</style>
