<template>
	<view class="list_container">
		<view class="navBar-list">
			<view v-for="item in getNavbar()" :key="item.type" @click="handleSurround(item.type)"
				:class="['navBar-list-item', item.type == surroundIndex ? 'active' : '']">
				{{ item.name }}
			</view>
		</view>
		<view class="card-menu" v-for="item in list" :key="item.id" v-if="list.length>0" @click="gotoDetail(item)">
			<view class="img-container">
				<image :src="item.icon"></image>
				<view class="img-mask">
					<image :src="$getImg('index/icon-dw@2x.png')" mode="widthFix"></image>
					<text>距{{item.distance}}</text>
				</view>
			</view>
			<view class="detail-container">
				<view class="list-title">{{item.name}}</view>
				<view class="list-info-container">
					<view class="list-info">
						<view class="list-gradePrice">
							<view class="list-content">
								<view class="list-review">
									<text>{{item.commentNum}}</text>
									条点评
								</view>
								<view class="list-divider"></view>
								<view class="list-collection">
									<text>{{item.collectNum}}</text>
									收藏
								</view>
							</view>
						</view>
						<tags-list></tags-list>
						<view class="price-container" v-if="item.price>0">
							<text class="name">人均价</text>
							<text>
								<text class="symbol">¥</text>
								<text class="price">{{item.price}}</text>
								<text>0</text>
								<text class="qi">起</text>
							</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-empty v-if="list.length<=0" text="暂无数据" mode="list"></u-empty>
		<view class="viewMore" v-if="list.length>0">
			<text @click="lookMore">查看更多</text>
			<image :src="$getImg('ouhai_xcx/scenic/icon-%E6%9B%B4%E5%A4%9A-%E7%BB%BF.png')" mode="widthFix"></image>
		</view>
	</view>
</template>
<script>
	import tagsList from '../../components/tags-list'
	export default {
		props: {
			surround: {
				type: Array,
				default: () => []
			}
		},
		components: {
			tagsList
		},
		data() {
			return {
				surroundIndex: 1,
				list: []
			};
		},
		mounted() {
			setTimeout(() => {
				this.handleSurround(1)
			}, 500)
		},
		methods: {
			lookMore() {
				let obj = this.surround.find(item => item.type == this.surroundIndex)
				this.$emit('lookMore', obj.name)
			},
			gotoDetail(item) {
				let obj = this.surround.find(item => item.type == this.surroundIndex)
				this.$emit('gotoDetail',obj.name, item.id)
			},
			handleSurround(index) {
				this.surroundIndex = index
				let obj = this.surround.find(item => item.type == index)
				if (obj && obj.list) {
					this.list = obj.list
				}
			},
			getNavbar() {
				let list = []
				this.surround.forEach(item => {
					list.push({
						name: item.name,
						type: item.type
					})
				})
				return list
			}
		}
	};
</script>

<style lang="scss" scoped>
	.list_container {
		.navBar-list {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			align-items: center;
			margin-top: 27rpx;
			margin-bottom: 41rpx;

			.navBar-list-item {
				display: flex;
				align-items: center;
				justify-content: center;
				background: #e6e7e8;
				border-radius: 29rpx;
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 400;
				max-width: 170rpx;
				height: 58rpx;
				padding: 25rpx;
				color: #666666;
				margin-bottom: 10rpx;
			}

			.active {
				color: #ffffff;
				background: #04bb6d;
			}
		}

		.card-menu {
			width: 100%;
			height: 254rpx;
			background: #ffffff;
			padding: 25rpx 0;
			display: flex;
			border-bottom: 1rpx solid #e3e3e3;

			.img-container {
				position: relative;
				color: #ffffff;
				font-weight: 400;
				font-family: Microsoft YaHei;

				image {
					width: 194rpx;
					height: 194rpx;
					border-radius: 10rpx;
				}

				.img-mask {
					position: absolute;
					width: 194rpx;
					height: 50rpx;
					border-radius: 0rpx 0rpx 10rpx 10rpx;
					bottom: 10rpx;
					display: flex;
					align-items: center;
					padding-left: 20rpx;
					background: linear-gradient(right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
					font-size: 24rpx;

					image {
						width: 30rpx;
						height: 30rpx;
					}

					text {
						margin-left: 9rpx;
					}
				}
			}

			.detail-container {
				margin-left: 15rpx;

				.list-title {
					color: #2a2a2a;
					font-weight: bold;
					font-size: 30rpx;
					font-family: PingFang SC;
				}

				.list-info-container {
					display: flex;
					justify-content: space-between;
					margin-top: 15rpx;

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

					.list-gradePrice {
						display: flex;
						justify-content: space-between;
						align-items: center;
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						margin-bottom: 10rpx;

						.list-content {
							display: flex;
							align-items: center;

							.list-review,
							.list-collection {
								color: #666666;

								text {
									font-size: 25rpx;
									font-family: DIN;
									font-weight: 500;
									color: #999999;
									margin-right: 10rpx;
								}
							}

							.list-divider {
								width: 3rpx;
								height: 17rpx;
								background: #cccccc;
								margin-left: 15rpx;
								margin-right: 13rpx;
							}
						}
					}
				}
			}
		}

		.viewMore {
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #04BB6D;
			margin-top: 49rpx;

			image {
				width: 10rpx;
				height: 10rpx;
				margin-left: 12rpx;
			}
		}
	}
</style>
