<template>
	<view class="container">
		<!-- 顶部评分区域 -->
		<view class="header">
			<view class="header_box">
				<!-- 总评分区域 -->
				<view class="box_left">5.0</view>
				<view class="box_right">
					<!-- 位置评分区域 -->
					<view class="right_item">
						<view class="item_info">位置 4.6</view>
						<view class="item_progress">
							<progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="(4.6 / 5) * 100" />
						</view>
					</view>
					<!-- 设施评分区域 -->
					<view class="right_item">
						<view class="item_info">设施 4.6</view>
						<view class="item_progress">
							<progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="(4.6 / 5) * 100" />
						</view>
					</view>
					<!-- 服务评分区域 -->
					<view class="right_item">
						<view class="item_info">服务 4.6</view>
						<view class="item_progress">
							<progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="(4.6 / 5) * 100" />
						</view>
					</view>
					<!-- 卫生评分区域 -->
					<view class="right_item">
						<view class="item_info">卫生 4.6</view>
						<view class="item_progress">
							<progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="(4.6 / 5) * 100" />
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 分段器区域 -->
		<view class="segmented">
			<uni-segmented-control styleType="text" activeColor="#096562" :current="activeCurrent" :values="headerList" @clickItem="onClickItem" />
		</view>

		<!-- 评价列表 -->
		<view class="body">
			<!-- 每一个评价区域 -->
			<view class="body_box" v-for="item in commentList" :key="item.id">
				<!-- 用户信息区域 -->
				<view class="box_userInfo" @click="handleGoDetail(item)">
					<img mode="aspectFill" :src="item.imgUrl" />
					<view class="userInfo_msg">
						<view class="msg_name">{{ item.name }}</view>
						<view class="msg_star">
							<uni-rate readonly activeColor="#FFC300" :size="16" :value="item.rate" />
						</view>
					</view>
				</view>

				<!-- 入住时间区域 -->
				<view class="box_time">{{ item.liveTime }}入住，{{ item.subTime }}发表 | {{ item.type }}</view>

				<!-- 评价内容区域 -->
				<uv-read-more show-height="85rpx" closeText="全文" color="#096663" fontSize="24rpx" textIndent="0" :toggle="true" :shadowStyle="shadowStyle">
					<view class="box_content">
						{{ item.content }}
					</view>
				</uv-read-more>

				<!-- 图片区域 -->
				<view class="box_img">
					<img v-for="(ele, index) in item.imgList" :key="index" mode="aspectFill" :src="ele" @click="handleClickImg(item.imgList, index)" />
				</view>

				<!-- 评论按钮区域 -->
				<view class="box_comment">
					<img src="../../static/index/comment.png" />
					<view>评论（{{ item.count }}）</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 分段器分类数组
			headerList: ['全部（256）', '有图/视频（42）', '商家回复（42）'],
			// 当前激活的分段器索引
			activeCurrent: 0,
			// 评价内容区域阴影样式
			shadowStyle: {
				backgroundImage: 'none'
			},
			// 评价列表数据
			commentList: [
				{
					id: 1,
					imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
					name: '张三',
					rate: 4.6,
					liveTime: '2023-07',
					subTime: '2023-08-01',
					type: '大床房',
					content:
						'评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容的丰富的丰富评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容的丰富的丰富',
					imgList: [
						'https://img1.baidu.com/it/u=2776549017,1408541252&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
						'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201912%2F28%2F20191228151619_wxioq.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1695352503&t=cf595866bbcbd5c6a01ffe69913da7e0'
					],
					count: 12
				},
				{
					id: 2,
					imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
					name: '李四',
					rate: 4.1,
					liveTime: '2023-08',
					subTime: '2023-08-11',
					type: '双人房',
					content:
						'评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容的丰富的丰富评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容的丰富的丰富',
					imgList: [
						'https://img1.baidu.com/it/u=2776549017,1408541252&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
						'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
						'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201912%2F28%2F20191228151619_wxioq.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1695352503&t=cf595866bbcbd5c6a01ffe69913da7e0',
						'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F70a86822-e473-4ad8-9147-fad3e5cbc5ec%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1695352600&t=689d4a86e77580db11cdc227291ef6f7'
					],
					count: 8
				},
				{
					id: 3,
					imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
					name: '王八',
					rate: 3.8,
					liveTime: '2023-07',
					subTime: '2023-07-11',
					type: '普通房',
					content:
						'评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容的丰富的丰富评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容的丰富的丰富',
					imgList: [],
					count: 26
				}
			]
		}
	},
	methods: {
		// 点击每一个评价回调
		handleGoDetail(item) {
			let info = encodeURIComponent(JSON.stringify(item))
			uni.navigateTo({
				url: `/pages/appraiseDetail/appraiseDetail?info=${info}`
			})
		},
		// 切换分段器时的回调
		onClickItem(e) {
			if (this.current !== e.currentIndex) {
				this.current = e.currentIndex
			}
		},
		// 点击评价图片回调
		handleClickImg(url, index) {
			// 预览图片
			uni.previewImage({
				current: index,
				urls: url
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	background-color: #f2f3f5;

	.header {
		height: 150rpx;
		background-color: #fff;

		.header_box {
			display: flex;
			margin: 43rpx 0 36rpx;
			height: 70rpx;

			.box_left {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 140rpx;
				color: #096562;
				font-size: 60rpx;
				font-weight: 900;
				border-right: 1rpx solid #cccccc;
			}

			.box_right {
				flex: 1;
				display: flex;
				flex-wrap: wrap;
				color: #808080;
				font-size: 24rpx;

				.right_item {
					display: flex;
					align-items: center;
					width: 50%;

					.item_info {
						margin-left: 33rpx;
					}

					.item_progress {
						margin-right: 20rpx;
						padding: 0 13rpx;
						flex: 1;
					}
				}
			}
		}
	}

	.segmented {
		padding-bottom: 18rpx;
		margin-bottom: 20rpx;
		background-color: #fff;
	}

	.body {
		.body_box {
			box-sizing: border-box;
			padding: 0 20rpx;
			margin: 0 auto 20rpx;
			width: 710rpx;
			border-radius: 18rpx;
			background-color: #fff;

			.box_userInfo {
				display: flex;
				align-items: center;
				height: 115rpx;

				img {
					width: 70rpx;
					height: 70rpx;
					border-radius: 50%;
				}

				.userInfo_msg {
					margin-left: 18rpx;

					.msg_name {
						font-size: 28rpx;
					}

					.msg_star {
						margin-left: -5rpx;
						margin-top: 5rpx;
					}
				}
			}

			.box_time {
				display: flex;
				align-items: center;
				color: #a6a6a6;
				font-size: 24rpx;
			}

			.box_content {
				margin-top: 15rpx;
				font-size: 24rpx;
				color: #000;
			}

			.box_img {
				display: grid;
				grid-template-columns: 1fr 1fr 1fr;
				grid-auto-rows: auto;
				gap: 10rpx;
				margin-top: 20rpx;

				img {
					width: 216rpx;
					height: 216rpx;
					border-radius: 20rpx;
				}
			}

			.box_comment {
				display: flex;
				justify-content: flex-end;
				align-items: center;
				padding: 20rpx 0 30rpx;
				font-size: 24rpx;

				img {
					margin-right: 12rpx;
					width: 25rpx;
					height: 22rpx;
				}
			}
		}
	}
}
</style>
