<template>
	<view class="search-list">
		<mescroll-empty v-if="projectList.length == 0 && houseList.length == 0">>
		</mescroll-empty>
		<view class="search-top" v-if="projectList.length > 0">
			<swiper class="swiper" circular :indicator-dots="true">
				<swiper-item v-for="(item,index) in projectList" :key="item.id">
					<view class="project-item" @click="$navigateTo('/pages/project/project?projectId='+item.id)">
						<view class="title">
							<view class="name">{{item.name}}</view>
						</view>
						<image class="image"
							src="https://assets.api.uizard.io/api/cdn/stream/0ba939e8-082b-42f9-a314-be3e195b3b25.png"
							mode="aspectFill">
						</image>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="house-list" v-if="houseList.length > 0">
			<house-item v-for="(item,index) in houseList" :house="item" :key="item.id"></house-item>
		</view>
	</view>
</template>

<script>
	import houseItem from "@/components/house/houseItem.vue";
	import {
		search
	} from '@/request/api/house.js'
	export default {
		data() {
			return {
				houseList: [],
				projectList: [],
				searchValue: ''
			}
		},
		onLoad(body) {
			this.searchValue = body.searchValue;
			this.init();
		},
		methods: {
			init() {
				search(this.searchValue).then(res => {
					if (res.code === 200) {
						let data = res.data;
						this.projectList = data.projectList;
						this.houseList = data.houseList;
					}
				})
			}
		},
		components: {
			houseItem
		}
	}
</script>

<style lang="scss">
	.search-list {
		.search-top {
			padding: 30rpx 30rpx 0rpx 30rpx;

			.swiper {
				border-radius: 16rpx;
				overflow: hidden;
				height: 400rpx;
			}

			.project-item {
				height: 100%;
				background: #fff;
				box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);

				.title {
					display: flex;
					padding: 20rpx 30rpx;
					align-items: center;
				}

				.name {
					font-weight: bold;
					font-size: 32rpx;
					flex: 1;
					width: 0;
					overflow: hidden;
				}

				.to {
					border: 1px solid $uni-primary;
					width: 160rpx;
					height: 60rpx;
					text-align: center;
					line-height: 60rpx;
					font-size: 24rpx;
					border-radius: 60rpx;
					color: $uni-primary;
				}

				.image {
					height: 300rpx;
				}
			}
		}

		.house-list {
			padding: 30rpx;
		}
	}
</style>