classic-tabs.vue
2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
<div :class="classes">
<div class="yoho-coupon-filter-bar">
<div
:class="tabCls(item)"
v-for="(item, index) in navList"
@click="handleChange(index)"
:key="index"
>{{item.label}}
<span v-if="getNum[index]">({{getNum[index]}})</span>
<span :class="filterClass" v-if="item.filter"></span>
</div>
</div>
</div>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
const {mapGetters} = createNamespacedHelpers('coupon/yoho');
export default {
name: 'ClassicTabs',
props: {
value: {
type: [String, Number]
},
data: {
type: Array,
default() {
return [];
}
}
},
data() {
return {
prefixCls: 'yoho-tabs',
navList: this.data,
activeKey: this.value,
showFilter: false
};
},
computed: {
classes() {
return [`${this.prefixCls}`];
},
filterClass() {
if (this.showFilter) {
return ['iconfont', 'icon-up'];
} else {
return ['iconfont', 'icon-downn'];
}
},
...mapGetters(['getNum'])
},
methods: {
handleChange(index) {
const nav = this.navList[index];
if (this.activeKey === nav.label) {
this.showFilter = !this.showFilter;
this.$emit('on-filter-change', this.showFilter);
return;
}
this.activeKey = nav.label;
this.$emit('input', nav.label);
},
tabCls(item) {
return [
'filter-btn-box',
{
active: item.label === this.activeKey
}
];
},
},
watch: {
value(val) {
this.activeKey = val;
}
}
};
</script>
<style lang="scss" scoped>
$yoho-tab: yoho-tab;
.#{$yoho-tab}s {
width: 100%;
}
.yoho-coupon-filter-bar {
width: 100%;
height: 90px;
display: flex;
padding: 14px 0;
box-shadow: 0 0 16px 0 #eee;
background-color: #fff;
left: 0;
z-index: 3;
border-bottom: 1px solid #e0e0e0;
.filter-btn-box {
flex: 1;
line-height: 60px;
text-align: center;
font-size: 28px;
color: #b0b0b0;
border-right: 1px solid #e0e0e0;
}
.filter-btn-box:last-child {
border-right: none;
}
.show-filter-btn {
color: #b0b0b0;
}
.active {
color: #444;
}
}
</style>