个人/中介 搜索 求房源 首页更新

This commit is contained in:
2023-07-20 17:18:53 +08:00
parent 60f0f45def
commit 4adeb65dbd
8 changed files with 68 additions and 59 deletions

View File

@@ -119,7 +119,7 @@ let listId = props.listId
let imgRef = null let imgRef = null
let loadFinish = () => { let loadFinish = () => {
let height = imgRef.ctx.$refs&&imgRef.ctx.$refs.list&&imgRef.ctx.$refs.list.offsetHeight let height = imgRef.ctx.$refs&&imgRef.ctx.$refs.list&&imgRef.ctx.$refs.list.offsetHeight
console.log(data.id, listId, height) // console.log(data.id, listId, height)
props.imgLoad(data.id, listId, height) props.imgLoad(data.id, listId, height)
} }

View File

@@ -159,16 +159,24 @@ historyArr.data = JSON.parse(localStorage.getItem('historyArr')) || []
//搜索数据 //搜索数据
let seachList = (item) => { let seachList = (item) => {
console.log(123)
let string=seachAllType.keyword
if (!string.replace(/\s/g, "")) return
if (historyArr.data.indexOf(seachAllType.keyword) === -1) { if (historyArr.data.indexOf(seachAllType.keyword) === -1) {
historyArr.data.push(seachAllType.keyword) historyArr.data.push(seachAllType.keyword)
} }
localStorage.setItem('historyArr', JSON.stringify(historyArr.data)); localStorage.setItem('historyArr', JSON.stringify(historyArr.data));
route.push({ if (routePath.value === '/') {
path: '/seachPage', route.push({
query: { path: '/seachPage',
keyword:seachAllType.keyword query: {
} keyword: seachAllType.keyword
}) }
})
}else{
setSeachConditions()
}
// getDataList(seachAllType) // getDataList(seachAllType)
} }
@@ -450,5 +458,6 @@ defineExpose({
flex-wrap: wrap; flex-wrap: wrap;
} }
} }
}</style> }
</style>

View File

