搜索页

This commit is contained in:
2023-07-19 18:23:56 +08:00
parent ea4b66db95
commit 9900a77f14
9 changed files with 675 additions and 72 deletions

View File

@@ -543,6 +543,7 @@ img {
.img-box:hover .img-list {
display: block;
cursor: pointer;
}
}
@@ -634,6 +635,7 @@ img {
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.0784313725490196);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.0784313725490196);
margin-bottom: 10px;
cursor: pointer;
}
.img {

View File

@@ -1,7 +1,7 @@
<template>
<div>
<pageTopBar></pageTopBar>
<seachModule :count="dataList.count" :getDataList="setSeachSelectData"></seachModule>
<seachModule :getDataList="setSeachSelectData"></seachModule>
<div class="dis-f jus-x al-item">
<div class="body-maxWidth mg-t-35">
<div class="dis-f jus-bet" v-show="dataList.data && dataList.data.length > 0">

View File

@@ -1,11 +1,11 @@
<template>
<div>
<pageTopBar></pageTopBar>
<inputModule></inputModule>
<!-- <seachModule :getDataList="setSeachSelectData"></seachModule> -->
<inputModule :getDataList="setSeachSelectData" :count="dataCount"></inputModule>
<div class="dis-f jus-x al-item">
<div class="body-maxWidth mg-t-35">
<div class="dis-f jus-bet" v-show="dataList.data && dataList.data.length > 0">
<div class="dis-f jus-bet"
v-show="dataList.data && dataList.data.length > 0 && seachSelectData.data.intermediary !== ''">
<div ref="list">
<biserialItem v-for="(item, i) in pageList['1']" :key="i" :item="item" :imgLoad="watchImgLoad"
listId="1"></biserialItem>
@@ -15,6 +15,9 @@
listId="2"></biserialItem>
</div>
</div>
<div v-show="seachSelectData.data.intermediary === ''" ref="gridContainer">
<apartment-item v-for="item in listApartment" :item="item"></apartment-item>
</div>
<div class="dis-f jus-x no-list-box al-item" v-show="dataList.data && dataList.data.length === 0">
<noList></noList>
</div>
@@ -27,25 +30,28 @@
<script setup>
import { reactive, onMounted, ref, provide, onBeforeUnmount, nextTick } from 'vue'
import pageTopBar from '../components/pageTopBar/pageTopBar.vue';
// import seachModule from "../components/seachModule/seachModule.vue";
import biserialItem from '../components/biserialListItem/biserialListItem.vue'
import listBtmPrompt from "../components/public/have-questions.vue";
import noList from "../components/public/empty-duck.vue";
import api from "../utils/api";
import tool from '../toolJs/downLoadMore'
import inputModule from '../components/seachPage/input.vue'
import apartmentItem from '@/components/public/apartment-item.vue';
import Masonry from 'masonry-layout';
//获取数据
let pages = ref(1)
let dataList = reactive({ data: [], count: 0 })
let dataCount = ref(0)
let pageList = reactive({ 1: [], 2: [], height1: 0, height2: 0, tab: 1 })
let seachSelectData = reactive({ data: {} })
let loading = ref(false)
let pages = ref(1)//页数
let dataList = reactive({ data: [], count: 0 })//个人/中介数据
let dataCount = ref(0)//数据数量
let pageList = reactive({ 1: [], 2: [], height1: 0, height2: 0, tab: 1 })//双列瀑布数据
let seachSelectData = reactive({ data: {} })//搜索数据
let loading = ref(true)//开关
let listApartment = ref([])//公寓数据
let masonryInstance = null//瀑布实例
provide('count', dataCount)
//保存搜索设置
let setSeachSelectData = (data) => {
let setSeachSelectData = (data, type) => {
pages.value = 1
// if(data.location.length>0){
@@ -55,9 +61,9 @@ let setSeachSelectData = (data) => {
...data
}
loading.value = true
console.log('seachSelectData',seachSelectData.data)
return
getDataList(seachSelectData.data)
// console.log('seachSelectData', seachSelectData.data, type)
// return
getDataList(seachSelectData.data, type)
}
//初始化列表参数
@@ -70,29 +76,48 @@ let setInitial = () => {
//获取搜索数据
let getDataList = (data) => {
if (!loading.value) return
let postData = {
page: pages.value,
intermediary:0,
intermediary: 0,
...data
}
api.getLists(postData).then(res => {
loading.value = false
let seachApi = null
if (seachSelectData.data.tabType !== 'apartment') {
seachApi = api.getLists(postData)
} else {
seachApi = api.apartment(postData)
}
seachApi.then(res => {
if (res.code === 200) {
console.log(res.data)
loading.value = true
dataList.data = res.data.data
if (res.data.data.length === 0) {
if (res.data.data.length < 20) {
loading.value = false
return
}
if (pages.value === 1) {
setInitial()
if (seachSelectData.data.tabType !== 'apartment') {
if (pages.value === 1) {
setInitial()
}
pageList.tab = 1
dataList.count = res.data.count
dataCount.value = res.data.count
nextTick(() => {
pageList['1'].push(dataList.data[0])
pageList['2'].push(dataList.data[1])
})
} else {
let data = res.data
listApartment.value = listApartment.value.concat(data.data)
nextTick(() => {
masonryInstance.reloadItems();
masonryInstance.layout();
})
}
pageList.tab = 1
dataList.count = res.data.count
dataCount.value = res.data.count
nextTick(() => {
pageList['1'].push(dataList.data[0])
pageList['2'].push(dataList.data[1])
})
} else {
// ElMessage(res.message)
}
@@ -127,10 +152,15 @@ let downLoadMore = () => {
})
}
const gridContainer = ref(null);
//listImg
onMounted(() => {
// getDataList()
// window.addEventListener('scroll', downLoadMore, true);
masonryInstance = new Masonry(gridContainer.value, {
itemSelector: '.item',
gutter: 20
});
getDataList()
window.addEventListener('scroll', downLoadMore, true);
})
onBeforeUnmount(() => {