From 742f2a7023d3c7c9f4fcea87b415776c24786363 Mon Sep 17 00:00:00 2001 From: LuoShijie Date: Fri, 24 Nov 2023 21:44:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=97=E4=B8=96=E6=9D=B0=EF=BC=9Afixed?= =?UTF-8?q?=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=90=84=E4=B8=AA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=E5=A4=84=E5=BC=82=E5=B8=B8=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/DropDown/DropDown.vue | 103 +++++++++++++-------- components/DropDown/DropDownItem.vue | 113 +++++++++++------------ components/ShowShopList/ShowShopList.vue | 2 +- pages/index/NavBarPages/czxx/czxx.vue | 7 +- pages/index/NavBarPages/xmzs/xmzs.vue | 7 +- pages/index/NavBarPages/zdxx/zdxx.vue | 8 +- pages/index/NavBarPages/zrxx/zrxx.vue | 7 +- pages/shopAddress/shopAddress.vue | 7 +- pages/shopTransfer/shopTransfer.vue | 8 +- 9 files changed, 153 insertions(+), 109 deletions(-) diff --git a/components/DropDown/DropDown.vue b/components/DropDown/DropDown.vue index 924d899..295bcc7 100644 --- a/components/DropDown/DropDown.vue +++ b/components/DropDown/DropDown.vue @@ -15,8 +15,8 @@ - + @@ -35,6 +35,8 @@ return { title: ['行业', '区域', '面积', '筛选'], activeIndex: -1, + // 是否显示下拉框 + isShow: false, postlist: [ [], [], @@ -47,19 +49,30 @@ areatype: '', business: '' }, - // 当前行业下拉列表 - currentClassList: 0, - // 当前区域下拉列表 - currentRegionList: 0, - // 当前面积下拉列表 - currentAreaList: 0, - // 当前筛选下拉列表 - currentFilterList: 0, + // 当前选中的行业下拉列表项 + currentClassActive: 0, + // 当前选中的区域下拉列表项 + currentRegionActive: 0, + // 当前选中的面积下拉列表项 + currentAreaActive: 0, + // 当前选中的筛选下拉列表项 + currentFilterActive: 0, }; }, computed: { tablist: function() { return this.postlist[this.activeIndex] + }, + setActiveTag: function(){ + if(this.activeIndex == 0){ + return this.currentClassActive + }else if(this.activeIndex == 1){ + return this.currentRegionActive + }else if(this.activeIndex == 2){ + return this.currentAreaActive + }else if(this.activeIndex == 3){ + return this.currentFilterActive + } } }, created() { @@ -70,6 +83,11 @@ // this.postlist[2].unshift('所有面积') // this.postlist[3].unshift('全部') }, + watch: { + setActiveTag (reset){ + + } + }, methods: { changeActiveIndex(index) { if (this.activeIndex === index) { @@ -80,49 +98,54 @@ cancelDrop() { this.activeIndex = -1; }, + cancelPageNum(){ + this.$emit('cancelPageNum') + }, getQueryInfo(querys) { - + console.log(querys, 'getquerysinfo'); // 修改当前选择的各选项卡下标 - if (this.activeIndex === 0) { - this.currentClassList = querys.business - }else if (this.activeIndex === 1) { - this.currentRegionList = querys.region - }else if (this.activeIndex === 2) { - this.currentAreaList = querys.areatype - }else if (this.activeIndex === 3) { - this.currentFilterList = querys.sortType - } - // 记忆各下拉框数据 - if(querys.business==0){ - querys.business = '' - }else{ - querys.business = this.postlist[0][this.currentClassList] - } - if(querys.region==0){ - querys.region = '' - }else querys.region = this.postlist[1][this.currentRegionList] - + if (this.activeIndex === 0) { + this.currentClassActive = querys.business + }else if (this.activeIndex === 1) { + this.currentRegionActive = querys.region + }else if (this.activeIndex === 2) { + this.currentAreaActive = querys.areatype + }else if (this.activeIndex === 3) { + this.currentFilterActive = querys.sortType + } + // 特殊处理行业、区域 + if(querys.business){ + querys.business = this.tablist[this.currentClassActive] + } + if(querys.region){ + querys.region = this.tablist[this.currentRegionActive] + } + this.queryInfo = { ...this.queryInfo, ...querys } const query = this.$u.queryParams(this.queryInfo) - console.log(query, 'dropquery'); + console.log(querys, 'dropquery'); this.$emit('getQueryInfo', this.queryInfo) }, - setActiveTag(){ - if(this.activeIndex == 0){ - return this.currentClassList - }else if(this.activeIndex == 1){ - return this.currentRegionList - }else if(this.activeIndex == 2){ - return this.currentAreaList - }else{ - return this.currentFilterList + resetInfo(){ + console.log("重置了Dropdown"); + this.queryInfo = { + region: '', + sortType: '', + areatype: '', + business: '' } + this.currentClassActive = 0 + this.currentRegionActive = 0 + this.currentAreaActive = 0 + this.currentFilterActive = 0 + // 重置各下拉框保存的数据 + this.$refs.dropdownitem.resetQueryInfo() } } } diff --git a/components/DropDown/DropDownItem.vue b/components/DropDown/DropDownItem.vue index 9bf56eb..b629bc8 100644 --- a/components/DropDown/DropDownItem.vue +++ b/components/DropDown/DropDownItem.vue @@ -3,7 +3,7 @@ - {{item}} @@ -22,10 +22,15 @@ } }, type: { - type: String, default () { return '' } + }, + activeChoose: { + type: Number, + default () { + return 0 + } } }, data() { @@ -40,87 +45,75 @@ }, sendQueryInfo() { console.log(this.queryInfo); + console.log(this.type); + console.log(this.activeIndex); + if (this.type === '行业') { - + if(this.list[this.activeIndex] == '全部'){ + this.queryInfo = { + business: '' + } + }else{ this.queryInfo = { business: this.activeIndex } + } - - } - if (this.type === '区域') { - + } else if (this.type === '区域') { + if(this.list[this.activeIndex] == '全区域'){ + this.queryInfo = { + region: '' + } + }else{ this.queryInfo = { region: this.activeIndex } - - } - if (this.type === '面积') { - + } + } else if (this.type === '面积') { + if(this.list[this.activeIndex] == '任意面积'){ + this.queryInfo = { + areatype: '' + } + }else { this.queryInfo = { areatype: this.activeIndex } + } - - } - if (this.type === '筛选') { - + } else if (this.type === '筛选') { + if(this.list[this.activeIndex] == '全部'){ + this.queryInfo = { + sortType: '' + } + }else{ this.queryInfo = { sortType: this.activeIndex } - + } } - // if (this.type === '行业') { - // if(this.list[this.activeIndex] == '全部'){ - // this.queryInfo = { - // business: '' - // } - // }else{ - // this.queryInfo = { - // business: this.activeIndex - // } - // } - - // } else if (this.type === '区域') { - // if(this.list[this.activeIndex] == '全区域'){ - // this.queryInfo = { - // region: '' - // } - // }else{ - // this.queryInfo = { - // region: this.activeIndex - // } - // } - // } else if (this.type === '面积') { - // if(this.list[this.activeIndex] == '任意面积'){ - // this.queryInfo = { - // areatype: '' - // } - // }else { - // this.queryInfo = { - // areatype: this.activeIndex - // } - // } - - // } else if (this.type === '筛选') { - // if(this.list[this.activeIndex] == '全部'){ - // this.queryInfo = { - // sortType: '' - // } - // }else{ - // this.queryInfo = { - // sortType: this.activeIndex - // } - // } - - // } // 发送queryInfo console.log(this.queryInfo, 'sendqueryInfo'); this.$emit('getQueryInfo', this.queryInfo); }, + resetQueryInfo(){ + console.log("重置了DropdownItem"); + this.currentClassActive = 0 + this.currentRegionActive = 0 + this.currentAreaActive = 0 + this.currentFilterActive = 0 + this.activeIndex = 0 + this.queryInfo = { + region: '', + sortType: '', + areatype: '', + business: '' + } + }, async handleActive(index) { this.activeIndex = index; + // 取消当前页面的pageNum参数 + this.$emit('cancelPageNum'); this.sendQueryInfo(); // 设置一个定时器,等待200毫秒 const delayPromise = this.delay(200); diff --git a/components/ShowShopList/ShowShopList.vue b/components/ShowShopList/ShowShopList.vue index 79e5b01..483d7cc 100644 --- a/components/ShowShopList/ShowShopList.vue +++ b/components/ShowShopList/ShowShopList.vue @@ -1,6 +1,6 @@