罗世杰:未完成Dropdown

This commit is contained in:
LuoShijie
2023-11-24 00:42:46 +08:00
parent bcd878f09a
commit 67dd393a7f
3 changed files with 132 additions and 28 deletions

View File

@@ -3,7 +3,7 @@
<view class="root">
<view class="mask" @click="handleMask"></view>
<view class="list-container">
<view class="item" v-for="(item,index) in list" :class="{isActive: activeIndex === index}"
<view class="item" v-for="(item,index) in list" :key="item" :class="{isActive: activeIndex === index}"
@click="handleActive(index)">
<text class="list-text">{{item}}</text>
</view>
@@ -30,7 +30,7 @@
},
data() {
return {
activeIndex: -1,
activeIndex: 0,
queryInfo: {}
}
},
@@ -39,29 +39,89 @@
this.$emit('cancelDrop');
},
sendQueryInfo() {
console.log(this.queryInfo);
if (this.type === '行业') {
this.queryInfo = {
business: this.list[this.activeIndex]
}
} else if (this.type === '区域') {
this.queryInfo = {
region: this.list[this.activeIndex]
}
} else if (this.type === '面积') {
this.queryInfo = {
areatype: this.activeIndex + 1
}
} else if (this.type === '筛选') {
this.queryInfo = {
sortType: this.activeIndex + 1
}
this.queryInfo = {
business: this.activeIndex
}
}
if (this.type === '区域') {
this.queryInfo = {
region: this.activeIndex
}
}
if (this.type === '面积') {
this.queryInfo = {
areatype: this.activeIndex
}
}
if (this.type === '筛选') {
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);
},
async handleActive(index) {
this.activeIndex = index;
this.sendQueryInfo(index);
this.sendQueryInfo();
// 设置一个定时器等待200毫秒
const delayPromise = this.delay(200);
// 等待定时器完成