罗世杰:fixed:修复各个使用下拉框处异常请求问题

This commit is contained in:
LuoShijie
2023-11-24 21:44:39 +08:00
parent 67dd393a7f
commit 742f2a7023
9 changed files with 153 additions and 109 deletions

View File

@@ -15,8 +15,8 @@
</view> </view>
</view> </view>
<view class="item-border"> <view class="item-border">
<DropDownItem v-if="activeIndex !== -1" :list="tablist" @cancelDrop="cancelDrop" @getQueryInfo="getQueryInfo" <DropDownItem v-show="activeIndex !== -1" :list="tablist" @cancelDrop="cancelDrop" @getQueryInfo="getQueryInfo"
:type="title[activeIndex]" :activeChoose = "setActiveTag"/> :type="title[activeIndex]" :activeChoose = "setActiveTag" :key="tablist" ref="dropdownitem" @cancelPageNum="cancelPageNum"/>
</view> </view>
</view> </view>
</template> </template>
@@ -35,6 +35,8 @@
return { return {
title: ['行业', '区域', '面积', '筛选'], title: ['行业', '区域', '面积', '筛选'],
activeIndex: -1, activeIndex: -1,
// 是否显示下拉框
isShow: false,
postlist: [ postlist: [
[], [],
[], [],
@@ -47,19 +49,30 @@
areatype: '', areatype: '',
business: '' business: ''
}, },
// 当前行业下拉列表 // 当前选中的行业下拉列表
currentClassList: 0, currentClassActive: 0,
// 当前区域下拉列表 // 当前选中的区域下拉列表
currentRegionList: 0, currentRegionActive: 0,
// 当前面积下拉列表 // 当前选中的面积下拉列表
currentAreaList: 0, currentAreaActive: 0,
// 当前筛选下拉列表 // 当前选中的筛选下拉列表
currentFilterList: 0, currentFilterActive: 0,
}; };
}, },
computed: { computed: {
tablist: function() { tablist: function() {
return this.postlist[this.activeIndex] 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() { created() {
@@ -70,6 +83,11 @@
// this.postlist[2].unshift('所有面积') // this.postlist[2].unshift('所有面积')
// this.postlist[3].unshift('全部') // this.postlist[3].unshift('全部')
}, },
watch: {
setActiveTag (reset){
}
},
methods: { methods: {
changeActiveIndex(index) { changeActiveIndex(index) {
if (this.activeIndex === index) { if (this.activeIndex === index) {
@@ -80,49 +98,54 @@
cancelDrop() { cancelDrop() {
this.activeIndex = -1; this.activeIndex = -1;
}, },
cancelPageNum(){
this.$emit('cancelPageNum')
},
getQueryInfo(querys) { getQueryInfo(querys) {
console.log(querys, 'getquerysinfo'); 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 = {
...this.queryInfo, ...this.queryInfo,
...querys ...querys
} }
const query = this.$u.queryParams(this.queryInfo) const query = this.$u.queryParams(this.queryInfo)
console.log(query, 'dropquery'); console.log(querys, 'dropquery');
this.$emit('getQueryInfo', this.queryInfo) this.$emit('getQueryInfo', this.queryInfo)
}, },
setActiveTag(){ resetInfo(){
if(this.activeIndex == 0){ console.log("重置了Dropdown");
return this.currentClassList this.queryInfo = {
}else if(this.activeIndex == 1){ region: '',
return this.currentRegionList sortType: '',
}else if(this.activeIndex == 2){ areatype: '',
return this.currentAreaList business: ''
}else{
return this.currentFilterList
} }
this.currentClassActive = 0
this.currentRegionActive = 0
this.currentAreaActive = 0
this.currentFilterActive = 0
// 重置各下拉框保存的数据
this.$refs.dropdownitem.resetQueryInfo()
} }
} }
} }

View File

@@ -3,7 +3,7 @@
<view class="root"> <view class="root">
<view class="mask" @click="handleMask"></view> <view class="mask" @click="handleMask"></view>
<view class="list-container"> <view class="list-container">
<view class="item" v-for="(item,index) in list" :key="item" :class="{isActive: activeIndex === index}" <view class="item" v-for="(item,index) in list" :key="item" :class="{isActive: (activeChoose == index)}"
@click="handleActive(index)"> @click="handleActive(index)">
<text class="list-text">{{item}}</text> <text class="list-text">{{item}}</text>
</view> </view>
@@ -22,10 +22,15 @@
} }
}, },
type: { type: {
type: String,
default () { default () {
return '' return ''
} }
},
activeChoose: {
type: Number,
default () {
return 0
}
} }
}, },
data() { data() {
@@ -40,87 +45,75 @@
}, },
sendQueryInfo() { sendQueryInfo() {
console.log(this.queryInfo); console.log(this.queryInfo);
if (this.type === '行业') { console.log(this.type);
console.log(this.activeIndex);
if (this.type === '行业') {
if(this.list[this.activeIndex] == '全部'){
this.queryInfo = {
business: ''
}
}else{
this.queryInfo = { this.queryInfo = {
business: this.activeIndex business: this.activeIndex
} }
}
} else if (this.type === '区域') {
} if(this.list[this.activeIndex] == '全区域'){
if (this.type === '区域') { this.queryInfo = {
region: ''
}
}else{
this.queryInfo = { this.queryInfo = {
region: this.activeIndex region: this.activeIndex
} }
}
} } else if (this.type === '面积') {
if (this.type === '面积') { if(this.list[this.activeIndex] == '任意面积'){
this.queryInfo = {
areatype: ''
}
}else {
this.queryInfo = { this.queryInfo = {
areatype: this.activeIndex areatype: this.activeIndex
} }
}
} else if (this.type === '筛选') {
} if(this.list[this.activeIndex] == '全部'){
if (this.type === '筛选') { this.queryInfo = {
sortType: ''
}
}else{
this.queryInfo = { this.queryInfo = {
sortType: this.activeIndex 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 // 发送queryInfo
console.log(this.queryInfo, 'sendqueryInfo'); console.log(this.queryInfo, 'sendqueryInfo');
this.$emit('getQueryInfo', this.queryInfo); 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) { async handleActive(index) {
this.activeIndex = index; this.activeIndex = index;
// 取消当前页面的pageNum参数
this.$emit('cancelPageNum');
this.sendQueryInfo(); this.sendQueryInfo();
// 设置一个定时器等待200毫秒 // 设置一个定时器等待200毫秒
const delayPromise = this.delay(200); const delayPromise = this.delay(200);

View File

@@ -1,6 +1,6 @@
<template> <template>
<view> <view>
<ShowShopListItem v-for="item in shopInfoList" :key="item" :shopInfo="item" :is-adshow="isADshow" <ShowShopListItem v-for="item in shopInfoList" :shopInfo="item" :is-adshow="isADshow"
:adlinkPath="adlinkPath" :show-style="showStyle" :is-edit="isEdit" @delItem="handleDel" :adlinkPath="adlinkPath" :show-style="showStyle" :is-edit="isEdit" @delItem="handleDel"
@updateItem="hanldeUpdate"></ShowShopListItem> @updateItem="hanldeUpdate"></ShowShopListItem>
</view> </view>

View File

@@ -12,7 +12,7 @@
</view> </view>
<view> <view>
<DropDown @getQueryInfo="getShopList"></DropDown> <DropDown @getQueryInfo="getShopList" ref="dropdown" @cancelPageNum="cancelPageNum"></DropDown>
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<ShowShopList :showStyle="2" :adlinkPath="adlinkPath" :listType="3" :shopInfoList="shopInfoList" /> <ShowShopList :showStyle="2" :adlinkPath="adlinkPath" :listType="3" :shopInfoList="shopInfoList" />
@@ -55,6 +55,7 @@
// this.pageNum=1 // this.pageNum=1
// } // }
this.getShopList(q, "refresh") this.getShopList(q, "refresh")
this.$refs.dropdown.resetInfo()
// } // }
}, },
@@ -128,6 +129,10 @@
this.customQuery = q this.customQuery = q
return q return q
}, },
cancelPageNum() {
this.pageNum = 1;
this.refresh = true
}
} }
} }
</script> </script>

