详情顶部导航跳转

This commit is contained in:
2023-07-26 19:27:30 +08:00
parent 44d99b26ce
commit 77b5e5e6aa
7 changed files with 44 additions and 47 deletions

View File

@@ -146,9 +146,9 @@ let loadFinish = () => {
} }
//监听路由 //监听路由
const route = useRoute() const route = useRouter()
let routePath = ref('') let routePath = ref('')
routePath.value = route.path routePath.value = route.currentRoute.value.meta.path
//地区数据 //地区数据
let location = reactive({ data: {} }) let location = reactive({ data: {} })
location.data = store.state.indexData && store.state.indexData.config && store.state.indexData.config.location location.data = store.state.indexData && store.state.indexData.config && store.state.indexData.config.location

View File

@@ -133,8 +133,8 @@ let openInfo = (data) => {
//监听路由 //监听路由
const route = useRoute() const route = useRoute()
let routePath = ref('') let routePath = ref('')
routePath.value = route.path routePath.value = route.meta.path
tabBtnType.value = route.path tabBtnType.value = route.meta.path
</script> </script>
<style scoped> <style scoped>

View File

@@ -142,8 +142,7 @@ let getLocationData = (data) => {
//监听路由 //监听路由
const route = useRouter() const route = useRouter()
let routePath = ref('') let routePath = ref('')
routePath.value = route.currentRoute.value.path routePath.value = route.currentRoute.value.meta.path
// console.log(route)
watchEffect(() => { watchEffect(() => {
seachSchoolBtn.data = store.state.seachTypeData[0] ? store.state.seachTypeData[0].where : [] seachSchoolBtn.data = store.state.seachTypeData[0] ? store.state.seachTypeData[0].where : []
@@ -174,18 +173,6 @@ let seachList = (item) => {
houseingPageType:routePath.value === '/needHousing'?6:routePath.value === '/intermediaryHousing'?1:routePath.value === '/personHousing'?0:0 houseingPageType:routePath.value === '/needHousing'?6:routePath.value === '/intermediaryHousing'?1:routePath.value === '/personHousing'?0:0
} }
}) })
// if (routePath.value === '/') {
// route.push({
// path: '/seachPage',
// query: {
// keyword: seachAllType.keyword
// }
// })
// }else{
// setSeachConditions()
// }
// getDataList(seachAllType)
} }
//设置搜索数据 //设置搜索数据
@@ -227,7 +214,7 @@ let setHotSeach = (item) => {
//点击选项 //点击选项
let checkBtn = (data, type, areaItem) => { let checkBtn = (data, type, areaItem) => {
console.log(data, type, areaItem) // console.log(data, type, areaItem)
getDataList(type, data, areaItem) getDataList(type, data, areaItem)
} }

View File

@@ -265,10 +265,10 @@ let configData = reactive({ data: {} })
const route = useRouter() 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.meta.path
if(route.currentRoute.value.params.type){ if (route.currentRoute.value.params.type) {
routeQuery.data = route.currentRoute.value.params routeQuery.data = route.currentRoute.value.params
}else{ } else {
routeQuery.data = route.currentRoute.value.query routeQuery.data = route.currentRoute.value.query
} }
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
@@ -575,6 +575,7 @@ let cleanSelect = () => {
//根据路由设置参数 //根据路由设置参数
let setRouterQuerySet = ref(true) let setRouterQuerySet = ref(true)
let routerQuerySet = () => { let routerQuerySet = () => {
console.log(123, routeQuery)
if (!setRouterQuerySet.value) return if (!setRouterQuerySet.value) return
//路由参数设置 //路由参数设置
if ((routeQuery.data && routeQuery.data.houseingPageType === '1') || (routePath.value === '/intermediaryHousing')) { if ((routeQuery.data && routeQuery.data.houseingPageType === '1') || (routePath.value === '/intermediaryHousing')) {
@@ -595,11 +596,20 @@ let routerQuerySet = () => {
hireTypeObj.title = data.name hireTypeObj.title = data.name
hireTypeObj.hireId = type == 1 ? '合租' : type == 2 ? '整租' : '不限' hireTypeObj.hireId = type == 1 ? '合租' : type == 2 ? '整租' : '不限'
} else if (routeQuery.data.type === 'location') { } else if (routeQuery.data.type === 'location') {
let areaItem = JSON.parse(routeQuery.data.areaItem) let areaItem = routeQuery.data.areaItem?JSON.parse(routeQuery.data.areaItem):''
selectTabCheck.id = areaItem.id; selectTabCheck.id = areaItem.id * 1;
selectTabCheck.title = areaItem.name selectTabCheck.title = areaItem.name
selectTabCheck.data = list[areaItem.id].data; selectTabCheck.data = list[areaItem.id].data;
selectData.data = seachAreaId(data) selectData.data = seachAreaId(data)
console.log(selectData.data.length)
if (routeQuery.data.types) {
let types = JSON.parse(routeQuery.data.types)
let {data} = types
let type = data.id.toString().substring(0, 1)
hireTypeObj.id = selectData.data.length==0?'':data.id
hireTypeObj.title =selectData.data.length==0?'':data.name
hireTypeObj.hireId = type == 1 ? '合租' : type == 2 ? '整租' : '不限'
}
setCheckBoxData(data)//设置地区选项 setCheckBoxData(data)//设置地区选项
} }
} }
@@ -612,7 +622,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) console.log('route', route)
if (setRouterQuerySet.value) { if (setRouterQuerySet.value) {
setRegionList()//设置地区数据 setRegionList()//设置地区数据
setSchoolData()//设置学校数据 setSchoolData()//设置学校数据

View File

@@ -9,7 +9,8 @@ const routes = [
name: 'home', name: 'home',
component: HomeView, component: HomeView,
meta: { meta: {
title: "首页" title: "首页",
path:'/'
} }
}, },
{ {
@@ -46,38 +47,43 @@ const routes = [
} }
}, },
{//个人房源 {//个人房源
path: '/personHousing/:type?/:data?/:areaItem?', path: '/personHousing/:type?/:data?/:areaItem?/:types?',
component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/person.vue'), component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/person.vue'),
meta: { meta: {
title: '个人房源' title: '个人房源',
path:'/personHousing'
} }
}, },
{//中介房源 {//中介房源
path: '/intermediaryHousing', path: '/intermediaryHousing',
component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/intermediary.vue'), component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/intermediary.vue'),
meta: { meta: {
title: '中介房源' title: '中介房源',
path:'/intermediaryHousing'
} }
}, },
{//求房源 {//求房源
path: '/needHousing', path: '/needHousing',
component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/needHousing.vue'), component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/needHousing.vue'),
meta: { meta: {
title: '求房源' title: '求房源',
path:'/needHousing'
} }
}, },
{//搜索 {//搜索
path: '/seachPage', path: '/seachPage',
component: () => import(/* webpackChunkName: "seachPage" */ '@/views/seachIndex.vue'), component: () => import(/* webpackChunkName: "seachPage" */ '@/views/seachIndex.vue'),
meta: { meta: {
title: '搜索' title: '搜索',
path:'/seachPage'
} }
}, },
{ {
path: "/apartment", path: "/apartment",
component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/apartment.vue'), component: () => import(/* webpackChunkName: "housing" */ '@/views/housingView/apartment.vue'),
meta: { meta: {
title: "品牌公寓" title: "品牌公寓",
path:'/apartment'
} }
}, },
{ {
@@ -104,10 +110,7 @@ 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==='/needHousing'?'/needHousing': store.state.routeList.secondaryIndex.path = from.meta.path
from.path==='/intermediaryHousing'?'/intermediaryHousing':
from.path==='/personHousing'?'/personHousing':
from.path==='/seachPage'?'/seachPage':''
} }
next() next()
let meta = to['meta'] || {} let meta = to['meta'] || {}

