|
|
<template>
|
|
|
<div class="resource-category">
|
|
|
<a-link class="cate-label" :href="brandLink">品牌<i class="icon icon-right"></i></a-link>
|
|
|
<p class="cate-label" @click="show=!show">{{label}}<i class="icon" :class="sortClass"></i></p>
|
|
|
<div class="cate-items" v-if="show">
|
|
|
<a-link :href="item.url" class="cate-item" v-for="item in items" :key="item.name">{{item.name}}</a-link>
|
|
|
<div v-for="(item, index) in value">
|
|
|
<p class="cate-label" @click="toggle(index)">{{item.category_name
|
|
|
}}<i class="icon" :class="sortClass[index]"></i></p>
|
|
|
<div class="cate-items" v-if="show[index]">
|
|
|
<a-link class="cate-item"
|
|
|
:href="`/product/list?sort=${getAllSortId(index)}&sort_name=全部${item.category_name}&gender=${genderCvt}`">
|
|
|
{{`全部${item.category_name}`}}</a-link>
|
|
|
<a-link
|
|
|
:href="`/product/list?sort=${sub.relation_parameter.sort}&sort_name=${sub.category_name}&gender=${genderCvt}`"
|
|
|
class="cate-item" v-for="sub in item.sub" :key="sub.category_id">{{sub.category_name}}
|
|
|
</a-link>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import _ from 'lodash/core';
|
|
|
import Resource from './resource';
|
|
|
|
|
|
export default {
|
|
|
name: 'ResourceTwoImage',
|
|
|
name: 'ResourceCategory',
|
|
|
props: {
|
|
|
value: Array,
|
|
|
gender: {
|
|
|
type: String
|
|
|
},
|
|
|
label: {
|
|
|
type: String,
|
|
|
default: '测试'
|
|
|
},
|
|
|
items: {
|
|
|
type: Array,
|
|
|
default() {
|
|
|
return [
|
|
|
{
|
|
|
name: '大衣',
|
|
|
url: 'https://wwww.yohobuy.com'
|
|
|
},
|
|
|
{
|
|
|
name: '裤子',
|
|
|
url: 'https://wwww.yohobuy.com'
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
show: false
|
|
|
show: [],
|
|
|
sortClass: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
sortClass() {
|
|
|
return {
|
|
|
'icon-sort-up': this.show,
|
|
|
'icon-sort-down': !this.show,
|
|
|
}
|
|
|
},
|
|
|
brandLink() {
|
|
|
return `/brand?channel=${this.gender}`;
|
|
|
},
|
|
|
genderCvt() {
|
|
|
return { men: '1,3', women: '2,3' }[this.gender];
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
toggle(idx) {
|
|
|
this.$set(this.show, idx, !this.show[idx]);
|
|
|
this.$set(this.sortClass, idx, {
|
|
|
'icon-sort-up': this.show[idx],
|
|
|
'icon-sort-down': !this.show[idx]
|
|
|
});
|
|
|
},
|
|
|
getAllSortId(idx) {
|
|
|
return this.value[idx].sub.map(sort=>sort.relation_parameter.sort).join(',') + ',';
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
const len = this.value.length;
|
|
|
|
|
|
this.show = [];
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
this.show.push(false);
|
|
|
this.sortClass.push({
|
|
|
'icon-sort-up': false,
|
|
|
'icon-sort-down': true,
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
components: {Resource}
|
...
|
...
|
|