Authored by 郭成尧

'cate抽成组件'

<template>
<tab v-bind:page="'cate'"></tab>
<brand-cate v-bind:category="category" v-bind:jump="true"></brand-cate>
<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: {}
category: [],
categoryResult: {},
gender: '1,3'
};
},
components: {
... ... @@ -25,7 +43,8 @@
url: '/cate/list.json'
}).then(result => {
if (result.code === 200 && result.data) {
this.$set('category', result.data);
this.$set('categoryResult', result.data);
this.$set('category', this.categoryResult['MEN男士']);
}
}).fail(() => {
tip('网络错误');
... ... @@ -34,6 +53,11 @@
},
created() {
this.getCateList();
bus.$on('channel.change', (page, channel) => {
this.$set('gender', channelTrans[channel].code);
this.$set('category', this.categoryResult[channelTrans[channel].key]);
});
}
};
</script>
... ...
... ... @@ -204,49 +204,34 @@
<script>
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 = {
props: {
category: {
type: Object
type: Array
},
jump: {
type: Boolean
},
gender: {
type: String
}
},
data() {
return {
brandCate: [], // 频道切换时取数据使用
cateNavLeftData: [], // 左侧分类数据
cateNavRightData: [], // 右侧分类数据
leftcurrent: 0, // 标记当前左侧选中条目
gender: '1,2,3', // 跳转到商品列表页的参数
rightAll: {} // 全部XX
};
},
watch: {
category() {
this.$set('brandCate', this.category);
this.$set('cateNavLeftData', this.category['MEN男士']);
this.$set('cateNavRightData', this.category['MEN男士'] ? this.category['MEN男士'][0].sub : []);
this.$set('cateNavLeftData', this.category);
this.$set('cateNavRightData', this.cateNavLeftData ? this.cateNavLeftData[0].sub : []);
this.$set('rightAll', this.category['MEN男士'] ? {
sortId: this.category['MEN男士'][0].relationParameter.sort,
categoryName: this.category['MEN男士'][0].categoryName
this.$set('rightAll', this.cateNavLeftData ? {
sortId: this.cateNavLeftData[0].relationParameter.sort,
categoryName: this.cateNavLeftData[0].categoryName
} : {});
}
},
... ... @@ -267,17 +252,6 @@
name: categoryName
});
}
},
created() {
bus.$on('channel.change', (page, channel) => {
this.gender = channelTrans[channel].code;
this.cateNavLeftData = this.brandCate[channelTrans[channel].key];
this.cateNavRightData = this.cateNavLeftData ? this.cateNavLeftData[0].sub : [];
this.rightAll = {
sortId: this.cateNavLeftData[0].relationParameter.sort,
categoryName: this.cateNavLeftData[0].categoryName
};
});
}
};
</script>
... ...