Showing
4 changed files
with
73 additions
and
35 deletions
@@ -28,5 +28,12 @@ module.exports = { | @@ -28,5 +28,12 @@ module.exports = { | ||
28 | params: { | 28 | params: { |
29 | content_code: {type: String}, | 29 | content_code: {type: String}, |
30 | } | 30 | } |
31 | + }, | ||
32 | + '/sort/list': { | ||
33 | + api: 'app.sort.get', | ||
34 | + cache: true, | ||
35 | + params: { | ||
36 | + app_type: 1, | ||
37 | + } | ||
31 | } | 38 | } |
32 | }; | 39 | }; |
1 | <template> | 1 | <template> |
2 | <div class="resource-category"> | 2 | <div class="resource-category"> |
3 | <a-link class="cate-label" :href="brandLink">品牌<i class="icon icon-right"></i></a-link> | 3 | <a-link class="cate-label" :href="brandLink">品牌<i class="icon icon-right"></i></a-link> |
4 | - <p class="cate-label" @click="show=!show">{{label}}<i class="icon" :class="sortClass"></i></p> | ||
5 | - <div class="cate-items" v-if="show"> | ||
6 | - <a-link :href="item.url" class="cate-item" v-for="item in items" :key="item.name">{{item.name}}</a-link> | 4 | + <div v-for="(item, index) in value"> |
5 | + <p class="cate-label" @click="toggle(index)">{{item.category_name | ||
6 | + }}<i class="icon" :class="sortClass[index]"></i></p> | ||
7 | + <div class="cate-items" v-if="show[index]"> | ||
8 | + <a-link class="cate-item" | ||
9 | + :href="`/product/list?sort=${getAllSortId(index)}&sort_name=全部${item.category_name}&gender=${genderCvt}`"> | ||
10 | + {{`全部${item.category_name}`}}</a-link> | ||
11 | + <a-link | ||
12 | + :href="`/product/list?sort=${sub.relation_parameter.sort}&sort_name=${sub.category_name}&gender=${genderCvt}`" | ||
13 | + class="cate-item" v-for="sub in item.sub" :key="sub.category_id">{{sub.category_name}} | ||
14 | + </a-link> | ||
15 | + </div> | ||
7 | </div> | 16 | </div> |
8 | </div> | 17 | </div> |
9 | </template> | 18 | </template> |
10 | 19 | ||
11 | <script> | 20 | <script> |
21 | +import _ from 'lodash/core'; | ||
12 | import Resource from './resource'; | 22 | import Resource from './resource'; |
13 | 23 | ||
14 | export default { | 24 | export default { |
15 | - name: 'ResourceTwoImage', | 25 | + name: 'ResourceCategory', |
16 | props: { | 26 | props: { |
27 | + value: Array, | ||
17 | gender: { | 28 | gender: { |
18 | type: String | 29 | type: String |
19 | - }, | ||
20 | - label: { | ||
21 | - type: String, | ||
22 | - default: '测试' | ||
23 | - }, | ||
24 | - items: { | ||
25 | - type: Array, | ||
26 | - default() { | ||
27 | - return [ | ||
28 | - { | ||
29 | - name: '大衣', | ||
30 | - url: 'https://wwww.yohobuy.com' | ||
31 | - }, | ||
32 | - { | ||
33 | - name: '裤子', | ||
34 | - url: 'https://wwww.yohobuy.com' | ||
35 | - } | ||
36 | - ] | ||
37 | - } | ||
38 | } | 30 | } |
39 | }, | 31 | }, |
40 | data() { | 32 | data() { |
41 | return { | 33 | return { |
42 | - show: false | 34 | + show: [], |
35 | + sortClass: [] | ||
43 | } | 36 | } |
44 | }, | 37 | }, |
45 | computed: { | 38 | computed: { |
46 | - sortClass() { | ||
47 | - return { | ||
48 | - 'icon-sort-up': this.show, | ||
49 | - 'icon-sort-down': !this.show, | ||
50 | - } | ||
51 | - }, | ||
52 | brandLink() { | 39 | brandLink() { |
53 | return `/brand?channel=${this.gender}`; | 40 | return `/brand?channel=${this.gender}`; |
41 | + }, | ||
42 | + genderCvt() { | ||
43 | + return { men: '1,3', women: '2,3' }[this.gender]; | ||
44 | + } | ||
45 | + }, | ||
46 | + methods: { | ||
47 | + toggle(idx) { | ||
48 | + this.$set(this.show, idx, !this.show[idx]); | ||
49 | + this.$set(this.sortClass, idx, { | ||
50 | + 'icon-sort-up': this.show[idx], | ||
51 | + 'icon-sort-down': !this.show[idx] | ||
52 | + }); | ||
53 | + }, | ||
54 | + getAllSortId(idx) { | ||
55 | + return this.value[idx].sub.map(sort=>sort.relation_parameter.sort).join(',') + ','; | ||
56 | + } | ||
57 | + }, | ||
58 | + created() { | ||
59 | + const len = this.value.length; | ||
60 | + | ||
61 | + this.show = []; | ||
62 | + for (let i = 0; i < len; i++) { | ||
63 | + this.show.push(false); | ||
64 | + this.sortClass.push({ | ||
65 | + 'icon-sort-up': false, | ||
66 | + 'icon-sort-down': true, | ||
67 | + }); | ||
54 | } | 68 | } |
55 | }, | 69 | }, |
56 | components: {Resource} | 70 | components: {Resource} |
@@ -11,8 +11,8 @@ | @@ -11,8 +11,8 @@ | ||
11 | <i class="icon icon-search"></i> | 11 | <i class="icon icon-search"></i> |
12 | </span> | 12 | </span> |
13 | </header-box> | 13 | </header-box> |
14 | - <div class="resources" v-for="floor in data"> | ||
15 | - <resource-category :gender="gender"></resource-category> | 14 | + <div class="resources" v-for="floor in data.data"> |
15 | + <resource-category :gender="gender" :value="data.sort" v-if="floor.category"></resource-category> | ||
16 | <resource-focus-image v-if="floor.template_name=='focus'" :value="floor.data"></resource-focus-image> | 16 | <resource-focus-image v-if="floor.template_name=='focus'" :value="floor.data"></resource-focus-image> |
17 | <resource-single-image v-if="floor.template_name =='newSingleImage'" | 17 | <resource-single-image v-if="floor.template_name =='newSingleImage'" |
18 | :value="floor.data.list[0]"></resource-single-image> | 18 | :value="floor.data.list[0]"></resource-single-image> |
@@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
85 | return this.$store.state.channel.gender; | 85 | return this.$store.state.channel.gender; |
86 | }, | 86 | }, |
87 | data() { | 87 | data() { |
88 | - return this.$store.state.channel[this.gender].data; | 88 | + return this.$store.state.channel[this.gender]; |
89 | } | 89 | } |
90 | }, | 90 | }, |
91 | asyncData({store, router: to}) { | 91 | asyncData({store, router: to}) { |
@@ -18,10 +18,12 @@ export default { | @@ -18,10 +18,12 @@ export default { | ||
18 | home: {}, | 18 | home: {}, |
19 | gender: 'men', | 19 | gender: 'men', |
20 | men: { | 20 | men: { |
21 | + sort: {}, | ||
21 | data: {}, | 22 | data: {}, |
22 | isFetching: false | 23 | isFetching: false |
23 | }, | 24 | }, |
24 | women: { | 25 | women: { |
26 | + sort: {}, | ||
25 | data: {}, | 27 | data: {}, |
26 | isFetching: false | 28 | isFetching: false |
27 | }, | 29 | }, |
@@ -45,9 +47,20 @@ export default { | @@ -45,9 +47,20 @@ export default { | ||
45 | [FETCH_CHANNEL_FAILURE](state) { | 47 | [FETCH_CHANNEL_FAILURE](state) { |
46 | state[state.gender].isFetching = false; | 48 | state[state.gender].isFetching = false; |
47 | }, | 49 | }, |
48 | - [FETCH_CHANNEL_SUCCESS](state, {data}) { | 50 | + [FETCH_CHANNEL_SUCCESS](state, {data, sort}) { |
51 | + const keyCvt = { | ||
52 | + men: 'MEN男士', | ||
53 | + women: 'WOMEN女士', | ||
54 | + }; | ||
55 | + | ||
49 | state[state.gender].isFetching = false; | 56 | state[state.gender].isFetching = false; |
57 | + | ||
58 | + // mock data | ||
59 | + data.splice(1, 0 , { | ||
60 | + category: true | ||
61 | + }); | ||
50 | state[state.gender].data = data; | 62 | state[state.gender].data = data; |
63 | + state[state.gender].sort = sort[keyCvt[state.gender]]; | ||
51 | }, | 64 | }, |
52 | }, | 65 | }, |
53 | actions: { | 66 | actions: { |
@@ -74,7 +87,11 @@ export default { | @@ -74,7 +87,11 @@ export default { | ||
74 | content_code: gender === 'men' ? CHANNEL_MAN_CONTENT_CODE : CHANNEL_WOMEN_CONTENT_CODE | 87 | content_code: gender === 'men' ? CHANNEL_MAN_CONTENT_CODE : CHANNEL_WOMEN_CONTENT_CODE |
75 | }); | 88 | }); |
76 | 89 | ||
77 | - commit(FETCH_CHANNEL_SUCCESS, result); | 90 | + const sort = await this.$api.get('/sort/list', { |
91 | + channel: gender | ||
92 | + }); | ||
93 | + | ||
94 | + commit(FETCH_CHANNEL_SUCCESS, {data: result.data, sort: sort.data}); | ||
78 | return result; | 95 | return result; |
79 | } catch (e) { | 96 | } catch (e) { |
80 | console.error(e); | 97 | console.error(e); |
-
Please register or login to post a comment