Files
city-store-transfer/components/DropDown/DropDown.vue
2023-11-18 23:00:12 +08:00

141 lines
3.0 KiB
Vue

<template>
<view class="container">
<view class="tabs-bg" />
<view class="tabs">
<view class="title-view" v-for="(item, index) in title" :key="item" @click="changeActiveIndex(index)"
:class="{isActive: activeIndex === index}">
<text>{{item}}</text>
<view class="arrow" v-if="activeIndex !== index">
<u-image src="/static/dropdown/dp_icon_lxia.png" width="14rpx" height="11rpx" />
</view>
<view class="arrow" v-if="activeIndex === index">
<u-image src="/static/dropdown/dp_icon_hlxia.png" width="14rpx" height="11rpx" />
</view>
</view>
</view>
<view class="item-border">
<DropDownItem
v-if="activeIndex !== -1"
:list="tablist"
@cancelDrop="cancelDrop"
@getQueryInfo="getQueryInfo"
:type="title[activeIndex]"
/>
</view>
</view>
</template>
<script>
/**
* @property {Array} postlist 传递一个二维数组
*/
import DropDownItem from "./DropDownItem.vue"
export default {
name: "DropDown",
components: {
DropDownItem
},
data() {
return {
title: ['行业', '区域', '面积', '筛选'],
activeIndex: -1,
postlist: [
['全部', '餐饮美食', '百货超市', '美容美发'],
['区域1', '区域2', '区域3', '区域4'],
['小于50m²', '50-200m²', '200-600m²', '600-800m²', '800-1000m²', '1000m²以上'],
['面积从大到小', '面积从小到大', '租金从大到小', '租金从小到大']
],
queryInfo: {
region: '',
sortType: '',
areaType: '',
business: ''
}
};
},
computed: {
tablist: function() {
return this.postlist[this.activeIndex]
}
},
created() {
this.postlist[0]=JSON.parse(uni.getStorageSync('classList'))
this.postlist[1]=JSON.parse(uni.getStorageSync('regionList'))
},
methods: {
changeActiveIndex(index) {
if (this.activeIndex === index) {
this.activeIndex = -1;
} else
this.activeIndex = index
},
cancelDrop() {
this.activeIndex = -1;
},
getQueryInfo(querys) {
this.queryInfo = {
...this.queryInfo,
...querys
}
const query = this.$u.queryParams(this.queryInfo)
console.log(query, 'query');
this.$emit('getQueryInfo', query)
return query
}
}
}
</script>
<style lang="scss" scoped>
.isActive {
color: #CC3333;
}
.container {
margin-top: 10px;
position: relative;
.tabs-bg {
position: absolute;
background-color: $uni-bg-color-grey;
height: 120rpx;
width: 100%;
transform: translateY(-20rpx);
z-index: 2;
}
.tabs {
background-color: #fff;
height: 100rpx;
display: flex;
justify-content: space-around;
position: relative;
z-index: 3;
}
.title-view {
display: flex;
>text {
font-size: 14px;
display: flex;
flex-direction: column;
justify-content: center;
}
}
.arrow {
margin-left: 8rpx;
display: flex;
flex-direction: column;
justify-content: center;
}
}
.item-border {
position: absolute;
width: 100%;
height: 100%;
}
</style>