From 9879550544e00da794e3af40a6da4fbcf53292e5 Mon Sep 17 00:00:00 2001 From: luJianJun <2587063613@qq.com> Date: Thu, 27 Jul 2023 19:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E6=88=BF=E6=BA=90=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/selectTabBox/selectTabBox.vue | 94 +++++++++++--------- src/views/detail.vue | 17 ++-- 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/src/components/selectTabBox/selectTabBox.vue b/src/components/selectTabBox/selectTabBox.vue index 0f75ca1..810d518 100644 --- a/src/components/selectTabBox/selectTabBox.vue +++ b/src/components/selectTabBox/selectTabBox.vue @@ -19,9 +19,11 @@ @click="setSelectData(item.id, item.data, item.name)" v-for="(item, i) in list" :key="i">
{{ item.name }}
 >  -
+
{{ - selectData.data && selectData.data.length === 0||selectData.data.length===selectTabCheck.data.length ?'不限' : + selectData.data && selectData.data.length === + 0 || selectData.data.length === selectTabCheck.data.length ? '不限' : selectData.data && selectData.data.length }}
@@ -75,7 +77,8 @@ v-show="selectTabCheck.id === item.id && selectTabCheck.id"> > 
{{ - selectData.data && selectData.data.length === 0||selectData.data.length===selectTabCheck.data.length ? '不限' : + selectData.data && selectData.data.length === + 0 || selectData.data.length === selectTabCheck.data.length ? '不限' : selectData.data && selectData.data.length }}
@@ -468,7 +471,7 @@ let listSortCheck = (item) => { //出租方式 -let hireTypeArr = shallowReactive([{ hireType: [], title: '不限' }, { title: '合租',id:1, hireType: [] }, { hireType: [],id:2, title: '整租' }]) +let hireTypeArr = shallowReactive([{ hireType: [], title: '不限' }, { title: '合租', id: 1, hireType: [] }, { hireType: [], id: 2, title: '整租' }]) //设置出租方式 let setHireTypeArr = (type, id) => { @@ -577,60 +580,66 @@ let cleanSelect = () => { } //查找数据 -let getAddressListId=(id,type)=>{ - let data=null - let checkList= type==='location'?list:type==='types'?hireTypeArr:type==='school'?store.state.seachTypeData[0].where:'' - let dataId=type==='types'?id.substring(0,1):id - checkList.map(res=>{ - if(res.id==dataId){ - if(type==='types'){ - data=getHireType(res.hireType,id) - }else{ - data= res +let getAddressListId = (id, type) => { + let data = null + let checkList = type === 'location' ? list : type === 'types' ? hireTypeArr : type === 'school' ? store.state.seachTypeData[0].where : '' + let dataId = type === 'types' ? id.substring(0, 1) : id + checkList.map(res => { + if (res.id == dataId) { + if (type === 'types') { + data = getHireType(res.hireType, id) + } else { + data = res } - } + } }) return data } //查找出租类型 -let getHireType=(data,id)=>{ - let obj=null - data.map(res=>{ - if(res.id==id)obj=res +let getHireType = (data, id) => { + console.log(data) + let obj = null + data.map(res => { + if (res.id == id) obj = res }) return obj } //解数据 -let deconstructionData=(data={})=>{ +let deconstructionData = (data = {}) => { //第一个为type //type第一个参数为一级区域 第二个参数为二级区域 - let seachData={} + let seachData = {} let key = Object.keys(data) - key.map((res,index)=>{ - if(index===0){//类型 - seachData['type']=res - seachData['selectData']=seachData['type']==='location'?data[res].split(','):seachData['type']==='types'?getAddressListId(data[res],'types'):seachData['type']==='school'?getAddressListId(data[res],'school'):'' + key.map((res, index) => { + if (index === 0) {//类型 + seachData['type'] = res + seachData['selectData'] = seachData['type'] === 'location' ? data[res].split(',') : seachData['type'] === 'types' ? getAddressListId(data[res], 'types') : seachData['type'] === 'school' ? getAddressListId(data[res], 'school') : '' } - if(index===1){//类型参数 - if(seachData['type']!=='location') return - let address=getAddressListId(data[res],'location') - seachData['areaItem']={} - seachData['areaItem'].id=address.id - seachData['areaItem'].name=address.name - seachData['areaItem'].data=address.data + if (index === 1) {//类型参数 + if (seachData['type'] === 'location') { + let address = getAddressListId(data[res], 'location') + seachData['areaItem'] = {} + seachData['areaItem'].id = address.id + seachData['areaItem'].name = address.name + seachData['areaItem'].data = address.data + } + } + if (index === 2) { + seachData['cotenancy'] = res + seachData['cotenancyData'] = getAddressListId(data[res], 'types') } }) return seachData } -let deconstructionSeachData=null +let deconstructionSeachData = null //根据路由设置参数 let setRouterQuerySet = ref(true) let routerQuerySet = () => { - deconstructionSeachData=deconstructionData(routeQuery.data) + deconstructionSeachData = deconstructionData(routeQuery.data) console.log(deconstructionSeachData) if (!setRouterQuerySet.value) return //路由参数设置 @@ -642,8 +651,8 @@ let routerQuerySet = () => { otherData.value = [{ title: '认证房源', id: 'isverified' }, { title: '有电梯', id: 'iselevator' }, { title: '有阳台', id: 'issunshinearea' }] } if (Object.keys(routeQuery.data).length > 0) { - if (Object.keys(deconstructionSeachData).length===0) return - let data = deconstructionSeachData.areaItem + if (Object.keys(deconstructionSeachData).length === 0) return + // let data = deconstructionSeachData.areaItem if (deconstructionSeachData.type === 'school') { selectPosition.value = 'school' @@ -664,15 +673,14 @@ let routerQuerySet = () => { selectTabCheck.data = deconstructionSeachData.areaItem.data; selectData.data = seachAreaId(deconstructionSeachData.selectData) - 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 + if (deconstructionSeachData.cotenancy) { + let type = deconstructionSeachData.cotenancyData.id.toString().substring(0, 1) + hireTypeObj.id = deconstructionSeachData.cotenancyData.id + hireTypeObj.title = deconstructionSeachData.cotenancyData.title hireTypeObj.hireId = type == 1 ? '合租' : type == 2 ? '整租' : '不限' } - nextTick(()=>{ + if(deconstructionSeachData.selectData[0]) + nextTick(() => { setCheckBoxData(deconstructionSeachData.selectData)//设置地区选项 }) } diff --git a/src/views/detail.vue b/src/views/detail.vue index 7c79bc9..9f13ac1 100644 --- a/src/views/detail.vue +++ b/src/views/detail.vue @@ -963,7 +963,6 @@ -