View File

@@ -12,7 +12,7 @@
</view> </view>
<view> <view>
<DropDown @getQueryInfo="getShopList"></DropDown> <DropDown @getQueryInfo="getShopList" ref="dropdown" @cancelPageNum="cancelPageNum"></DropDown>
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<ShowShopList :showStyle="2" :adlinkPath="adlinkPath" :listType="4" :shopInfoList="shopInfoList" /> <ShowShopList :showStyle="2" :adlinkPath="adlinkPath" :listType="4" :shopInfoList="shopInfoList" />
@@ -55,6 +55,7 @@
// this.pageNum=1 // this.pageNum=1
// } // }
this.getShopList(q, "refresh") this.getShopList(q, "refresh")
this.$refs.dropdown.resetInfo()
// } // }
}, },
@@ -128,6 +129,10 @@
this.customQuery = q this.customQuery = q
return q return q
}, },
cancelPageNum() {
this.pageNum = 1;
this.refresh = true
}
} }
} }
</script> </script>

View File

@@ -12,7 +12,7 @@
</view> </view>
<view> <view>
<DropDown @getQueryInfo="getShopList"></DropDown> <DropDown @getQueryInfo="getShopList" ref="dropdown" @cancelPageNum="cancelPageNum"></DropDown>
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<SearchShopList :showStyle="1" :searchInfoList="searchInfoList" /> <SearchShopList :showStyle="1" :searchInfoList="searchInfoList" />
@@ -54,7 +54,7 @@
// this.pageNum=1 // this.pageNum=1
// } // }
this.getShopList(q, "refresh") this.getShopList(q, "refresh")
this.$refs.dropdown.resetInfo()
// } // }
}, },
onReachBottom() { onReachBottom() {
@@ -127,6 +127,10 @@
this.customQuery = q this.customQuery = q
return q return q
}, },
cancelPageNum() {
this.pageNum = 1;
this.refresh = true
}
} }
} }
</script> </script>

