206 lines
5.0 KiB
Vue
206 lines
5.0 KiB
Vue
<template>
|
|
<view class="container">
|
|
<view class="tabs-bg"></view>
|
|
<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"></u-image>
|
|
</view>
|
|
<view class="arrow" v-if="activeIndex === index">
|
|
<u-image src="/static/dropdown/dp_icon_hlxia.png" width="14rpx" height="11rpx"></u-image>
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
<view class="item-border">
|
|
<DropDownItem v-show="activeIndex !== -1" :list="tablist" @cancelDrop="cancelDrop" @getQueryInfo="getQueryInfo"
|
|
:type="title[activeIndex]" :activeChoose="setActiveTag" :key="tablist" ref="dropdownitem"
|
|
@cancelPageNum="cancelPageNum" />
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
/**
|
|
* @property {Array} postlist 传递一个二维数组
|
|
*/
|
|
import DropDownItem from "./DropDownItem.vue"
|
|
export default {
|
|
name: "DropDown",
|
|
components: {
|
|
DropDownItem
|
|
},
|
|
data() {
|
|
return {
|
|
title: ['行业', '区域', '面积', '筛选'],
|
|
activeIndex: -1,
|
|
// 是否显示下拉框
|
|
isShow: false,
|
|
postlist: [
|
|
[],
|
|
[],
|
|
['全部', '小于50m²', '50-200m²', '200-600m²', '600-800m²', '800-1000m²', '1000m²以上'],
|
|
['全部', '面积从大到小', '面积从小到大', '租金从大到小', '租金从小到大']
|
|
],
|
|
queryInfo: {
|
|
region: '',
|
|
sortType: '',
|
|
areatype: '',
|
|
business: ''
|
|
},
|
|
// 当前选中的行业下拉列表项
|
|
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() {
|
|
this.postlist[0] = JSON.parse(uni.getStorageSync('classList'))
|
|
this.postlist[0].unshift('全部')
|
|
this.postlist[1] = JSON.parse(uni.getStorageSync('regionList'))
|
|
this.postlist[1].unshift('全区域')
|
|
// this.postlist[2].unshift('所有面积')
|
|
// this.postlist[3].unshift('全部')
|
|
},
|
|
watch: {
|
|
setActiveTag(reset) {
|
|
|
|
}
|
|
},
|
|
methods: {
|
|
changeActiveIndex(index) {
|
|
if (this.activeIndex === index) {
|
|
this.activeIndex = -1;
|
|
} else
|
|
this.activeIndex = index
|
|
},
|
|
cancelDrop() {
|
|
this.activeIndex = -1;
|
|
},
|
|
cancelPageNum() {
|
|
this.$emit('cancelPageNum')
|
|
},
|
|
getQueryInfo(querys) {
|
|
|
|
// console.log(querys, 'getquerysinfo');
|
|
// 修改当前选择的各选项卡下标
|
|
// 记忆各下拉框数据
|
|
|
|
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(querys, 'dropquery');
|
|
this.$emit('getQueryInfo', this.queryInfo)
|
|
},
|
|
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()
|
|
}
|
|
}
|
|
}
|
|
</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> |