brand-cate-box.vue
1.7 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
<template>
<tab v-bind:page="'cate'"></tab>
<brand-cate v-bind:category="category" v-bind:jump="true" v-bind:gender="gender"></brand-cate>
</template>
<script>
const tip = require('common/tip');
const brandCate = require('channel/brand-cate.vue');
const tab = require('channel/tab.vue');
const $ = require('jquery');
const bus = require('common/vue-bus');
const channelTrans = {
men: {
key: 'MEN男士',
code: '1,3'
},
women: {
key: 'WOMEN女士',
code: '2,3'
},
lifestyle: {
key: 'LIFESTYLE生活',
code: '1,2,3'
}
};
module.exports = {
data() {
return {
category: [],
categoryResult: {},
gender: '1,3'
};
},
components: {
tab,
brandCate
},
methods: {
getCateList() {
$.ajax({
url: '/cate/list.json'
}).then(result => {
if (result.code === 200 && result.data) {
this.$set('categoryResult', result.data);
this.$set('category', this.categoryResult['MEN男士']);
}
}).fail(() => {
tip('网络错误');
});
}
},
created() {
this.getCateList();
bus.$on('channel.change', (page, channel) => {
this.$set('gender', channelTrans[channel].code);
this.$set('category', this.categoryResult[channelTrans[channel].key]);
});
}
};
</script>