This commit is contained in:
A1300399510
2023-07-17 15:02:20 +08:00
parent 6fb705bde1
commit 983571d5c5
4 changed files with 457 additions and 10 deletions

View File

@@ -0,0 +1,433 @@
<template>
<div class="dis-f jus-x al-item" style="position: relative;z-index: 333;">
<div class="body-maxWidth">
<div class="s-w-100 seach-box-bg">
<div class="seach-box">
<div class="top-seach dis-f al-item">
<div style="position: absolute;left: -8px;top: 20px;">
<div class="location-box dis-f jus-x al-item">
<img src="../../assets/homeImage/addressImg.png" class="img" alt="">
香港
</div>
<div class="triangle"></div>
</div>
<div class="dis-f al-item pos-r">
<el-input class="search-input" v-model="seachValue" placeholder="搜索房源或输入房源ID"
@keyup.enter='seachList' @blur="setHistoryShow" @focus="setHistoryShow"
style="height:48px;width:460px;"></el-input>
<div class="seach-btn dis-f al-item jus-x" @click="seachList">
<img src="../../assets/homeImage/seachImg.svg" class="img" alt="">
搜索
</div>
<div class="seach-hiosory-box" :class="{ 'seach-history-h': historyShow }">
<div class="seach-history-info">
<div>
<div class="title">
历史搜索
</div>
<div class="info-box">
<div v-for="(item, i) in historyArr.data" :key="i" class="btn">
{{ item }}
</div>
</div>
</div>
<div style="margin-top:30px;">
<div class="title">
热门推荐
</div>
<div class="info-box">
<div v-for="(item, i) in hotArr.data" :key="i" class="btn">
{{ item }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tool-btn dis-f jus-x al-item add-btn">
<img src="../../assets/homeImage/addBtn.png" class="img" alt="">
发布房源
</div>
<div class="tool-btn consult-btn flexcenter">
<img class="consult-icon" src="@/assets/img/publicImage/consult-icon.png">
咨询小助手
</div>
</div>
<!-- 展示的 展开和隐藏按钮 -->
<div class="screen-btn flexcenter">
<b>筛选</b>
<div class="screen-btn-text" style="margin-left:0;">学校附近</div> | <div class="screen-btn-text">品牌
</div> | <div class="screen-btn-text">租金</div> | <div class="screen-btn-text">房型</div> | <div
class="screen-btn-text">楼型</div>
<img class="triangle" src="@/assets/img/publicImage/triangle-black.svg" />
</div>
<div class="screen-footer flexacenter">
<div class="quantity flexacenter">
<b class="b">43</b> 个品牌公寓
</div>
<div class="sort">最新发布</div>
</div>
<!-- <div class="seach-info-box dis-f" v-if="routePath === '/'"> -->
<!-- <seachInfo title="学校附近" :btn="seachSchoolBtn.data" seachType="1" v-if="seachSchoolBtn.data.length">
</seachInfo>
<seachInfo title="合租" seachType="2" :btn="hireType.data" v-if="hireType.data.length"></seachInfo>
<seachInfo title="区域找房" seachType="3" style="margin-top:30px;" :btn="seachArea.data"
v-if="seachArea.data.length"></seachInfo>
<seachInfo title="整租" seachType="2" style="margin-top:30px;" :btn="allHireType.data"
v-if="allHireType.data.length"></seachInfo> -->
<!-- </div> -->
<!-- -->
<!-- <div
v-if="routePath === '/personHousing' || routePath === '/intermediaryHousing' || routePath === '/needHousing'" :count="counti">
<selectTabBox></selectTabBox>
{{ counti }}
</div> -->
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, watchEffect, reactive, defineProps } from 'vue';
import seachInfo from '../indexSeachInfo/indexSeachInfo.vue';
import selectTabBox from "../selectTabBox/selectTabBox.vue";
import { useRoute } from 'vue-router';
import store from '../../store/index';
import api from "../../utils/api";
const props = defineProps({
count: {
type: Number,
default: 0
}
})
let counti = ref(0)
//搜索框
let seachValue = ref('')
let historyShow = ref(false);
let setHistoryShow = () => {
historyShow.value = !historyShow.value
}
let seachSchoolBtn = reactive({ data: [] });//学校地区
let hireType = {};//整租
let allHireType = {};//合租
let seachArea = {};//区域找房
let historyArr = reactive({ data: [] })//历史查找记录
let hotArr = reactive({ data: [] })
//获取区域下列数据
let getLocationData = (data) => {
for (let item in data) {
if (!seachArea.data[item.substring(0, 1) - 1].data) seachArea.data[item.substring(0, 1) - 1].data = []
if (item.length > 1) {
seachArea.data[item.substring(0, 1) - 1].data.push({
title: data[item],
id: item
})
}
}
}
//监听路由
const route = useRoute()
let routePath = ref('')
console.log("path", route.path);
routePath.value = route.path
watchEffect(() => {
seachSchoolBtn.data = store.state.seachTypeData[0] ? store.state.seachTypeData[0].where : []
hireType.data = store.state.seachTypeData[2] ? store.state.seachTypeData[2].where[0].data : []
allHireType.data = store.state.seachTypeData[2] ? store.state.seachTypeData[2].where[1].data : []
seachArea.data = store.state.seachTypeData[1] ? store.state.seachTypeData[1].where : []
if (seachArea.data.length > 0 && !seachArea.data[0].data) getLocationData(store.state.indexData.config.location)
hotArr.data = store.state.indexData.hotSearcheWords
counti.value = props.count
})
//获取历史搜索记录
historyArr.data = JSON.parse(localStorage.getItem('historyArr')) || []
//搜索数据
let seachList = () => {
localStorage.setItem('historyArr', JSON.stringify(historyArr.data));
}
defineExpose({
historyShow,
seachValue
})
</script>
<style scoped lang="less">
.dis-f {
display: flex;
}
.jus-x {
justify-content: center;
}
.al-item {
align-items: center;
}
.pos-r {
position: relative;
}
.body-maxWidth {
width: 1200px;
min-width: 1200px;
}
.s-w-100 {
width: 100%;
}
.jus-bet {
justify-content: space-between;
}
.seach-box-bg {
background: #d7d7d7 !important;
background: inherit;
border: none;
border-radius: 16px;
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
font-size: 14px;
margin-top: 20px;
.seach-box {
background: #FFFFFF;
transform: translate(0, 3px);
border-radius: 16px;
.top-seach {
padding: 20px;
position: relative;
justify-content: end;
border-bottom: 1px solid #ebebeb;
.intermediary-btn {
background: rgba(241, 245, 247, 1);
}
.seach-history-h {
max-height: 375px !important;
transition: max-height 0.5s ease-in-out;
}
.seach-hiosory-box {
position: absolute;
top: 55px;
z-index: 99;
max-height: 0;
overflow: hidden;
}
.seach-history-info {
width: 560px;
background: inherit;
background-color: rgba(255, 255, 255, 1);
box-sizing: border-box;
border-width: 1px;
border-style: solid;
border-color: rgba(235, 235, 235, 1);
border-radius: 16px;
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.0784313725490196);
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.0784313725490196);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.0784313725490196);
padding: 20px 25px;
.title {
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif;
font-weight: 650;
font-style: normal;
font-size: 16px;
color: #000000;
}
.info-box {
display: flex;
flex-wrap: wrap;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
font-weight: 400;
font-style: normal;
font-size: 15px;
color: #555555;
text-align: left;
.btn {
margin: 20px 30px 0 0;
cursor: pointer;
}
}
}
.location-box {
width: 80px;
height: 40px;
background: inherit;
background-color: rgba(68, 68, 68, 1);
border: none;
border-radius: 8px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.117647058823529);
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif;
font-weight: 650;
font-style: normal;
font-size: 14px;
color: #FFFFFF;
line-height: 48px;
position: absolute;
z-index: 666;
}
.triangle {
border: 7px solid;
border-color: transparent #000 transparent transparent;
width: 0;
height: 0;
position: absolute;
bottom: -47px;
left: -7px;
}
.seach-btn {
width: 100px;
height: 48px;
background-color: rgba(98, 177, 255, 1);
border-radius: 0 8px 8px 0;
line-height: 48px;
cursor: pointer;
color: #000;
font-size: 16px;
font-weight: 400;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
}
.img {
width: 20px;
height: 20px;
object-fit: contain;
margin-right: 5px;
}
.tool-btn {
width: 160px;
height: 48px;
border-radius: 8px;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
font-weight: 400;
font-style: normal;
font-size: 16px;
color: #000000;
line-height: 48px;
cursor: pointer;
&.add-btn {
background: rgba(253, 218, 85, 1);
margin-left: 20px;
}
&.consult-btn {
background: rgba(144, 216, 72, 1);
margin-left: 20px;
.consult-icon {
width: 22px;
height: 22px;
margin-right: 5px;
}
}
}
}
.seach-info-box {
padding: 20px 10px;
justify-content: space-around;
flex-wrap: wrap;
}
}
}
.search-input {
/deep/ .el-input__wrapper {
border-radius: 8px 0 0 8px;
box-shadow: none;
background-color: rgba(246, 246, 246, 1);
border: 1px solid rgba(235, 235, 235, 1);
border-right: none;
.el-input__inner {
&::placeholder {
color: #7f7f7f;
}
}
}
}
.screen-btn {
font-size: 15px;
color: #d7d7d7;
line-height: 21px;
height: 60px;
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif;
background-color: rgba(246, 246, 246, 1);
b {
color: #000000;
}
.screen-btn-text {
color: #555555;
margin: 0 10px;
}
.triangle {
width: 10px;
height: 6px;
margin-left: 10px;
}
}
.screen-footer {
justify-content: space-between;
.quantity {
color: #555555;
font-size: 15px;
padding: 0 16px;
height: 72px;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
.b {
font-weight: 700;
color: #000000;
margin: 0 5px;
}
}
}
</style>