brand-cate.vue
7.82 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<template>
<div class="cate-page" id='cate-page'>
<div class="cate-container clearfix">
<div class="content">
<ul class="primary-level">
<li v-for="(index, ca) in cateNavLeftData" class="ellipsis" :class="{focus: index === leftcurrent}" class="p-level-item" @click='cateNavLeftFun(index, ca.relationParameter.sort, ca.categoryName)'>
{{ca.categoryName}}
</li>
</ul>
<div class="sub-level-container">
<ul class="sub-level">
<li class="ellipsis">
<a v-if="jump" href="/product/list?sort={{rightAll.sortId || '' }}&sort_name=全部{{rightAll.categoryName || ''}}&gender={{gender}}">全部{{rightAll.categoryName}}</a>
<a v-else @click="noJumpReturn(rightAll.sortId, '全部' + rightAll.categoryName)">全部{{rightAll.categoryName}}</a>
</li>
</ul>
<ul class="sub-level">
<li v-for="sub in cateNavRightData" class="ellipsis">
<a v-if="jump" href="/product/list?sort={{sub.relationParameter.sort}}&sort_name={{sub.categoryName}}&gender={{gender}}">{{sub.categoryName}}</a>
<a v-else @click="noJumpReturn(sub.relationParameter.sort, sub.categoryName)">{{sub.categoryName}}</a>
</li>
</ul>
</div>
</div>
</div><!--/end cate-container-->
</div>
</template>
<style>
.cate-page {
font-size: 36px;
font-family: helvetica, Arial, "黑体";
.cate-container {
margin-top: 80px;
}
ul,
li {
position: relative;
margin: 0;
padding: 0;
list-style: none;
}
.search-input {
position: relative;
background-color: #f8f8f8;
padding: 13px 20px;
p {
box-sizing: border-box;
width: 100%;
height: 60px;
line-height: 60px;
border: none;
padding-left: 66px;
border-radius: 60px;
font-size: 26px;
background: #fff;
color: #999;
}
}
.search-icon {
position: absolute;
top: 0;
bottom: 0;
left: 43px;
line-height: 86px;
color: #999;
}
.cate-nav {
height: 120px;
border-bottom: 1px solid #e6e6e6;
font-size: 24px;
li {
display: block;
box-sizing: border-box;
float: left;
height: 100%;
padding: 20px 0;
width: 25%;
text-align: center;
color: #999;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:last-child {
border-right: none;
}
&.focus {
color: #000;
span {
border-bottom: 4px solid #000;
font-weight: bold;
}
}
&.bytouch {
background: #eee;
}
}
span {
line-height: 80px;
padding-bottom: 10px;
}
li:last-child span {
border-right: 0;
}
}
.content {
&.hide {
display: none;
}
}
.primary-level {
float: left;
box-sizing: border-box;
width: 50%;
height: 100%;
font-size: 34px;
background-color: #fff;
> li {
height: 108px;
line-height: 108px;
margin-left: 30px;
border-bottom: 1px solid #eee;
user-select: none;
color: #000;
&.focus {
background-color: #fff;
&:after {
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid #f6f6f6;
position: absolute;
margin-top: 32px;
right: 0%;
}
}
&.highlight {
background-color: #eee;
}
}
}
.sub-level-container {
float: left;
box-sizing: border-box;
background: #f6f6f6;
width: 50%;
height: 100%;
}
.sub-level {
width: 100%;
background-color: #f6f6f6;
position: relative;
font-size: 32px;
&.hide {
display: none;
}
> li {
box-sizing: border-box;
height: 88px;
line-height: 88px;
border-bottom: 1px solid #e6e6e6;
padding-left: 30px;
margin-right: 30px;
user-select: none;
white-space: nowrap;
overflow-y: auto;
&.highlight {
background: #eee;
}
&:hover {
background-color: #efefef;
}
}
a {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 20px;
display: inline;
color: #b0b0b0;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
</style>
<script>
const $ = require('jquery');
module.exports = {
props: {
category: {
type: Array
},
jump: {
type: Boolean
},
gender: {
type: String
}
},
data() {
return {
cateNavLeftData: [], // 左侧分类数据
cateNavRightData: [], // 右侧分类数据
leftcurrent: 0, // 标记当前左侧选中条目
rightAll: {} // 全部XX
};
},
watch: {
category() {
this.categoryChangeHandler();
}
},
methods: {
cateNavLeftFun(index, categoryId, categoryName) {
this.leftcurrent = index;
this.cateNavRightData = this.cateNavLeftData[index].sub;
this.rightAll = {
sortId: categoryId ? categoryId : '',
categoryName: categoryName ? categoryName : ''
};
},
/* 筛选列表使用返回值 */
noJumpReturn(categoryId, categoryName) {
this.$dispatch('select', {
id: categoryId,
name: categoryName
});
},
categoryChangeHandler() {
if (!this.category || !this.category.length) {
return;
}
this.$set('cateNavLeftData', this.category);
this.$set('cateNavRightData', this.cateNavLeftData ? this.cateNavLeftData[0].sub : []);
let allSorts = this.cateNavLeftData[0].sub ?
this.cateNavLeftData[0].sub.map(sort=>sort.relationParameter.sort).join(',') : '';
this.$set('rightAll', this.cateNavLeftData ? {
sortId: allSorts,
categoryName: this.cateNavLeftData[0].categoryName
} : {});
}
},
created() {
this.categoryChangeHandler();
window.addEventListener('touchstart', () => {
const c = $('.content');
const h = c.height();
const h1 = document.body.offsetHeight;
if (h <= h1) {
c.css('height', h1);
}
});
}
};
</script>