搜索为空可以跳转搜索页

This commit is contained in:
2023-07-21 16:14:58 +08:00
parent a8e75b0f98
commit da63d7358e
3 changed files with 12 additions and 8 deletions

View File

@@ -161,11 +161,11 @@ historyArr.data = JSON.parse(localStorage.getItem('historyArr')) || []
let seachList = (item) => {
// console.log(123)
let string = seachAllType.keyword
if (!string.replace(/\s/g, "")) return
if (historyArr.data.indexOf(seachAllType.keyword) === -1) {
historyArr.data.push(seachAllType.keyword)
}
localStorage.setItem('historyArr', JSON.stringify(historyArr.data));
if (string.replace(/\s/g, ""))localStorage.setItem('historyArr', JSON.stringify(historyArr.data));
route.push({
path: '/seachPage',
query: {

View File

@@ -3,7 +3,7 @@
<div class="body-maxWidth ">
<div class="input-box dis-f al-item jus-bet body-maxWidth">
<div class="dis-f al-item">
<el-input v-model="seachVal" class="input-s" placeholder="输入关键字" @keyup.enter='seachList'>
<el-input v-model="seachVal" class="input-s" placeholder="搜索房源或输入房源ID" @keyup.enter='seachList'>
<template #suffix>
<img src="../../assets/homeImage/seachIcon.svg" class="icon" alt="" @click="seachList">
</template>
@@ -181,6 +181,7 @@ let selectTabBoxInfo = ref(null)//个人/中介筛选实例
let apartmentSelectInfo = ref(null)//公寓筛选实例
//设置请求数据
let selectPage = (type) => {
if(type===seachAllType['tabType'])return
if (type === 'apartment') {
selectTabBoxInfo.value.cleanSelect()//清空筛选数据
} else {
@@ -211,7 +212,7 @@ let getDataList = props.getDataList
//搜索内容
let seachVal = ref('')
let isNeedHousing = ref(false)
seachVal.value = route.currentRoute.value.query.keyword
seachVal.value = route.currentRoute.value.query.keyword.replace(/\s/g, "")
//判断是否从求房源页面跳转
isNeedHousing.value = route.currentRoute.value.query.isNeedHousing === 'true'
@@ -235,6 +236,7 @@ let checkPageType = () => {
} else {
seachAllType['intermediary'] = ''
}
getDataList(seachAllType)
}
@@ -379,8 +381,6 @@ let setListCount=(item,num)=>{
}
}
//调用判断页面
checkPageType()
watchEffect(() => {
seachArea.data = store.state.seachTypeData[1] ? store.state.seachTypeData[1].where : []
@@ -388,7 +388,8 @@ watchEffect(() => {
})
defineExpose({
searchInit,
setListCount
setListCount,
checkPageType
})
</script>

View File

@@ -118,6 +118,7 @@ let getDataList = (data) => {
} else {
let data = res.data
dataList.count = res.data.count
dataCount.value = res.data.count
listApartment.value = listApartment.value.concat(data.data)
nextTick(() => {
masonryInstance.reloadItems();
@@ -186,7 +187,9 @@ onMounted(() => {
inputModuleInfo.value.searchInit(routeQuery.data.keyword)//调用搜索组件的搜索功能
route.currentRoute.value.query.keyword=''
}else{
getDataList()
console.log(seachSelectData.data)
inputModuleInfo.value.checkPageType()
// getDataList(seachSelectData.data)
}
window.addEventListener('scroll', downLoadMore, true);
})