修改搜索失败还能下拉刷新

This commit is contained in:
A1300399510
2023-12-08 15:21:16 +08:00
parent 86021d3066
commit 51c7932205
9 changed files with 298 additions and 337 deletions

1
dist/css/seachPage.9ad6c008.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/index.html vendored
View File

@@ -1,4 +1,4 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/favicon.ico"><title>港校租房</title><script defer="defer" src="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/js/chunk-vendors.e0e9f2f6.js"></script><script defer="defer" src="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/js/app.088fb767.js"></script><link href="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/css/chunk-vendors.7885d77e.css" rel="stylesheet"><link href="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/css/app.872c0487.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zufang doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><script src="https://app.gter.net/bottom?tpl=header&menukey=fang"></script><div id="app"></div><div style="display:none;"><script src="//v1.cnzz.com/z_stat.php?id=1281224882&amp;web_id=1281224882"></script><script>var _hmt = _hmt || []; <!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/favicon.ico"><title>港校租房</title><script defer="defer" src="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/js/chunk-vendors.e0e9f2f6.js"></script><script defer="defer" src="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/js/app.d772b454.js"></script><link href="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/css/chunk-vendors.7885d77e.css" rel="stylesheet"><link href="https://ansnid.oss-cn-shenzhen.aliyuncs.com/fang/css/app.872c0487.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zufang doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><script src="https://app.gter.net/bottom?tpl=header&menukey=fang"></script><div id="app"></div><div style="display:none;"><script src="//v1.cnzz.com/z_stat.php?id=1281224882&amp;web_id=1281224882"></script><script>var _hmt = _hmt || [];
(function () { (function () {
var hm = document.createElement("script"); var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?4bd66cbe45a640b607fe46c48f658746"; hm.src = "//hm.baidu.com/hm.js?4bd66cbe45a640b607fe46c48f658746";

File diff suppressed because one or more lines are too long

1
dist/js/app.d772b454.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/js/seachPage.d0e77f06.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,11 @@
<template> <template>
<div class="dis-f jus-x"> <div class="dis-f jus-x">
<div class="body-maxWidth "> <div class="body-maxWidth">
<div class="input-box dis-f al-item jus-bet body-maxWidth"> <div class="input-box dis-f al-item jus-bet body-maxWidth">
<div class="dis-f al-item"> <div class="dis-f al-item">
<el-input v-model="seachVal" class="input-s" placeholder="搜索房源或输入房源ID" @keyup.enter='seachList'> <el-input v-model="seachVal" class="input-s" placeholder="搜索房源或输入房源ID" @keyup.enter="seachList">
<template #suffix> <template #suffix>
<img src="../../assets/homeImage/seachIcon.svg" class="icon" alt="" @click="seachList"> <img src="../../assets/homeImage/seachIcon.svg" class="icon" alt="" @click="seachList" />
</template> </template>
</el-input> </el-input>
<!-- 地图找房的入口 暂时隐藏 --> <!-- 地图找房的入口 暂时隐藏 -->
@@ -15,37 +15,31 @@
</div> </div>
<div class="dis-f al-item"> <div class="dis-f al-item">
<div class="tool-btn dis-f al-item jus-x" @click="gouser('fav')"> <div class="tool-btn dis-f al-item jus-x" @click="gouser('fav')">
<img src="../../assets/homeImage/Mycollect.png" class="img" alt=""> <img src="../../assets/homeImage/Mycollect.png" class="img" alt="" />
我的收藏 我的收藏
</div> </div>
<div class="tool-btn dis-f al-item jus-x mg-l-10" @click="gouser('publish')"> <div class="tool-btn dis-f al-item jus-x mg-l-10" @click="gouser('publish')">
<img src="../../assets/homeImage/informationO.png" class="img" alt=""> <img src="../../assets/homeImage/informationO.png" class="img" alt="" />
我的发布 我的发布
</div> </div>
</div> </div>
</div> </div>
<div class="seach-info-box body-maxWidth"> <div class="seach-info-box body-maxWidth">
<div class="top-box dis-f al-item"> <div class="top-box dis-f al-item">
<div class="top-btn dis-f jus-x al-item first" v-if="!isNeedHousing" @click="selectPage('person')" <div class="top-btn dis-f jus-x al-item first" v-if="!isNeedHousing" @click="selectPage('person')" :class="{'select-top-btn-bg': tabType === 'person'}">
:class="{ 'select-top-btn-bg': tabType === 'person' }"> <div class="top-btn" :class="[tabType === 'person' ? 'select-top-btn' : 'first-no-select']" v-show="tabType === 'person'">
<div class="top-btn" :class="[tabType === 'person' ? 'select-top-btn' : 'first-no-select']" 个人房源 {{ seachKey.key && seachKey.key.personal && seachKey.key.personal.count }}
v-show="tabType === 'person'">
个人房源 {{ seachKey.key && seachKey.key.personal && seachKey.key.personal.count }}
<div class="dis-f jus-x btm-line-mg"> <div class="dis-f jus-x btm-line-mg">
<div class="btm-line"></div> <div class="btm-line"></div>
</div> </div>
</div> </div>
个人房源 {{ seachKey.key && seachKey.key.personal && seachKey.key.personal.count }} 个人房源 {{ seachKey.key && seachKey.key.personal && seachKey.key.personal.count }}
<div class="second-select" v-show="tabType === 'intermediary'"> <div class="second-select" v-show="tabType === 'intermediary'">
<div class="box"> <div class="box"></div>
</div>
</div> </div>
</div> </div>
<div class="top-btn dis-f jus-x al-item first" v-if="isNeedHousing" <div class="top-btn dis-f jus-x al-item first" v-if="isNeedHousing" :class="{'select-top-btn-bg': tabType === 'need'}">
:class="{ 'select-top-btn-bg': tabType === 'need' }"> <div class="top-btn" :class="[tabType === 'need' ? 'select-top-btn' : 'first-no-select']" v-show="tabType === 'need'">
<div class="top-btn" :class="[tabType === 'need' ? 'select-top-btn' : 'first-no-select']"
v-show="tabType === 'need'">
求房源 求房源
<div class="dis-f jus-x btm-line-mg"> <div class="dis-f jus-x btm-line-mg">
<div class="btm-line"></div> <div class="btm-line"></div>
@@ -53,28 +47,19 @@
</div> </div>
求房源{{ tabType }} 求房源{{ tabType }}
</div> </div>
<div class="top-btn dis-f jus-x al-item second" v-if="isNeedHousing" @click="selectPage('intermediary')" <div class="top-btn dis-f jus-x al-item second" v-if="isNeedHousing" @click="selectPage('intermediary')" :class="{'select-top-btn-bg': tabType === 'intermediary'}">
:class="{ 'select-top-btn-bg': tabType === 'intermediary' }">
<div class="first-select"> <div class="first-select">
<div class="box"> <div class="box"></div>
</div>
</div> </div>
</div> </div>
<div class="top-btn dis-f jus-x al-item second" v-if="!isNeedHousing && houseingPageType != 6" <div class="top-btn dis-f jus-x al-item second" v-if="!isNeedHousing && houseingPageType != 6" @click="selectPage('intermediary')" :class="{'select-top-btn-bg': tabType === 'intermediary'}">
@click="selectPage('intermediary')" :class="{ 'select-top-btn-bg': tabType === 'intermediary' }">
<div class="first-select" v-show="tabType === 'person'"> <div class="first-select" v-show="tabType === 'person'">
<div class="box"> <div class="box"></div>
</div>
</div> </div>
<div class="third-select" v-show="tabType === 'apartment'"> <div class="third-select" v-show="tabType === 'apartment'">
<div class="box"> <div class="box"></div>
</div>
</div> </div>
<div class="top-btn" :class="[tabType === 'intermediary' ? 'select-top-btn' : 'first-no-select']" <div class="top-btn" :class="[tabType === 'intermediary' ? 'select-top-btn' : 'first-no-select']" v-show="tabType === 'intermediary'">
v-show="tabType === 'intermediary'">
中介房源 {{ seachKey.key && seachKey.key.intermediary && seachKey.key.intermediary.count }} 中介房源 {{ seachKey.key && seachKey.key.intermediary && seachKey.key.intermediary.count }}
<div class="dis-f jus-x btm-line-mg"> <div class="dis-f jus-x btm-line-mg">
<div class="btm-line"></div> <div class="btm-line"></div>
@@ -82,16 +67,11 @@
</div> </div>
中介房源 {{ seachKey.key && seachKey.key.intermediary && seachKey.key.intermediary.count }} 中介房源 {{ seachKey.key && seachKey.key.intermediary && seachKey.key.intermediary.count }}
</div> </div>
<div class="top-btn dis-f jus-x al-item third" @click="selectPage('apartment')" <div class="top-btn dis-f jus-x al-item third" @click="selectPage('apartment')" :class="{'select-top-btn-bg': tabType === 'apartment'}" v-if="!isNeedHousing && houseingPageType != 6">
:class="{ 'select-top-btn-bg': tabType === 'apartment' }"
v-if="!isNeedHousing && houseingPageType != 6">
<div class="second-select-third-box" v-show="tabType === 'intermediary'"> <div class="second-select-third-box" v-show="tabType === 'intermediary'">
<div class="box"> <div class="box"></div>
</div>
</div> </div>
<div class="top-btn" :class="[tabType === 'apartment' ? 'select-top-btn' : 'first-no-select']" <div class="top-btn" :class="[tabType === 'apartment' ? 'select-top-btn' : 'first-no-select']" v-show="tabType === 'apartment'">
v-show="tabType === 'apartment'">
品牌公寓 {{ seachKey.key && seachKey.key.studentapartment && seachKey.key.studentapartment.count }} 品牌公寓 {{ seachKey.key && seachKey.key.studentapartment && seachKey.key.studentapartment.count }}
<div class="dis-f jus-x btm-line-mg"> <div class="dis-f jus-x btm-line-mg">
<div class="btm-line"></div> <div class="btm-line"></div>
@@ -101,76 +81,56 @@
</div> </div>
<div class="top-btn dis-f jus-x al-item four" v-if="!isNeedHousing"> <div class="top-btn dis-f jus-x al-item four" v-if="!isNeedHousing">
<div class="second-select-third-box" v-show="tabType === 'apartment'"> <div class="second-select-third-box" v-show="tabType === 'apartment'">
<div class="box"> <div class="box"></div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div v-show="tabType === 'apartment'" :class="{ 'show-box-pd': !showSelectModule }"> <div v-show="tabType === 'apartment'" :class="{'show-box-pd': !showSelectModule}">
<apartmentSelect @handleTransfer="setSeachConditions" :seachPage="false" ref="apartmentSelectInfo"> <apartmentSelect @handleTransfer="setSeachConditions" :seachPage="false" ref="apartmentSelectInfo"> </apartmentSelect>
</apartmentSelect>
</div> </div>
<div class="seach-select-info" v-show="tabType !== 'apartment'"> <div class="seach-select-info" v-show="tabType !== 'apartment'">
<div class="select-box" :class="{ 'seach-select-h': showSelectModule }" <div class="select-box" :class="{'seach-select-h': showSelectModule}" :style="{overflow: showSelectModule ? 'visible' : 'hidden'}">
:style="{ 'overflow': showSelectModule ? 'visible' : 'hidden' }"> <selectTabBox :setSeachCondition="setSeachConditions" :setLocation="setLocation" ref="selectTabBoxInfo"></selectTabBox>
<selectTabBox :setSeachCondition="setSeachConditions" :setLocation="setLocation"
ref="selectTabBoxInfo"></selectTabBox>
</div> </div>
<div :class="{ 'show-box-pd': !showSelectModule }"> <div :class="{'show-box-pd': !showSelectModule}">
<div class="box" :class="{ 'show-box': showSelectModule }"> <div class="box" :class="{'show-box': showSelectModule}">
<div class="dis-f jus-x al-item" :style="{ 'height': !showSelectModule ? '60px' : '40px' }" <div class="dis-f jus-x al-item" :style="{height: !showSelectModule ? '60px' : '40px'}" @click="showSelectModule = !showSelectModule">
@click="showSelectModule = !showSelectModule">
<div class="dis-f al-item"> <div class="dis-f al-item">
<span v-show="showSelectModule">收起筛选条件</span> <span v-show="showSelectModule">收起筛选条件</span>
<span class="text-tps" v-show="!showSelectModule">筛选</span> <span <span class="text-tps" v-show="!showSelectModule">筛选</span> <span v-show="!showSelectModule">&nbsp:&nbsp</span>
v-show="!showSelectModule">&nbsp:&nbsp</span>
<div v-show="!showSelectModule"> <div v-show="!showSelectModule">
<span v-for="(item, i) in typeText" :key="item"> <span v-for="(item, i) in typeText" :key="item">
{{ item }} {{ item }}
<span v-show="i !== typeText.length - 1" class="text-icon">&nbsp|&nbsp </span> <span v-show="i !== typeText.length - 1" class="text-icon">&nbsp|&nbsp </span>
</span> </span>
</div> </div>
<img src="../../assets/homeImage/listMore.svg" class="icon-img" <img src="../../assets/homeImage/listMore.svg" class="icon-img" :class="{'down-icon': showSelectModule}" alt="" />
:class="{ 'down-icon': showSelectModule }" alt="">
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div> <div>
<div class="btm-list" :class="{ 'apartment-btm': tabType === 'apartment' }"> <div class="btm-list" :class="{'apartment-btm': tabType === 'apartment'}">
<div class="dis-f al-item"> <div class="dis-f al-item">
<span class="count">{{ count || 0 }}</span> <span class="count">{{ count || 0 }}</span
{{ tabType === 'person' ? > {{ tabType === "person" ? "个人房源" : tabType === "intermediary" ? "中介房源" : tabType === "apartment" ? "品牌公寓" : "" }} <span v-show="selectTabCheck.title && selectTabCheck.id"> &nbsp | &nbsp</span>
'个人房源' : tabType === 'intermediary' ?
'中介房源' : tabType === 'apartment' ?
'品牌公寓' : '' }} <span v-show="selectTabCheck.title && selectTabCheck.id">
&nbsp
|
&nbsp</span>
<div class="dis-f al-item"> <div class="dis-f al-item">
<div v-show="selectTabCheck.id && selectTabCheck.title">{{ selectTabCheck.title }}:</div> <div v-show="selectTabCheck.id && selectTabCheck.title">{{ selectTabCheck.title }}:</div>
<div v-for="(item, i) in selectData.data" :key="i" class="btm-btn"> <div v-for="(item, i) in selectData.data" :key="i" class="btm-btn">
{{ item.title }} {{ item.title }}
<img src="../../assets/homeImage/closeIcon.svg" @click="deleteSelect(i)" class="img" <img src="../../assets/homeImage/closeIcon.svg" @click="deleteSelect(i)" class="img" alt="" />
alt="">
</div> </div>
</div> </div>
</div> </div>
<span class="dis-f al-item sort-text" v-show="tabType !== 'apartment'"> <span class="dis-f al-item sort-text" v-show="tabType !== 'apartment'">
<el-dropdown trigger="click" @command="listSortCheck"> <el-dropdown trigger="click" @command="listSortCheck">
<span class="dis-f al-item sort-text"> <span class="dis-f al-item sort-text"> {{ listSort.check }}<img class="img" src="../../assets/homeImage/sortIcon.png" alt="" /> </span>
{{ listSort.check }}<img class="img" src="../../assets/homeImage/sortIcon.png" alt="">
</span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="pd-10 el-dropdown-menu"> <el-dropdown-menu class="pd-10 el-dropdown-menu">
<el-dropdown-item v-for="(items, j) in listSort.type" :key="j" :command="j"> <el-dropdown-item v-for="(items, j) in listSort.type" :key="j" :command="j">
<div class="dropdown-text" <div class="dropdown-text" :class="{'dropdown-check-text': listSort.checkType === items.type}">
:class="{ 'dropdown-check-text': listSort.checkType === items.type }" {{ items.title }}
>{{
items.title
}}
<div class="type-icon" v-show="listSort.checkType === items.type"></div> <div class="type-icon" v-show="listSort.checkType === items.type"></div>
</div> </div>
</el-dropdown-item> </el-dropdown-item>
@@ -185,265 +145,273 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { reactive, ref, shallowReactive, defineProps, watchEffect, defineExpose } from 'vue' import {reactive, ref, inject, shallowReactive, defineProps, watchEffect, defineExpose} from "vue"
import selectTabBox from "../selectTabBox/selectTabBox.vue"; import selectTabBox from "../selectTabBox/selectTabBox.vue"
import apartmentSelect from '../apartment/seachModule.vue' import apartmentSelect from "../apartment/seachModule.vue"
import store from '../../store/index'; import store from "../../store/index"
import api from '@/utils/api'; import api from "@/utils/api"
import { useRoute, useRouter } from 'vue-router'; import {useRoute, useRouter} from "vue-router"
import { ElMessage } from 'element-plus' import {ElMessage} from "element-plus"
//路由 //路由
const route = useRouter() const route = useRouter()
const props = defineProps({ const props = defineProps({
getDataList: { getDataList: {
type: Function type: Function,
}, },
count: { count: {
type: Number type: Number,
} },
isNoGetData: Boolean,
}) })
//选项卡 //选项卡
let tabType = ref('person') let tabType = ref("person")
let selectTabBoxInfo = ref(null)//个人/中介筛选实例 let selectTabBoxInfo = ref(null) //个人/中介筛选实例
let apartmentSelectInfo = ref(null)//公寓筛选实例 let apartmentSelectInfo = ref(null) //公寓筛选实例
//设置请求数据 //设置请求数据
let selectPage = (type) => { let selectPage = type => {
if (type === seachAllType['tabType'] || houseingPageType == 6) return if (type === seachAllType["tabType"] || houseingPageType == 6) return
if (type === 'apartment') { if (type === "apartment") {
selectTabBoxInfo.value.cleanSelect()//清空筛选数据 selectTabBoxInfo.value.cleanSelect() //清空筛选数据
} else { } else {
apartmentSelectInfo.value.cleanSelect && apartmentSelectInfo.value.cleanSelect() apartmentSelectInfo.value.cleanSelect && apartmentSelectInfo.value.cleanSelect()
} }
//清空数据 //清空数据
if (type === 'apartment') if (type === "apartment")
seachAllType = reactive({ seachAllType = reactive({
keyword: seachAllType['keyword'], keyword: seachAllType["keyword"],
location: [], location: [],
intermediary: '' intermediary: "",
}) })
tabType.value = type tabType.value = type
seachAllType['tabType'] = type seachAllType["tabType"] = type
seachAllType['searchid'] = setPageKey().searchid seachAllType["searchid"] = setPageKey().searchid
//根据类型初始化筛选参数 //根据类型初始化筛选参数
if (type === 'person') { if (type === "person") {
seachAllType['intermediary'] = 0 seachAllType["intermediary"] = 0
seachAllType['isintermediary'] = 0 seachAllType["isintermediary"] = 0
houseingPageType = '0' houseingPageType = "0"
sessionStorage.setItem('houseingPageType', 0) sessionStorage.setItem("houseingPageType", 0)
selectTabBoxInfo.value.routerQuerySet() selectTabBoxInfo.value.routerQuerySet()
} else if (type === 'intermediary') { } else if (type === "intermediary") {
seachAllType['intermediary'] = 1 seachAllType["intermediary"] = 1
seachAllType['isverified'] = 0 seachAllType["isverified"] = 0
houseingPageType = '1' houseingPageType = "1"
sessionStorage.setItem('houseingPageType', 1) sessionStorage.setItem("houseingPageType", 1)
// route.currentRoute.value.query.houseingPageType='1' // route.currentRoute.value.query.houseingPageType='1'
selectTabBoxInfo.value.routerQuerySet() selectTabBoxInfo.value.routerQuerySet()
} else { } else {
seachAllType['intermediary'] = '' seachAllType["intermediary"] = ""
seachAllType['isverified'] = 0 seachAllType["isverified"] = 0
seachAllType['isintermediary'] = 0 seachAllType["isintermediary"] = 0
} }
//初始化搜索框输入内容 //初始化搜索框输入内容
if (tabType.value != 'need') { if (tabType.value != "need") {
setSeachVal() setSeachVal()
} }
if ((seachVal.value && !setPageKey().searchid)) return if (seachVal.value && !setPageKey().searchid) return
let seachObj=setSeachId() let seachObj = setSeachId()
getDataList(seachAllType,seachObj.count==0?false:true) getDataList(seachAllType, seachObj.count == 0 ? false : true)
} }
let getDataList = props.getDataList let getDataList = props.getDataList
//搜索数据 //搜索数据
let seachAllType = reactive({ let seachAllType = reactive({
keyword: '', keyword: "",
location: [], location: [],
searchid: '', searchid: "",
intermediary: 0 intermediary: 0,
}) })
//搜索内容 //搜索内容
let seachVal = ref('') let seachVal = ref("")
let isNeedHousing = ref(false) let isNeedHousing = ref(false)
seachVal.value = route.currentRoute.value.query.keyword && route.currentRoute.value.query.keyword.replace(/\s/g, "") seachVal.value = route.currentRoute.value.query.keyword && route.currentRoute.value.query.keyword.replace(/\s/g, "")
//判断是否从求房源页面跳转 //判断是否从求房源页面跳转
isNeedHousing.value = route.currentRoute.value.query.isNeedHousing === 'true' isNeedHousing.value = route.currentRoute.value.query.isNeedHousing === "true"
//判断当前是什么页面 //判断当前是什么页面
let houseingPageType = sessionStorage.getItem('houseingPageType') let houseingPageType = sessionStorage.getItem("houseingPageType")
let type = houseingPageType === '0' ? 'person' : houseingPageType === '1' ? 'intermediary' : houseingPageType === '6' ? 'need' : 'apartment' let type = houseingPageType === "0" ? "person" : houseingPageType === "1" ? "intermediary" : houseingPageType === "6" ? "need" : "apartment"
tabType.value = type tabType.value = type
if(tabType.value=='apartment'){ if (tabType.value == "apartment") {
seachAllType['intermediary'] = '' seachAllType["intermediary"] = ""
seachAllType['tabType']='apartment' seachAllType["tabType"] = "apartment"
} }
//页面判断-抛出方法 //页面判断-抛出方法
let checkPageType = () => { let checkPageType = () => {
// houseingPageType 0个人 1中介 6求房源 // houseingPageType 0个人 1中介 6求房源
let type = houseingPageType === '0' ? 'person' : houseingPageType === '1' ? 'intermediary' : houseingPageType === '6' ? 'need' : 'apartment' let type = houseingPageType === "0" ? "person" : houseingPageType === "1" ? "intermediary" : houseingPageType === "6" ? "need" : "apartment"
tabType.value = type tabType.value = type
seachAllType['tabType'] = type seachAllType["tabType"] = type
if (type === 'person') { if (type === "person") {
seachAllType['intermediary'] = 0 seachAllType["intermediary"] = 0
} else if (type === 'intermediary') { } else if (type === "intermediary") {
seachAllType['intermediary'] = 1 seachAllType["intermediary"] = 1
} else if (type === 'need') { } else if (type === "need") {
seachAllType['intermediary'] = 6 seachAllType["intermediary"] = 6
seachAllType['keyword'] = seachVal.value seachAllType["keyword"] = seachVal.value
} else { } else {
seachAllType['intermediary'] = '' seachAllType["intermediary"] = ""
} }
let seachObj=setSeachId() let seachObj = setSeachId()
getDataList(seachAllType,seachObj.count==0?false:true) getDataList(seachAllType, seachObj.count == 0 ? false : true)
} }
//搜索key //搜索key
let seachKey = reactive({ let seachKey = reactive({
key: { key: {
personal: {}, personal: {},
intermediary: {}, intermediary: {},
studentapartment: {} studentapartment: {},
} },
}) })
let seachInfoData=shallowReactive({ let seachInfoData = shallowReactive({
data:{} data: {},
}) })
//直接输入url //直接输入url
if (isNeedHousing.value) { if (isNeedHousing.value) {
tabType.value = 'need' tabType.value = "need"
seachAllType['intermediary'] = 6 seachAllType["intermediary"] = 6
} }
//切换选项重置输入框内容 //切换选项重置输入框内容
let setSeachVal = () => { let setSeachVal = () => {
seachAllType['searchid'] = setPageKey().searchid seachAllType["searchid"] = setPageKey().searchid
seachVal.value = seachKey.key.keyword seachVal.value = seachKey.key.keyword
} }
//设置点击一级区域 //设置点击一级区域
let setLocation = (type, data) => { let setLocation = (type, data) => {
seachAllType[type] = data seachAllType[type] = data
seachAllType['school'] = '' seachAllType["school"] = ""
} }
//设置搜索数据 //设置搜索数据
let setSeachConditions = (type, data) => { let setSeachConditions = (type, data) => {
if (seachAllType['tabType'] !== 'apartment') { if (seachAllType["tabType"] !== "apartment") {
if (type === 'rent') { if (type === "rent") {
seachAllType['rent_min'] = data.min seachAllType["rent_min"] = data.min
seachAllType['rent_max'] = data.max seachAllType["rent_max"] = data.max
} else if (type !== '') { } else if (type !== "") {
seachAllType[type] = data seachAllType[type] = data
} else if (type === '') { } else if (type === "") {
data.indexOf('isintermediary') !== -1 ? seachAllType['isintermediary'] = 1 : seachAllType['isintermediary'] = 0 data.indexOf("isintermediary") !== -1 ? (seachAllType["isintermediary"] = 1) : (seachAllType["isintermediary"] = 0)
data.indexOf('isverified') !== -1 ? seachAllType['isverified'] = 1 : seachAllType['isverified'] = 0 data.indexOf("isverified") !== -1 ? (seachAllType["isverified"] = 1) : (seachAllType["isverified"] = 0)
data.indexOf('iselevator') !== -1 ? seachAllType['iselevator'] = 1 : seachAllType['iselevator'] = 0 data.indexOf("iselevator") !== -1 ? (seachAllType["iselevator"] = 1) : (seachAllType["iselevator"] = 0)
data.indexOf('issunshinearea') !== -1 ? seachAllType['issunshinearea'] = 1 : seachAllType['issunshinearea'] = 0 data.indexOf("issunshinearea") !== -1 ? (seachAllType["issunshinearea"] = 1) : (seachAllType["issunshinearea"] = 0)
} }
if (type === 'school') { if (type === "school") {
seachAllType.location = [] seachAllType.location = []
} }
if (type === 'location') { if (type === "location") {
seachAllType.school = '' seachAllType.school = ""
} }
} else { } else {
seachAllType = { seachAllType = {
tabType: 'apartment', tabType: "apartment",
...type.value ...type.value,
} }
} }
if (tabType.value != 'need') { if (tabType.value != "need") {
setSeachVal() setSeachVal()
} else if (tabType.value == 'need') { } else if (tabType.value == "need") {
seachVal.value = seachAllType.keyword seachVal.value = seachAllType.keyword
} }
if (!seachAllType['tabType']) seachAllType['tabType'] = tabType.value if (!seachAllType["tabType"]) seachAllType["tabType"] = tabType.value
if (!seachVal.value) { if (!seachVal.value) {
seachAllType.searchid = '' seachAllType.searchid = ""
} }
//设置其他选项 //设置其他选项
if (seachAllType['tabType'] === 'person') { if (seachAllType["tabType"] === "person") {
seachAllType['isintermediary'] = 0 seachAllType["isintermediary"] = 0
} else if (seachAllType['tabType'] === 'intermediary') { } else if (seachAllType["tabType"] === "intermediary") {
seachAllType['isverified'] = 0 seachAllType["isverified"] = 0
} else { } else {
seachAllType['isverified'] = 0 seachAllType["isverified"] = 0
seachAllType['isintermediary'] = 0 seachAllType["isintermediary"] = 0
} }
let seachObj=setSeachId() let seachObj = setSeachId()
getDataList(seachAllType,seachObj.count==0?false:true) getDataList(seachAllType, seachObj.count == 0 ? false : true)
} }
//设置当前搜索key //设置当前搜索key
let setPageKey = () => { let setPageKey = () => {
return tabType.value === 'person' ? seachKey.key.personal : tabType.value === 'intermediary' ? seachKey.key.intermediary : tabType.value === 'apartment' ? seachKey.key.studentapartment : '' return tabType.value === "person" ? seachKey.key.personal : tabType.value === "intermediary" ? seachKey.key.intermediary : tabType.value === "apartment" ? seachKey.key.studentapartment : ""
} }
let setSeachId=()=>{ let setSeachId = () => {
return tabType.value === 'person' ? seachInfoData.data.personal : tabType.value === 'intermediary' ? seachInfoData.data.intermediary : tabType.value === 'apartment' ? seachInfoData.data.studentapartment : '' return tabType.value === "person" ? seachInfoData.data.personal : tabType.value === "intermediary" ? seachInfoData.data.intermediary : tabType.value === "apartment" ? seachInfoData.data.studentapartment : ""
} }
let isDownGetData = inject("isDownGetData")
//搜索初始化 //搜索初始化
let searchInit = (data) => { let searchInit = data => {
api.search({ keyword: data }).then(res => { api.search({keyword: data})
if (res.code === 200) { .then(res => {
seachKey.key = res.data if (res.code === 200) {
seachInfoData.data=JSON.parse(JSON.stringify(res.data)) seachKey.key = res.data
let seachObj=checkSearckInit(setSeachId()) seachInfoData.data = JSON.parse(JSON.stringify(res.data))
seachAllType.searchid = seachObj.searchid let seachObj = checkSearckInit(setSeachId())
seachAllType['intermediary']=tabType.value==='person'?0:tabType.value==='intermediary'?1:tabType.value==='need'?6:'' seachAllType.searchid = seachObj.searchid
seachAllType['tabType']=tabType.value seachAllType["intermediary"] = tabType.value === "person" ? 0 : tabType.value === "intermediary" ? 1 : tabType.value === "need" ? 6 : ""
getDataList(seachAllType,seachObj.count==0?false:true) seachAllType["tabType"] = tabType.value
} else { getDataList(seachAllType, seachObj.count == 0 ? false : true)
ElMessage({ isDownGetData.value = true
message: res.message, } else {
center: true, isDownGetData.value = false
}) ElMessage({
} message: res.message,
}) center: true,
})
}
})
.catch(err => {
console.log("1111")
})
} }
//判断搜索数据数量 //判断搜索数据数量
let checkSearckInit=(data)=>{ let checkSearckInit = data => {
if(data.count) return data if (data.count) return data
let obj={} let obj = {}
if(seachInfoData.data.personal.count>0){ if (seachInfoData.data.personal.count > 0) {
obj=seachInfoData.data.personal obj = seachInfoData.data.personal
tabType.value = 'person' tabType.value = "person"
seachAllType['intermediary']=0 seachAllType["intermediary"] = 0
}else if(seachInfoData.data.intermediary.count>0){ } else if (seachInfoData.data.intermediary.count > 0) {
obj=seachInfoData.data.intermediary obj = seachInfoData.data.intermediary
tabType.value = 'intermediary' tabType.value = "intermediary"
seachAllType['intermediary']=1 seachAllType["intermediary"] = 1
}else if(seachInfoData.data.studentapartment.count>0){ } else if (seachInfoData.data.studentapartment.count > 0) {
obj=seachInfoData.data.studentapartment obj = seachInfoData.data.studentapartment
tabType.value = 'apartment' tabType.value = "apartment"
seachAllType['intermediary']='' seachAllType["intermediary"] = ""
}else obj=setSeachId() } else obj = setSeachId()
return obj return obj
} }
//搜索数据 //搜索数据
let seachList = (item) => { let seachList = item => {
let routeInfo = route.currentRoute.value let routeInfo = route.currentRoute.value
if (!seachVal.value.replace(/\s/g, "")) return if (!seachVal.value.replace(/\s/g, "")) return
if (!seachVal.value) { if (!seachVal.value) {
return return
} }
if (seachAllType['intermediary'] === 6) { if (seachAllType["intermediary"] === 6) {
seachAllType['keyword'] = seachVal.value seachAllType["keyword"] = seachVal.value
let seachObj=setSeachId() let seachObj = setSeachId()
getDataList(seachAllType,seachObj.count==0?false:true) getDataList(seachAllType, seachObj.count == 0 ? false : true)
} else { } else {
searchInit(seachVal.value) searchInit(seachVal.value)
} }
@@ -451,53 +419,53 @@ let seachList = (item) => {
path: routeInfo.path, path: routeInfo.path,
query: { query: {
keyword: seachVal.value, keyword: seachVal.value,
isNeedHousing: routeInfo.query.isNeedHousing isNeedHousing: routeInfo.query.isNeedHousing,
} },
}) })
} }
//筛选词条 //筛选词条
let typeText = ['地理位置', '出租方式', '租金', '租期', '性别要求', '发布时间', '其他'] let typeText = ["地理位置", "出租方式", "租金", "租期", "性别要求", "发布时间", "其他"]
//显示筛选组件 //显示筛选组件
let showSelectModule = ref(false) let showSelectModule = ref(false)
//选中地区 //选中地区
let selectData = reactive({ data: [] }) let selectData = reactive({data: []})
let selectTabCheck = reactive({ let selectTabCheck = reactive({
id: '', id: "",
title: '', title: "",
data: [] data: [],
}) })
//最新发布选项 //最新发布选项
let listSort = shallowReactive({ let listSort = shallowReactive({
type: [ type: [
{ title: '最新发布', type: 'timestamp' }, {title: "最新发布", type: "timestamp"},
{ title: '热门', type: 'hotnum' }, {title: "热门", type: "hotnum"},
{ title: '价格从低到高', type: 'rentasc' }, {title: "价格从低到高", type: "rentasc"},
{ title: '价格从高到低', type: 'rentdesc' } {title: "价格从高到低", type: "rentdesc"},
], ],
checkType: 'timestamp', checkType: "timestamp",
check: '最新发布' check: "最新发布",
}) })
//搜索列表排序 //搜索列表排序
let listSortCheck = (item) => { let listSortCheck = item => {
let obj= listSort.type[item] let obj = listSort.type[item]
listSort.checkType = obj.type listSort.checkType = obj.type
listSort.check = obj.title listSort.check = obj.title
setSeachConditions('orderby', obj.type) setSeachConditions("orderby", obj.type)
} }
let seachArea = {};//区域找房 let seachArea = {} //区域找房
//获取区域下列数据 //获取区域下列数据
let getLocationData = (data) => { let getLocationData = data => {
for (let item in data) { for (let item in data) {
if (!seachArea.data[item.substring(0, 1) - 1].data) seachArea.data[item.substring(0, 1) - 1].data = [] if (!seachArea.data[item.substring(0, 1) - 1].data) seachArea.data[item.substring(0, 1) - 1].data = []
if (item.length > 1) { if (item.length > 1) {
seachArea.data[item.substring(0, 1) - 1].data.push({ seachArea.data[item.substring(0, 1) - 1].data.push({
title: data[item], title: data[item],
id: item id: item,
}) })
} }
} }
@@ -506,15 +474,14 @@ let getLocationData = (data) => {
//更新当前数据数量 //更新当前数据数量
let setListCount = (item, num) => { let setListCount = (item, num) => {
if (item.tabType === "intermediary") { if (item.tabType === "intermediary") {
seachKey.key['intermediary']['count'] = num seachKey.key["intermediary"]["count"] = num
} else if (item.tabType === "person") { } else if (item.tabType === "person") {
seachKey.key['personal']['count'] = num seachKey.key["personal"]["count"] = num
} else if (item.tabType === "apartment") { } else if (item.tabType === "apartment") {
seachKey.key['studentapartment']['count'] = num seachKey.key["studentapartment"]["count"] = num
} }
} }
watchEffect(() => { watchEffect(() => {
seachArea.data = store.state.seachTypeData[1] ? store.state.seachTypeData[1].where : [] 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) if (seachArea.data.length > 0 && !seachArea.data[0].data) getLocationData(store.state.indexData.config.location)
@@ -522,18 +489,17 @@ watchEffect(() => {
defineExpose({ defineExpose({
searchInit, searchInit,
setListCount, setListCount,
checkPageType checkPageType,
}) })
// 跳转我的页面 // 跳转我的页面
const gouser = tab => { const gouser = tab => {
if (!store.state['user']['uid']) { if (!store.state["user"]["uid"]) {
store.state.showloginmodal = true store.state.showloginmodal = true
return return
} }
route.push(`/user?tab=${tab}`) route.push(`/user?tab=${tab}`)
} }
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
img { img {
@@ -605,7 +571,7 @@ img {
border-bottom: 1px solid #ebebeb !important; border-bottom: 1px solid #ebebeb !important;
} }
.box:hover{ .box:hover {
background-color: rgba(242, 242, 242, 1); background-color: rgba(242, 242, 242, 1);
} }
.box { .box {
@@ -615,7 +581,7 @@ img {
background-color: rgba(246, 246, 246, 1); background-color: rgba(246, 246, 246, 1);
border: none; border: none;
border-radius: 10px; border-radius: 10px;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
color: #555555; color: #555555;
font-size: 15px; font-size: 15px;
@@ -633,15 +599,15 @@ img {
} }
.text-tps { .text-tps {
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650; font-weight: 650;
color: #000000; color: #000000;
} }
.text-icon { .text-icon {
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
color: #D7D7D7; color: #d7d7d7;
} }
} }
} }
@@ -652,22 +618,22 @@ img {
background: #62b1ff; background: #62b1ff;
position: relative; position: relative;
border-radius: 16px 16px 0 0; border-radius: 16px 16px 0 0;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
font-size: 17px; font-size: 17px;
color: #FFFFFF; color: #ffffff;
.btm-line { .btm-line {
height: 4px; height: 4px;
width:102px; width: 102px;
background: inherit; background: inherit;
background-color: rgba(253, 223, 109, 1); background-color: rgba(253, 223, 109, 1);
border: none; border: none;
border-radius: 53px; border-radius: 53px;
} }
.btm-line-mg{ .btm-line-mg {
margin-top:-5px; margin-top: -5px;
} }
.select-top-bos-show { .select-top-bos-show {
@@ -692,7 +658,7 @@ img {
line-height: 45px; line-height: 45px;
background: #fff !important; background: #fff !important;
border-radius: 16px 16px 0 0; border-radius: 16px 16px 0 0;
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650; font-weight: 650;
font-style: normal; font-style: normal;
font-size: 17px; font-size: 17px;
@@ -823,8 +789,8 @@ img {
} }
} }
.top-btn:hover{ .top-btn:hover {
color:#bcd7f3; color: #bcd7f3;
} }
.top-btn { .top-btn {
@@ -833,7 +799,7 @@ img {
position: absolute; position: absolute;
border-radius: 16px 16px 0 0; border-radius: 16px 16px 0 0;
cursor: pointer; cursor: pointer;
line-height:45px; line-height: 45px;
} }
} }
} }
@@ -846,13 +812,13 @@ img {
padding: 0 20px 25px 20px; padding: 0 20px 25px 20px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
color: #555555; color: #555555;
font-size: 15px; font-size: 15px;
.btm-btn { .btm-btn {
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
font-size: 14px; font-size: 14px;
@@ -867,14 +833,14 @@ img {
} }
.count { .count {
font-family: 'Arial-BoldMT', 'Arial Bold', 'Arial', sans-serif; font-family: "Arial-BoldMT", "Arial Bold", "Arial", sans-serif;
font-weight: 700; font-weight: 700;
color: #000000; color: #000000;
margin: 0 5px; margin: 0 5px;
} }
.sort-text { .sort-text {
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650; font-weight: 650;
font-style: normal; font-style: normal;
font-size: 14px; font-size: 14px;
@@ -890,7 +856,6 @@ img {
} }
} }
.input-box { .input-box {
height: 92px; height: 92px;
background: inherit; background: inherit;
@@ -910,8 +875,8 @@ img {
margin-left: 10px; margin-left: 10px;
} }
.tool-btn:hover{ .tool-btn:hover {
border-color:rgba(200, 200, 200, 1); border-color: rgba(200, 200, 200, 1);
} }
.tool-btn { .tool-btn {
@@ -924,7 +889,7 @@ img {
border-style: solid; border-style: solid;
border-color: rgba(235, 235, 235, 1); border-color: rgba(235, 235, 235, 1);
border-radius: 8px; border-radius: 8px;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
font-size: 16px; font-size: 16px;
@@ -938,8 +903,8 @@ img {
} }
} }
.input-s:hover{ .input-s:hover {
border-color:rgb(200, 200, 200); border-color: rgb(200, 200, 200);
} }
.input-s { .input-s {
@@ -987,11 +952,11 @@ img {
} }
.dropdown-text { .dropdown-text {
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
font-size: 14px; font-size: 14px;
color: #7F7F7F; color: #7f7f7f;
text-align: center; text-align: center;
display: flex; display: flex;
align-items: center; align-items: center;
@@ -1017,7 +982,7 @@ img {
} }
.dropdown-check-text { .dropdown-check-text {
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650; font-weight: 650;
font-style: normal; font-style: normal;
font-size: 14px; font-size: 14px;
@@ -1026,7 +991,7 @@ img {
::v-deep .el-input__wrapper { ::v-deep .el-input__wrapper {
color: #333333 !important; color: #333333 !important;
font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
font-size: 16px !important; font-size: 16px !important;
@@ -1037,8 +1002,7 @@ img {
} }
::v-deep .el-dropdown-menu__item { ::v-deep .el-dropdown-menu__item {
--el-dropdown-menuItem-hover-color: #7F7F7F; --el-dropdown-menuItem-hover-color: #7f7f7f;
--el-dropdown-menuItem-hover-fill: rgba(246, 246, 246, 1); --el-dropdown-menuItem-hover-fill: rgba(246, 246, 246, 1);
} }
</style> </style>

View File

@@ -1,73 +1,70 @@
<template> <template>
<div class="box-min-1200-src"> <div class="box-min-1200-src">
<pageTopBar></pageTopBar> <pageTopBar></pageTopBar>
<inputModule :getDataList="setSeachSelectData" :count="dataCount" ref="inputModuleInfo"></inputModule> <inputModule :getDataList="setSeachSelectData" :count="dataCount" ref="inputModuleInfo" :isNoGetData="isNoGetData"></inputModule>
<div class="dis-f jus-x al-item"> <div class="dis-f jus-x al-item">
<div class="body-maxWidth mg-t-35"> <div class="body-maxWidth mg-t-35">
<div class="body-maxWidth" <div class="body-maxWidth" v-show="dataList.data && dataList.data.length > 0 && seachSelectData.data.tabType !== 'apartment' && seachSelectData.data.intermediary !== ''" ref="list">
v-show="dataList.data && dataList.data.length > 0 && seachSelectData.data.tabType !== 'apartment' && seachSelectData.data.intermediary !== ''"
ref="list">
<biserialItem v-for="(item, i) in pageList" :key="i" :item="item"></biserialItem> <biserialItem v-for="(item, i) in pageList" :key="i" :item="item"></biserialItem>
</div> </div>
<div class="body-maxWidth" v-show="seachSelectData.data && seachSelectData.data.tabType === 'apartment' && dataList.data && dataList.data.length > 0" <div class="body-maxWidth" v-show="seachSelectData.data && seachSelectData.data.tabType === 'apartment' && dataList.data && dataList.data.length > 0" ref="gridContainer">
ref="gridContainer"> <apartment-item v-for="(item, index) in listApartment" :key="index" :item="item"></apartment-item>
<apartment-item v-for="item in listApartment" :item="item"></apartment-item>
</div> </div>
<div class="dis-f jus-x no-list-box al-item" v-show="dataList.data && dataList.data.length === 0"> <div class="dis-f jus-x no-list-box al-item" v-show="dataList.data && dataList.data.length === 0">
<noList hintText="暂无搜索结果" hintTextTwo="建议更换搜索关键词,或放宽筛选条件"></noList> <noList hintText="暂无搜索结果" hintTextTwo="建议更换搜索关键词,或放宽筛选条件"></noList>
</div> </div>
</div> </div>
</div> </div>
<loadMoreText :loadText="loadingText" v-show="dataList.data && dataList.data.length>0"></loadMoreText> <loadMoreText :loadText="loadingText" v-show="dataList.data && dataList.data.length > 0"></loadMoreText>
<listBtmPrompt></listBtmPrompt> <listBtmPrompt></listBtmPrompt>
<footerTool></footerTool> <footerTool></footerTool>
</div> </div>
<back-to-top></back-to-top> <back-to-top></back-to-top>
</template> </template>
<script setup> <script setup>
import { reactive, onMounted, ref, provide, onBeforeUnmount, nextTick } from 'vue' import {reactive, onMounted, ref, provide, onBeforeUnmount, nextTick} from "vue"
import pageTopBar from '../components/pageTopBar/pageTopBar.vue'; import pageTopBar from "../components/pageTopBar/pageTopBar.vue"
import biserialItem from '../components/biserialListItem/biserialListItem.vue' import biserialItem from "../components/biserialListItem/biserialListItem.vue"
import listBtmPrompt from "../components/public/have-questions.vue"; import listBtmPrompt from "../components/public/have-questions.vue"
import noList from "../components/public/empty-duck.vue"; import noList from "../components/public/empty-duck.vue"
import api from "../utils/api"; import api from "../utils/api"
import tool from '../toolJs/downLoadMore' import tool from "../toolJs/downLoadMore"
import inputModule from '../components/seachPage/input.vue' import inputModule from "../components/seachPage/input.vue"
import apartmentItem from '@/components/public/apartment-item.vue'; import apartmentItem from "@/components/public/apartment-item.vue"
import Masonry from 'masonry-layout'; import Masonry from "masonry-layout"
import { useRouter } from 'vue-router'; import {useRouter} from "vue-router"
import { ElMessage } from 'element-plus' import {ElMessage} from "element-plus"
import footerTool from '@/components/footer/footer.vue' import footerTool from "@/components/footer/footer.vue"
import loadMoreText from '../components/loadMore/loadMoreText.vue' import loadMoreText from "../components/loadMore/loadMoreText.vue"
import backToTop from '@/components/public/backToTop.vue' import backToTop from "@/components/public/backToTop.vue"
//路由 //路由
const route = useRouter() const route = useRouter()
let routeQuery = reactive({ data: {} }) let routeQuery = reactive({data: {}})
//获取数据 //获取数据
let pages = ref(1)//页数 let pages = ref(1) //页数
let dataList = reactive({ data: [], count: 0 })//个人/中介数据 let dataList = reactive({data: [], count: 0}) //个人/中介数据
let dataCount = ref(0)//数据数量 let dataCount = ref(0) //数据数量
let pageList = ref([]) let pageList = ref([])
// let pageList = reactive({ 1: [], 2: [], height1: 0, height2: 0, tab: 1 })//双列瀑布数据 // let pageList = reactive({ 1: [], 2: [], height1: 0, height2: 0, tab: 1 })//双列瀑布数据
let seachSelectData = reactive({ data: {} })//搜索数据 let seachSelectData = reactive({data: {}}) //搜索数据
let loading = ref(true)//开关 let loading = ref(true) //开关
let loadingText = ref(` 下拉加载更多 `) let loadingText = ref(` 下拉加载更多 `)
let listApartment = ref([])//公寓数据 let listApartment = ref([]) //公寓数据
let masonryInstance = null//瀑布实例 let masonryInstance = null //瀑布实例
let listMasonryInstance = null let listMasonryInstance = null
provide('count', dataCount) provide("count", dataCount)
//保存搜索设置 //保存搜索设置
let setSeachSelectData = (data,type) => { let setSeachSelectData = (data, type) => {
pages.value = 1 pages.value = 1
seachSelectData.data = { seachSelectData.data = {
...data ...data,
} }
loading.value = true loading.value = true
getDataList(seachSelectData.data,type) getDataList(seachSelectData.data, type)
} }
//初始化列表参数 //初始化列表参数
@@ -79,25 +76,26 @@ let setInitial = () => {
} }
//获取搜索数据 //获取搜索数据
let getDataList = (data,type=true) => { let getDataList = (data, type = true) => {
// console.log(data,type) // console.log(data,type)
if(!type){ //是否继续搜索 if (!type) {
seachSelectData.data.tabType !== 'apartment'?pageList.value = []:listApartment.value = [] //是否继续搜索
seachSelectData.data.tabType !== "apartment" ? (pageList.value = []) : (listApartment.value = [])
dataList.data = [] dataList.data = []
dataCount.value = 0 dataCount.value = 0
loading.value = false loading.value = false
return return
} }
loadingText.value=' 加载中..... ' loadingText.value = " 加载中..... "
if (!loading.value) return if (!loading.value) return
let postData = { let postData = {
page: pages.value, page: pages.value,
limit: 20, limit: 20,
...data ...data,
} }
loading.value = false loading.value = false
let seachApi = null let seachApi = null
if (seachSelectData.data.tabType !== 'apartment') { if (seachSelectData.data.tabType !== "apartment") {
seachApi = api.getLists(postData) seachApi = api.getLists(postData)
} else { } else {
seachApi = api.apartment(postData) seachApi = api.apartment(postData)
@@ -110,10 +108,10 @@ let getDataList = (data,type=true) => {
loadingText.value = ` 到底了 ` loadingText.value = ` 到底了 `
loading.value = false loading.value = false
} else { } else {
loadingText.value = ' 下拉加载更多 ' loadingText.value = " 下拉加载更多 "
loading.value = true loading.value = true
} }
if (seachSelectData.data.tabType !== 'apartment') { if (seachSelectData.data.tabType !== "apartment") {
if (pages.value === 1) { if (pages.value === 1) {
setInitial() setInitial()
pageList.value = [] pageList.value = []
@@ -123,8 +121,8 @@ let getDataList = (data,type=true) => {
dataCount.value = res.data.count dataCount.value = res.data.count
pageList.value = pageList.value.concat(dataList.data) pageList.value = pageList.value.concat(dataList.data)
nextTick(() => { nextTick(() => {
listMasonryInstance.reloadItems(); listMasonryInstance.reloadItems()
listMasonryInstance.layout(); listMasonryInstance.layout()
}) })
} else { } else {
let data = res.data let data = res.data
@@ -133,15 +131,14 @@ let getDataList = (data,type=true) => {
if (pages.value === 1) listApartment.value = [] if (pages.value === 1) listApartment.value = []
listApartment.value = listApartment.value.concat(data.data) listApartment.value = listApartment.value.concat(data.data)
nextTick(() => { nextTick(() => {
masonryInstance.reloadItems(); masonryInstance.reloadItems()
masonryInstance.layout(); masonryInstance.layout()
if (res.data.data.length >= 20) { if (res.data.data.length >= 20) {
loading.value = true loading.value = true
} }
}) })
} }
inputModuleInfo.value.setListCount(seachSelectData.data, dataList.count) inputModuleInfo.value.setListCount(seachSelectData.data, dataList.count)
} else { } else {
ElMessage({ ElMessage({
message: res.message, message: res.message,
@@ -151,43 +148,44 @@ let getDataList = (data,type=true) => {
}) })
} }
let isDownGetData = ref(true) // 是否可以下拉获取数据
provide("isDownGetData", isDownGetData)
//加载更多 //加载更多
let downLoadMore = () => { let downLoadMore = () => {
tool.loadMore(() => { tool.loadMore(() => {
if (!loading.value) return if (!loading.value || !isDownGetData.value) return
pages.value++ pages.value++
getDataList(seachSelectData.data) getDataList(seachSelectData.data)
}) })
} }
let inputModuleInfo = ref(null) let inputModuleInfo = ref(null)
const gridContainer = ref(null); const gridContainer = ref(null)
const list = ref(null) const list = ref(null)
//listImg //listImg
onMounted(() => { onMounted(() => {
listMasonryInstance = new Masonry(list.value, { listMasonryInstance = new Masonry(list.value, {
itemSelector: '.item', itemSelector: ".item",
gutter: 20, gutter: 20,
}); })
masonryInstance = new Masonry(gridContainer.value, { masonryInstance = new Masonry(gridContainer.value, {
itemSelector: '.item', itemSelector: ".item",
gutter: 20 gutter: 20,
}); })
routeQuery.data = route.currentRoute.value.query routeQuery.data = route.currentRoute.value.query
if (routeQuery.data.keyword && routeQuery.data.keyword.replace(/\s/g, "") && routeQuery.data.houseingPageType != 6) { if (routeQuery.data.keyword && routeQuery.data.keyword.replace(/\s/g, "") && routeQuery.data.houseingPageType != 6) {
inputModuleInfo.value.searchInit(routeQuery.data.keyword)//调用搜索组件的搜索功能 inputModuleInfo.value.searchInit(routeQuery.data.keyword) //调用搜索组件的搜索功能
// route.currentRoute.value.query.keyword = '' // route.currentRoute.value.query.keyword = ''
} else { } else {
inputModuleInfo.value.checkPageType() inputModuleInfo.value.checkPageType()
} }
window.addEventListener('scroll', downLoadMore, true); window.addEventListener("scroll", downLoadMore, true)
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
window.removeEventListener('scroll', downLoadMore, true); window.removeEventListener("scroll", downLoadMore, true)
}) })
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
img { img {
@@ -238,4 +236,3 @@ img {
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.0784313725490196); box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.0784313725490196);
} }
</style> </style>