View File

@@ -12,7 +12,7 @@
</view> </view>
<view> <view>
<DropDown @getQueryInfo="getShopList"></DropDown> <DropDown @getQueryInfo="getShopList" ref="dropdown" @cancelPageNum="cancelPageNum"></DropDown>
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<ShowShopList :showStyle="1" :shopInfoList="shopInfoList" /> <ShowShopList :showStyle="1" :shopInfoList="shopInfoList" />
@@ -54,6 +54,7 @@
// this.pageNum=1 // this.pageNum=1
// } // }
this.getShopList(q, "refresh") this.getShopList(q, "refresh")
this.$refs.dropdown.resetInfo()
// } // }
}, },
@@ -127,6 +128,10 @@
this.customQuery = q this.customQuery = q
return q return q
}, },
cancelPageNum() {
this.pageNum = 1;
this.refresh = true
}
} }
} }
</script> </script>

View File

@@ -7,7 +7,7 @@
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<DropDown @getQueryInfo="getShopList"></DropDown> <DropDown @getQueryInfo="getShopList" ref="dropdown" @cancelPageNum="cancelPageNum"></DropDown>
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<SearchShopList :showStyle="1" :searchInfoList="searchInfoList" /> <SearchShopList :showStyle="1" :searchInfoList="searchInfoList" />
@@ -52,6 +52,7 @@
// this.pageNum=1 // this.pageNum=1
// } // }
this.getShopList(q, "refresh") this.getShopList(q, "refresh")
this.$refs.dropdown.resetInfo()
// } // }
}, },
@@ -133,6 +134,10 @@
...query ...query
}) })
return q return q
},
cancelPageNum() {
this.pageNum = 1;
this.refresh = true
} }
} }

View File

@@ -8,7 +8,7 @@
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<DropDown @getQueryInfo="getShopList"></DropDown> <DropDown @getQueryInfo="getShopList" ref="dropdown" @cancelPageNum="cancelPageNum"></DropDown>
</view> </view>
<view class="marginLR10"> <view class="marginLR10">
<ShowShopList :showStyle="1" :shopInfoList="shopInfoList"></ShowShopList> <ShowShopList :showStyle="1" :shopInfoList="shopInfoList"></ShowShopList>
@@ -53,7 +53,7 @@
// this.pageNum=1 // this.pageNum=1
// } // }
this.getShopList(q, "refresh") this.getShopList(q, "refresh")
this.$refs.dropdown.resetInfo()
// } // }
}, },
onReachBottom() { onReachBottom() {
@@ -133,6 +133,10 @@
...query ...query
}) })
return q return q
},
cancelPageNum() {
this.pageNum = 1;
this.refresh = true
} }
} }
} }