<template>
	<view class="container">
		<!-- 搜索框区域 -->
		<uv-row custom-style="margin: 10px 0px" gutter="10">
			<view class="address">
				<view class="">靖安县</view>
				<img src="../../static/index/bottom.png" />
			</view>

			<view class="search">
				<view class="add">
					<image class="img" src="../../static/index/search.png" mode="aspectFit"></image>
				</view>
				<input class="inp" type="text" v-model="keywords" placeholder="请输入关键字搜索" />
				<view class="btnSearch" @click="searchHandler()">搜索</view>
			</view>
		</uv-row>

		<!-- 名宿列表区域 -->
		<view class="body">
			<!-- 每一个名宿区域 -->
			<view class="item" v-for="item in hotelList" :key="item.id" @click="goPageDetail(item)">
				<image class="item-img" :src="item.imgUrl" mode="scaleToFill"></image>
				<view class="descrition">
					<text class="title">{{ item.hotelName }}</text>
					<text class="type">{{ item.type }}</text>
					<text class="distance">距您直线{{ item.distance }}公里</text>
					<view class="detail">
						<img class="img" src="../../static/index/hotel.png" />
						<view class="price">
							<text class="txt1">¥{{ item.price }}</text>
							<text class="txt2">起</text>
						</view>
						<!-- <text class="score">5.0分</text> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 搜索框绑定数据
			keywords: '',
			// 名宿列表数组
			hotelList: [
				{
					id: 1,
					imgUrl: '../../static/search/img.png',
					hotelName: '双溪镇抱朴小院',
					type: '舒适型',
					distance: '7.2',
					price: 180
				},
				{
					id: 2,
					imgUrl: '../../static/index/banner.png',
					hotelName: '幸福乡宿',
					type: '舒适型',
					distance: '3.2',
					price: 190
				},
				{
					id: 3,
					imgUrl: '../../static/index/banner.png',
					hotelName: '健康乡宿',
					type: '舒适型',
					distance: '8.6',
					price: 150
				},
				{
					id: 4,
					imgUrl: '../../static/search/img.png',
					hotelName: '开心乡宿',
					type: '舒适型',
					distance: '6.2',
					price: 180
				},
				{
					id: 5,
					imgUrl: '../../static/index/banner.png',
					hotelName: '快乐乡宿',
					type: '舒适型',
					distance: '3.9',
					price: 280
				}
			]
		}
	},
	onLoad() {},
	methods: {
		// 搜索按钮点击回调
		searchHandler() {
			console.log(this.keywords)
		},
		// 点击每一个名宿卡片回调
		goPageDetail(item) {
			// console.log(item)
			const info = JSON.stringify(item)
			uni.navigateTo({
				url: `/pages/detail/detail?info=${info}`
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	display: flex;
	flex-direction: column;
	width: 750rpx;
	padding: 0 30rpx;
	box-sizing: border-box;
	background-color: #ebeced;

	.address {
		display: flex;
		width: 152rpx;
		font-size: 28rpx;

		img {
			width: 48rpx;
			height: 48rpx;
		}
	}

	.search {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 538rpx;
		height: 80rpx;
		opacity: 1;
		border-radius: 70px;
		background-color: #fff;

		.add {
			display: flex;
			justify-content: center;
			align-items: center;
			margin-left: 10rpx;
			width: 60rpx;
			font-size: 50rpx;
			height: 60rpx;
			line-height: 60rpx;
			color: rgba(30, 125, 251, 1);

			.img {
				width: 30rpx;
				height: 30rpx;
			}
		}

		.inp {
			height: 60rpx;
			line-height: 60rpx;
			flex-grow: 1;
			font-size: 28rpx;
		}

		.btnSearch {
			width: 100rpx;
			text-align: center;
			margin-right: 10rpx;
			height: 60rpx;
			line-height: 60rpx;
			opacity: 1;
			font-size: 28rpx;
			font-weight: 400;
			height: 2rem;
			color: #096562;
		}
	}

	.body {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;

		.item {
			width: 335rpx;
			box-sizing: border-box;
			margin-bottom: 20rpx;

			.item-img {
				width: 100%;
				height: 223rpx;
				border-radius: 18rpx 18rpx 0 0;
				box-sizing: border-box;
			}

			.descrition {
				display: flex;
				flex-direction: column;
				width: 100%;
				border-radius: 0 0 18rpx 18rpx;
				box-sizing: border-box;
				background: rgba(255, 255, 255, 1);
				margin-top: -10rpx;

				.title {
					font-size: 28rpx;
					font-weight: 600;
					padding: 20rpx 20rpx 10rpx;
					color: rgba(0, 0, 0, 1);
				}

				.type {
					padding: 5rpx 20rpx;
					font-size: 24rpx;
					color: #a6a6a6;
				}

				.distance {
					padding: 10rpx 20rpx;
					font-size: 24rpx;
					color: #a6a6a6;
				}

				.detail {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;
					padding: 0 20rpx 20rpx 20rpx;
					color: rgba(0, 0, 0, 1);

					.img {
						width: 40rpx;
						height: 40rpx;
					}

					.price {
						.txt1 {
							font-size: 36rpx;
							font-weight: 600;
							color: rgba(255, 87, 51, 1);
						}

						.txt2 {
							font-size: 24rpx;
							font-weight: 400;
							color: #a6a6a6;
						}
					}

					.score {
						font-size: 24rpx;
						font-weight: 400;
						padding-top: 10rpx;
						color: rgba(166, 166, 166, 1);
					}
				}
			}
		}
	}
}
</style>
