list.vue
4.28 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<template>
<LayoutApp :show-back="true">
<div class="filter">
<div class="filter-tab">
<div class="tab-item" :class="selectedType === 2 && 'selected-tab'" @click="pressType(2)">人气</div>
<div class="tab-item middle" :class="selectedType === 1 && 'selected-tab'" @click="pressType(1)">
<span>价格</span>
<div :class="arrowImage"></div>
</div>
<div class="tab-item" :class="selectedType === 3 && 'selected-tab'" @click="pressType(3)">新品</div>
</div>
<div class="screen middle">
<div class="screen-img"></div>
筛选
</div>
</div>
<Scroll :options="scrollOptions"
:data="productList.list"
@pulling-up="onPullingUp">
<ProductList :list="productList.list"></ProductList>
</Scroll>
</LayoutApp>
</template>
<script>
import ProductList from './components/productList';
import {Scroll} from 'cube-ui';
import {createNamespacedHelpers} from 'vuex';
const {mapState, mapActions} = createNamespacedHelpers('list');
export default {
name: 'list',
components: {
ProductList,
Scroll
},
data() {
return {
scrollOptions: {
bounce: {
top: false
},
pullUpLoad: true
},
fixed: false,
selectedType: 2,
priceDesc: true,
arrowImage: '',
searchKey: '',
listType: 1
};
},
mounted() {
this.changeArrow();
let params = this.$route.params;
if (Object.keys(params).length && params.listType) {
this.listType = params.listType;
}
this.fetchProductList({listType: this.listType, isReset: true});
},
methods: {
...mapActions(['fetchProductList']),
// 上拉加载
async onPullingUp() {
await this.fetchProductList({listType: this.listType});
},
// 点击tab type, 0: 推荐, 1: 价格, 2: 人气, 3: 新品
pressType(type) {
if (type === this.selectedType && type !== 1) {
return;
}
let params = {
type: 6,
query: this.searchKey,
sort: this.filterParams.sort.join(','),
brand: this.filterParams.brand.join(','), // 品牌id
gender: this.filterParams.gender.join(','), // 性别
size: this.filterParams.size.join(','), // 尺码id
};
if (this.listType === 4) {
delete params.type;
}
this.selectedType = type;
if (type === 1) {
this.priceDesc = !this.priceDesc;
params.order = !this.priceDesc ? 'p_desc' : 'p_asc';
} else if (type === 2) {
this.priceDesc = true;
params.order = 'sale_desc';
} else if (type === 3) {
this.priceDesc = true;
params.order = 'st_desc';
}
params.listType = this.listType;
params.isReset = true;
this.changeArrow();
this.fetchProductList(params);
},
changeArrow() {
this.arrowImage = (this.selectedType === 3 || this.selectedType === 2) ? 'price-arrow' :
this.priceDesc ? 'desc-arrow' : 'asc-arrow';
},
},
computed: {
...mapState(['productList', 'filterParams']),
},
};
</script>
<style scoped>
.filter {
display: flex;
height: 120px;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding-left: 42px;
padding-right: 38px;
}
.filter-tab {
display: flex;
flex-direction: row;
align-items: center;
font-size: 32px;
color: #999;
text-align: center;
}
.selected-tab {
font-size: 40px;
color: #000;
font-weight: bold;
}
.tab-item {
margin-right: 60px;
}
.screen {
font-size: 32px;
color: #000;
letter-spacing: 0;
}
.middle {
display: flex;
align-items: center;
}
.asc-arrow {
width: 40px;
height: 40px;
background: url(~statics/image/list/asc_arrow@3x.png) no-repeat;
background-size: cover;
}
.desc-arrow {
width: 40px;
height: 40px;
background: url(~statics/image/list/desc_arrow@3x.png) no-repeat;
background-size: cover;
}
.price-arrow {
width: 40px;
height: 40px;
background: url(~statics/image/list/price_arrow@3x.png) no-repeat;
background-size: cover;
}
.screen-img {
width: 40px;
height: 40px;
background: url(~statics/image/list/filter@3x.png) no-repeat;
background-size: cover;
}
</style>