1
|
<template>
|
1
|
<template>
|
2
|
-<div class="cate-page" id='cate-page'>
|
|
|
3
|
- <div class="cate-nav clearfix" v-on:click='cateNavTopFun'>
|
|
|
4
|
- <ul>
|
|
|
5
|
- <li v-for="cate in brandCate">
|
|
|
6
|
- <span>{{cate.name}}</span>
|
|
|
7
|
- </li>
|
|
|
8
|
- </ul>
|
|
|
9
|
- </div>
|
|
|
10
|
- <div class="cate-container clearfix">
|
|
|
11
|
- <div class="content hide" style="height: 522px;" v-for="cate in brandCate">
|
|
|
12
|
- <ul class="primary-level">
|
|
|
13
|
- <li v-for="ca in cate.ca" class="p-level-item {{#if index}} focus {{/if}}" v-on:click='cateNavLeftFun'>
|
|
|
14
|
- <a href="{{ca.url}}">{{ca.name}}</a>
|
2
|
+ <div class="cate-page" id='cate-page'>
|
|
|
3
|
+ <div class="cate-nav clearfix">
|
|
|
4
|
+ <ul>
|
|
|
5
|
+ <li v-for="(index, cate) in brandCate" v-on:click='cateNavTopFun(index)' v-bind:class="{focus: index === topcurrent}" >
|
|
|
6
|
+ <span>{{cate.name}}</span>
|
15
|
</li>
|
7
|
</li>
|
16
|
</ul>
|
8
|
</ul>
|
17
|
- <div class="sub-level-container">
|
|
|
18
|
- <ul class="sub-level hide" v-for="ca in cate.ca">
|
|
|
19
|
- <li v-for="sub in ca.sub">
|
|
|
20
|
- <a href="{{sub.url}}">{{sub.name}}</a>
|
9
|
+ </div>
|
|
|
10
|
+ <div class="cate-container clearfix">
|
|
|
11
|
+ <div class="content" style="height: 522px;">
|
|
|
12
|
+ <ul class="primary-level">
|
|
|
13
|
+ <li v-for="(index, ca) in cateNavLeftData" v-bind:class="{focus: index === leftcurrent}" class="p-level-item" v-on:click='cateNavLeftFun(index)'>
|
|
|
14
|
+ <a href="{{ca.url}}">{{ca.name}}</a>
|
21
|
</li>
|
15
|
</li>
|
22
|
</ul>
|
16
|
</ul>
|
|
|
17
|
+ <div class="sub-level-container">
|
|
|
18
|
+ <ul class="sub-level">
|
|
|
19
|
+ <li v-for="sub in cateNavRightData">
|
|
|
20
|
+ <a href="{{sub.url}}">{{sub.name}}</a>
|
|
|
21
|
+ </li>
|
|
|
22
|
+ </ul>
|
|
|
23
|
+ </div>
|
23
|
</div>
|
24
|
</div>
|
24
|
- </div>
|
|
|
25
|
- </div><!--/end cate-container-->
|
|
|
26
|
-</div>
|
25
|
+ </div><!--/end cate-container-->
|
|
|
26
|
+ </div>
|
27
|
</template>
|
27
|
</template>
|
28
|
-
|
|
|
29
|
<style>
|
28
|
<style>
|
30
|
.cate-page {
|
29
|
.cate-page {
|
31
|
font-size: 36px;
|
30
|
font-size: 36px;
|
|
@@ -202,12 +201,13 @@ |
|
@@ -202,12 +201,13 @@ |
202
|
props: [],
|
201
|
props: [],
|
203
|
data() {
|
202
|
data() {
|
204
|
return {
|
203
|
return {
|
205
|
- brandCate: []
|
204
|
+ brandCate: [],
|
|
|
205
|
+ cateNavLeftData: [],
|
|
|
206
|
+ cateNavRightData: [],
|
|
|
207
|
+ topcurrent: 0,
|
|
|
208
|
+ leftcurrent: 0
|
206
|
};
|
209
|
};
|
207
|
},
|
210
|
},
|
208
|
- watch: {
|
|
|
209
|
-
|
|
|
210
|
- },
|
|
|
211
|
methods: {
|
211
|
methods: {
|
212
|
getCateList() {
|
212
|
getCateList() {
|
213
|
let data = {
|
213
|
let data = {
|
|
@@ -219,50 +219,20 @@ |
|
@@ -219,50 +219,20 @@ |
219
|
data: data
|
219
|
data: data
|
220
|
}).then(result => {
|
220
|
}).then(result => {
|
221
|
this.brandCate = result;
|
221
|
this.brandCate = result;
|
222
|
- console.log(result, '====');
|
222
|
+ this.cateNavLeftData = this.brandCate[0].ca;
|
|
|
223
|
+ this.cateNavRightData = this.cateNavLeftData[0].sub;
|
223
|
}).fail(() => {
|
224
|
}).fail(() => {
|
224
|
tip('网络错误');
|
225
|
tip('网络错误');
|
225
|
});
|
226
|
});
|
226
|
},
|
227
|
},
|
227
|
- cateNavTopFun(e) {
|
|
|
228
|
- var $this = $(e.target).closest('li'),
|
|
|
229
|
- $nav = $('.cate-nav'),
|
|
|
230
|
- $cateContainer = $('.cate-container'),
|
|
|
231
|
- $contents = $cateContainer.children('.content'),
|
|
|
232
|
- $curContent = $contents.not('.hide'),
|
|
|
233
|
- index = $this.index();
|
|
|
234
|
-
|
|
|
235
|
- if ($this.hasClass('focus')) {
|
|
|
236
|
- return;
|
|
|
237
|
- }
|
|
|
238
|
-
|
|
|
239
|
- $nav.find('li.focus').removeClass('focus');
|
|
|
240
|
- $this.addClass('focus');
|
|
|
241
|
-
|
|
|
242
|
- $curContent.addClass('hide');
|
|
|
243
|
- $curContent = $contents.eq(index).removeClass('hide');
|
228
|
+ cateNavTopFun(index) {
|
|
|
229
|
+ this.topcurrent = index;
|
|
|
230
|
+ this.cateNavLeftData = this.brandCate[index].ca;
|
|
|
231
|
+ this.cateNavRightData = this.cateNavLeftData[0].sub;
|
244
|
},
|
232
|
},
|
245
|
- cateNavLeftFun(e) {
|
|
|
246
|
- var $this = $(e.target),
|
|
|
247
|
- $subLevel,
|
|
|
248
|
- $cur, index;
|
|
|
249
|
-
|
|
|
250
|
- $cur = $this.closest('.p-level-item');
|
|
|
251
|
-console.log($cur.html(), '222');
|
|
|
252
|
- if ($cur.length > 0) {
|
|
|
253
|
- index = $cur.index();
|
|
|
254
|
- $subLevel = $this.closest('.content').find('.sub-level');
|
|
|
255
|
-
|
|
|
256
|
- if ($this.hasClass('focus')) {
|
|
|
257
|
- return;
|
|
|
258
|
- }
|
|
|
259
|
-
|
|
|
260
|
- $this.closest('.primary-level').children('.focus').removeClass('focus');
|
|
|
261
|
- $this.addClass('focus');
|
|
|
262
|
-
|
|
|
263
|
- $subLevel.not('.hide').addClass('hide');
|
|
|
264
|
- $subLevel.eq(index).removeClass('hide');
|
|
|
265
|
- }
|
233
|
+ cateNavLeftFun(index) {
|
|
|
234
|
+ this.leftcurrent = index;
|
|
|
235
|
+ this.cateNavRightData = this.cateNavLeftData[index].sub;
|
266
|
}
|
236
|
}
|
267
|
},
|
237
|
},
|
268
|
created() {
|
238
|
created() {
|