This commit is contained in:
2023-07-26 18:03:04 +08:00
parent 13dacfe5d3
commit dff6345e33
4 changed files with 42 additions and 23 deletions

View File

@@ -266,8 +266,11 @@ const route = useRouter()
let routePath = ref('') let routePath = ref('')
let routeQuery = reactive({ data: {} }) let routeQuery = reactive({ data: {} })
routePath.value = route.currentRoute.value.path routePath.value = route.currentRoute.value.path
routeQuery.data = route.currentRoute.value.query if(route.currentRoute.value.params.type){
routeQuery.data = route.currentRoute.value.params
}else{
routeQuery.data = route.currentRoute.value.query
}
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const props = defineProps({ const props = defineProps({
@@ -600,6 +603,7 @@ let routerQuerySet = () => {
setCheckBoxData(data)//设置地区选项 setCheckBoxData(data)//设置地区选项
} }
} }
setRouterQuerySet.value = false setRouterQuerySet.value = false
} }
@@ -608,6 +612,7 @@ watchEffect(() => {
if (configData.data) { if (configData.data) {
hireTypeArr[1].hireType = setHireTypeArr(store.state.seachTypeData[2] ? store.state.seachTypeData[2].where[0].data : [], 1) hireTypeArr[1].hireType = setHireTypeArr(store.state.seachTypeData[2] ? store.state.seachTypeData[2].where[0].data : [], 1)
hireTypeArr[2].hireType = setHireTypeArr(store.state.seachTypeData[2] ? store.state.seachTypeData[2].where[1].data : [], 2) hireTypeArr[2].hireType = setHireTypeArr(store.state.seachTypeData[2] ? store.state.seachTypeData[2].where[1].data : [], 2)
console.log('route',route)
if (setRouterQuerySet.value) { if (setRouterQuerySet.value) {
setRegionList()//设置地区数据 setRegionList()//设置地区数据
setSchoolData()//设置学校数据 setSchoolData()//设置学校数据

View File

@@ -46,7 +46,7 @@ const routes = [
} }
}, },
{//个人房源 {//个人房源
path: '/personHousing', path: '/personHousing/:type?/:data?/:areaItem?',
component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/person.vue'), component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/person.vue'),
meta: { meta: {
title: '个人房源' title: '个人房源'
@@ -101,7 +101,10 @@ router.beforeEach((to, from, next) => {
//导航数据 //导航数据
if (/['seachPage','needHousing','intermediaryHousing','personHousing']/.test(from.path)) { if (/['seachPage','needHousing','intermediaryHousing','personHousing']/.test(from.path)) {
store.state.routeList.secondaryIndex.title = from.meta.title store.state.routeList.secondaryIndex.title = from.meta.title
store.state.routeList.secondaryIndex.path = from.path store.state.routeList.secondaryIndex.path = from.path==='/needHousing'?'/needHousing':
from.path==='/intermediaryHousing'?'/intermediaryHousing':
from.path==='/personHousing'?'/personHousing':
from.path==='/seachPage'?'/seachPage':''
} }
next() next()
let meta = to['meta'] || {} let meta = to['meta'] || {}

View File

@@ -1103,12 +1103,13 @@ let setNavigation = () => {
let type = store.state.indexData.config && store.state.indexData.config.type let type = store.state.indexData.config && store.state.indexData.config.type
indexData['data'] = store.state.indexData indexData['data'] = store.state.indexData
console.log('routeLis',store.state) console.log('routeLis',store.state)
console.log(location)
if (!location) return if (!location) return
if (pageType.value == 1 || pageType.value == 2) { if (pageType.value == 1 || pageType.value == 2) {
// type=location&data=["2.2"]&areaItem={"id":2,"name":"九龙"} // type=location&data=["2.2"]&areaItem={"id":2,"name":"九龙"}
console.log(`${store.state.routeList['secondaryIndex'].path}?type=location&data=${housingInfo['data']['info'].location.substring(0, 1)}`) console.log(`${store.state.routeList['secondaryIndex'].path}/location/${housingInfo['data']['info'].location.substring(0, 1)}`)
store.state.routeList['thirdIndex'] = { store.state.routeList['thirdIndex'] = {
path: `${store.state.routeList['secondaryIndex'].path}?type=location&data=${housingInfo['data']['info'].location.substring(0, 1)}`, path: `${store.state.routeList['secondaryIndex'].path}/location/${housingInfo['data']['info'].location.substring(0, 1)}`,
title: `${location[housingInfo['data']['info'].location.substring(0, 1)]}${type[housingInfo['data']['info'].type.substring(0, 1)]}房源` title: `${location[housingInfo['data']['info'].location.substring(0, 1)]}${type[housingInfo['data']['info'].type.substring(0, 1)]}房源`
} }
if (housingInfo['data']['info'].location.length > 0) if (housingInfo['data']['info'].location.length > 0)

View File

@@ -19,7 +19,7 @@
</div> </div>
</div> </div>
</div> </div>
<loadMoreText :loadText="loading?'加载中....':'到底了'"></loadMoreText> <loadMoreText :loadText="loading ? '加载中....' : '到底了'"></loadMoreText>
<listBtmPrompt></listBtmPrompt> <listBtmPrompt></listBtmPrompt>
<footerTool></footerTool> <footerTool></footerTool>
</div> </div>
@@ -77,7 +77,7 @@ let setInitial = () => {
//获取搜索数据 //获取搜索数据
let getDataList = (data) => { let getDataList = (data) => {
if(!loading.value)return if (!loading.value) return
loading.value = false loading.value = false
let postData = { let postData = {
page: pages.value, page: pages.value,
@@ -94,8 +94,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(() => {
if(dataList.data[0])pageList['1'].push(dataList.data[0]) if (dataList.data[0]) pageList['1'].push(dataList.data[0])
if(dataList.data[1])pageList['2'].push(dataList.data[1]) if (dataList.data[1]) pageList['2'].push(dataList.data[1])
}) })
} else { } else {
ElMessage({ ElMessage({
@@ -109,10 +109,10 @@ let getDataList = (data) => {
//添加数据 //添加数据
let addListData = () => { let addListData = () => {
let num = null let num = null
if (pageList.tab > (dataList.count>20?dataList.data.length-2:dataList.count-2)) { if (pageList.tab > (dataList.count > 20 ? dataList.data.length - 2 : dataList.count - 2)) {
if(dataList.data.length>20){ if (dataList.data.length > 20) {
loading.value = true loading.value = true
}else{ } else {
loading.value = false loading.value = false
} }
return return
@@ -135,7 +135,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 || dataList.data.length == 0) return
pages.value++ pages.value++
getDataList(seachSelectData.data) getDataList(seachSelectData.data)
}) })
@@ -143,15 +143,25 @@ let downLoadMore = () => {
//listImg //listImg
onMounted(() => { onMounted(() => {
let {type,data}=router.currentRoute.value.query console.log(123)
let typeData=null let type=null,data=null
if(data)typeData=JSON.parse(data) if (router.currentRoute.value.params.type) {
let { type, data } = router.currentRoute.value.params
type=type
data=data
} else {
let { type, data } = router.currentRoute.value.query
type=type
data=data
}
let typeData = null
if (data) typeData = JSON.parse(data)
if(data&&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 {
seachSelectData.data={[type]:typeData} seachSelectData.data = { [type]: typeData }
} }
} }
getDataList(seachSelectData.data) getDataList(seachSelectData.data)