View File

@@ -1107,14 +1107,14 @@ let setNavigation = () => {
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}/location/${housingInfo['data']['info'].location.substring(0, 1)}`) console.log(`${store.state.routeList['secondaryIndex'].path}/location/${JSON.stringify([housingInfo['data']['info'].location.substring(0, 1)])}`)
store.state.routeList['thirdIndex'] = { store.state.routeList['thirdIndex'] = {
path: `${store.state.routeList['secondaryIndex'].path}/location/${housingInfo['data']['info'].location.substring(0, 1)}`, path: `${store.state.routeList['secondaryIndex'].path}/location/${JSON.stringify([housingInfo['data']['info'].location.substring(0, 1)])}/${JSON.stringify({id:housingInfo['data']['info'].location.substring(0, 1),name:location[housingInfo['data']['info'].location.substring(0, 1)]})}/${JSON.stringify({type:'types',data:{name:type[housingInfo['data']['info'].type.substring(0, 1)],id:housingInfo['data']['info'].type}})}`,
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)
store.state.routeList['fourthIndex'] = { store.state.routeList['fourthIndex'] = {
path: "", path: `${store.state.routeList['secondaryIndex'].path}/location/${JSON.stringify([housingInfo['data']['info'].location.substring(0, 3)])}/${JSON.stringify({id:housingInfo['data']['info'].location.substring(0, 1),name:location[housingInfo['data']['info'].location.substring(0, 1)]})}/${JSON.stringify({type:'types',data:{name:type[housingInfo['data']['info'].type.substring(0, 3)],id:housingInfo['data']['info'].type}})}`,
title: `${location[housingInfo['data']['info'].location]}${type[housingInfo['data']['info'].type]}` title: `${location[housingInfo['data']['info'].location]}${type[housingInfo['data']['info'].type]}`
} }
} }

View File

@@ -143,20 +143,17 @@ let downLoadMore = () => {
//listImg //listImg
onMounted(() => { onMounted(() => {
console.log(123)
let type=null,data=null let type=null,data=null
console.log(router.currentRoute.value.params)
if (router.currentRoute.value.params.type) { if (router.currentRoute.value.params.type) {
let { type, data } = router.currentRoute.value.params type=router.currentRoute.value.params.type
type=type data=router.currentRoute.value.params.data
data=data
} else { } else {
let { type, data } = router.currentRoute.value.query type=router.currentRoute.value.query.type
type=type data=router.currentRoute.value.query.data
data=data
} }
let typeData = null let typeData = null
if (data) typeData = JSON.parse(data) 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 }