@@ -238,6 +238,9 @@ let setSeachConditions = (type, data) => {
...data ...data
} }
} }
if(!seachVal.value){
seachAllType.searchid=''
}
// console.log('seachAllType', seachAllType) // console.log('seachAllType', seachAllType)
// return // return
getDataList(seachAllType, tabType.value) getDataList(seachAllType, tabType.value)
@@ -266,7 +269,7 @@ let searchInit = (data) => {
} }
//搜索数据 //搜索数据
let seachList = (item) => { let seachList = (item) => {
console.log(seachVal.value) if(seachVal.value.replace(/\s/g,""))return
if (!seachVal.value) { if (!seachVal.value) {
return return
} }

View File

@@ -953,8 +953,14 @@ img {
margin-right: 10px; margin-right: 10px;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
border:1px solid transparent;
}
.btn:hover{
border:1px solid rgba(235,235,235,1)
}
.dropdown-btn:hover{
border:1px solid rgba(235,235,235,1);
} }
.dropdown-btn { .dropdown-btn {
height: 30px; height: 30px;
display: flex; display: flex;
@@ -969,6 +975,7 @@ img {
text-align: center; text-align: center;
padding: 5px 10px; padding: 5px 10px;
cursor: pointer; cursor: pointer;
border:1px solid transparent;
.mg-l-30 { .mg-l-30 {
margin-left: 30px !important; margin-left: 30px !important;
@@ -987,7 +994,7 @@ img {
.btn-check { .btn-check {
color: #50E3C2 !important; color: #50E3C2 !important;
border: 1px solid #50E3C2; border: 1px solid #50E3C2 !important;
background: #eefcf9; background: #eefcf9;
} }

View File

@@ -20,6 +20,7 @@
</div> </div>
</div> </div>
<listBtmPrompt></listBtmPrompt> <listBtmPrompt></listBtmPrompt>
<footerTool></footerTool>
</div> </div>
<!-- 右下角咨询 --> <!-- 右下角咨询 -->
<circle-btn></circle-btn> <circle-btn></circle-btn>
@@ -36,6 +37,7 @@ import circleBtn from '@/components/public/circle-btn.vue'
import api from "../../utils/api"; import api from "../../utils/api";
import tool from '../../toolJs/downLoadMore' import tool from '../../toolJs/downLoadMore'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import footerTool from '@/components/footer/footer.vue'
//获取数据 //获取数据
let pages = ref(1) let pages = ref(1)
@@ -43,7 +45,7 @@ let dataList = reactive({ data: [], count: 0 })
let dataCount = ref(0) let dataCount = ref(0)
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(false) let loading = ref(true)
provide('count', dataCount) provide('count', dataCount)
//保存搜索设置 //保存搜索设置
@@ -76,11 +78,7 @@ let getDataList = (data) => {
} }
api.getLists(postData).then(res => { api.getLists(postData).then(res => {
if (res.code === 200) { if (res.code === 200) {
loading.value = true
dataList.data = res.data.data dataList.data = res.data.data
if(res.data.count<20){
loading.value = false
}
if (pages.value === 1) { if (pages.value === 1) {
setInitial() setInitial()
} }
@@ -88,8 +86,8 @@ let getDataList = (data) => {
dataList.count = res.data.count dataList.count = res.data.count
dataCount.value = res.data.count dataCount.value = res.data.count
nextTick(() => { nextTick(() => {
pageList['1'].push(dataList.data[0]) if(dataList.data[0])pageList['1'].push(dataList.data[0])
pageList['2'].push(dataList.data[1]) if(dataList.data[1])pageList['2'].push(dataList.data[1])
}) })
} else { } else {
ElMessage({ ElMessage({
@@ -103,9 +101,11 @@ let getDataList = (data) => {
//添加数据 //添加数据
let addListData = () => { let addListData = () => {
let num = null let num = null
if (pageList.tab >= (dataList.count>20?20-2:dataList.count-2)) { if (pageList.tab >= (dataList.count>20?dataList.data.length-2:dataList.count-2)) {
if(dataList.count>20){ if(dataList.data.length>=20){
loading.value = true loading.value = true
}else{
loading.value = false
} }
return return
} }
@@ -127,7 +127,7 @@ let watchImgLoad = (id, listId, height) => {
//加载更多 //加载更多
let downLoadMore = () => { let downLoadMore = () => {
tool.loadMore(() => { tool.loadMore(() => {
if (!loading.value||dataList.data.length===0) return if (!loading.value) return
pages.value++ pages.value++
getDataList(seachSelectData.data) getDataList(seachSelectData.data)
}) })

View File

@@ -20,6 +20,7 @@
</div> </div>
</div> </div>
<listBtmPrompt></listBtmPrompt> <listBtmPrompt></listBtmPrompt>
<footerTool></footerTool>
</div> </div>
<!-- 右下角咨询 --> <!-- 右下角咨询 -->
@@ -37,6 +38,7 @@ import circleBtn from '@/components/public/circle-btn.vue'
import api from "../../utils/api"; import api from "../../utils/api";
import tool from '../../toolJs/downLoadMore' import tool from '../../toolJs/downLoadMore'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import footerTool from '@/components/footer/footer.vue'
//获取数据 //获取数据
let pages = ref(1) let pages = ref(1)
@@ -44,22 +46,16 @@ let dataList = reactive({ data: [], count: 0 })
let dataCount = ref(0) let dataCount = ref(0)
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(false) let loading = ref(true)
provide('count', dataCount) provide('count', dataCount)
//保存搜索设置 //保存搜索设置
let setSeachSelectData = (data) => { let setSeachSelectData = (data) => {
pages.value = 1 pages.value = 1
// if(data.location.length>0){
// data.location=JSON.stringify(data.location)
// }
seachSelectData.data = { seachSelectData.data = {
...data ...data
} }
loading.value = true loading.value = true
console.log('seachSelectData', seachSelectData.data)
return
getDataList(seachSelectData.data) getDataList(seachSelectData.data)
} }
@@ -83,11 +79,7 @@ let getDataList = (data) => {
} }
api.getLists(postData).then(res => { api.getLists(postData).then(res => {
if (res.code === 200) { if (res.code === 200) {
loading.value = true
dataList.data = res.data.data dataList.data = res.data.data
if(res.data.count<20){
loading.value = false
}
if (pages.value === 1) { if (pages.value === 1) {
setInitial() setInitial()
} }
@@ -95,8 +87,8 @@ let getDataList = (data) => {
dataList.count = res.data.count dataList.count = res.data.count
dataCount.value = res.data.count dataCount.value = res.data.count
nextTick(() => { nextTick(() => {
pageList['1'].push(dataList.data[0]) if(dataList.data[0])pageList['1'].push(dataList.data[0])
pageList['2'].push(dataList.data[1]) if(dataList.data[1])pageList['2'].push(dataList.data[1])
}) })
} else { } else {
ElMessage({ ElMessage({
@@ -110,9 +102,12 @@ let getDataList = (data) => {
//添加数据 //添加数据
let addListData = () => { let addListData = () => {
let num = null let num = null
if (pageList.tab >= (dataList.count>20?20-2:dataList.count-2)) { if (pageList.tab >= (dataList.count>20?dataList.data.length-2:dataList.count-2)) {
if(dataList.count>20){ console.log(dataList.data.length,20,loading.value)
if(dataList.data.length>=20){
loading.value = true loading.value = true
}else{
loading.value = false
} }
return return
} }
@@ -134,7 +129,7 @@ let watchImgLoad = (id, listId, height) => {
//加载更多 //加载更多
let downLoadMore = () => { let downLoadMore = () => {
tool.loadMore(() => { tool.loadMore(() => {
if (!loading.value||dataList.data.length===0) return if (!loading.value) return
pages.value++ pages.value++
getDataList(seachSelectData.data) getDataList(seachSelectData.data)
}) })

View File

@@ -20,6 +20,7 @@
</div> </div>
</div> </div>
<listBtmPrompt></listBtmPrompt> <listBtmPrompt></listBtmPrompt>
<footerTool></footerTool>
</div> </div>
<!-- 右下角咨询 --> <!-- 右下角咨询 -->
@@ -38,6 +39,7 @@ import api from "../../utils/api";
import tool from '../../toolJs/downLoadMore' import tool from '../../toolJs/downLoadMore'
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'
//路由 //路由
const router = useRouter() const router = useRouter()
@@ -83,23 +85,15 @@ let getDataList = (data) => {
api.getLists(postData).then(res => { api.getLists(postData).then(res => {
if (res.code === 200) { if (res.code === 200) {
dataList.data = res.data.data dataList.data = res.data.data
// if (res.data.data.length === 0) {
// loading.value = false
// return
// }
if(res.data.count<20){
loading.value = false
}
if (pages.value === 1) { if (pages.value === 1) {
setInitial() setInitial()
} }
pageList.tab = 1 pageList.tab = 1
dataList.count = res.data.count dataList.count = res.data.count
dataCount.value = res.data.count dataCount.value = res.data.count
nextTick(() => { nextTick(() => {
pageList['1'].push(dataList.data[0]) if(dataList.data[0])pageList['1'].push(dataList.data[0])
pageList['2'].push(dataList.data[1]) if(dataList.data[1])pageList['2'].push(dataList.data[1])
}) })
} else { } else {
ElMessage({ ElMessage({
@@ -113,9 +107,11 @@ let getDataList = (data) => {
//添加数据 //添加数据
let addListData = () => { let addListData = () => {
let num = null let num = null
if (pageList.tab >= (dataList.count>20?20-2:dataList.count-2)) { if (pageList.tab >= (dataList.count>20?dataList.data.length-2:dataList.count-2)) {
if(dataList.count>20){ if(dataList.data.length>=20){
loading.value = true loading.value = true
}else{
loading.value = false
} }
return return
} }
@@ -150,7 +146,7 @@ onMounted(() => {
let typeData=null let typeData=null
if(data)typeData=JSON.parse(data) if(data)typeData=JSON.parse(data)
if(Object.keys(data).length>0){ if(data&&Object.keys(data).length>0){
if(type!=='location'){ if(type!=='location'){
seachSelectData.data={[type]:typeData.id} seachSelectData.data={[type]:typeData.id}
}else{ }else{

View File

@@ -24,6 +24,7 @@
</div> </div>
</div> </div>
<listBtmPrompt></listBtmPrompt> <listBtmPrompt></listBtmPrompt>
<footerTool></footerTool>
</div> </div>
</template> </template>
@@ -40,6 +41,7 @@ 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'
//路由 //路由
const route = useRouter() const route = useRouter()
@@ -99,11 +101,7 @@ let getDataList = (data) => {
seachApi.then(res => { seachApi.then(res => {
if (res.code === 200) { if (res.code === 200) {
console.log(res.data) console.log(res.data)
loading.value = true
dataList.data = res.data.data dataList.data = res.data.data
if (res.data.count < 20) {
loading.value = false
}
if (seachSelectData.data.tabType !== 'apartment') { if (seachSelectData.data.tabType !== 'apartment') {
if (pages.value === 1) { if (pages.value === 1) {
setInitial() setInitial()
@@ -112,8 +110,8 @@ let getDataList = (data) => {
dataList.count = res.data.count dataList.count = res.data.count
dataCount.value = res.data.count dataCount.value = res.data.count
nextTick(() => { nextTick(() => {
pageList['1'].push(dataList.data[0]) if(dataList.data[0])pageList['1'].push(dataList.data[0])
pageList['2'].push(dataList.data[1]) if(dataList.data[1])pageList['2'].push(dataList.data[1])
}) })
} else { } else {
let data = res.data let data = res.data
@@ -137,10 +135,11 @@ let getDataList = (data) => {
//添加数据 //添加数据
let addListData = () => { let addListData = () => {
let num = null let num = null
console.log(pageList.tab , dataList.count) if (pageList.tab >= (dataList.count>20?dataList.data.length-2:dataList.count-2)) {
if (pageList.tab >= (dataList.count>20?20-2:dataList.count-2)) { if(dataList.data.length>=20){
if(dataList.count>20){
loading.value = true loading.value = true
}else{
loading.value = false
} }
return return
} }