Merge branch 'develop' into feature/channel
Showing
8 changed files
with
186 additions
and
79 deletions
1 | <div id="product-list"> | 1 | <div id="product-list"> |
2 | <Sort></Sort> | 2 | <Sort></Sort> |
3 | <List url="/product/list" :query='{a:1}'></List> | 3 | <List url="/product/list" :query='{a:1}'></List> |
4 | - <div class="drawer-slide"> | ||
5 | - <div class="drawer-main"> | ||
6 | - <filter></filter> | ||
7 | - </div> | ||
8 | - </div> | 4 | + <Drawer> |
5 | + <Filter></Filter> | ||
6 | + </Drawer> | ||
9 | </div> | 7 | </div> |
1 | const Vue = require('yoho-vue'); | 1 | const Vue = require('yoho-vue'); |
2 | -const sort = require('component/sort.vue'); | ||
3 | -const list = require('component/list.vue'); | ||
4 | -const filter = require('component/filter.vue'); | 2 | +const lazyload = require('yoho-vue-lazyload'); |
3 | +const infinitScroll = require('yoho-vue-infinite-scroll'); | ||
4 | +const sort = require('product/sort.vue'); | ||
5 | +const list = require('product/list.vue'); | ||
6 | +const drawer = require('product/drawer.vue'); | ||
7 | +const filter = require('product/filter.vue'); | ||
8 | + | ||
9 | +Vue.use(lazyload); | ||
10 | +Vue.use(infinitScroll); | ||
5 | 11 | ||
6 | require('common/vue-filter'); | 12 | require('common/vue-filter'); |
7 | 13 | ||
8 | new Vue({ | 14 | new Vue({ |
9 | el: '#product-list', | 15 | el: '#product-list', |
10 | components: { | 16 | components: { |
11 | - list, sort, filter | 17 | + list, sort, filter, drawer |
12 | } | 18 | } |
13 | }); | 19 | }); |
public/vue/product/drawer.vue
0 → 100644
1 | +<template> | ||
2 | + <div class="drawer" :class="{'drawer-open': on }" v-show="on"> | ||
3 | + <div class="drawer-main" v-el:main> | ||
4 | + <slot></slot> | ||
5 | + </div> | ||
6 | + </div> | ||
7 | +</template> | ||
8 | +<script> | ||
9 | +module.exports = { | ||
10 | + props: { | ||
11 | + on: Boolean | ||
12 | + } | ||
13 | +}; | ||
14 | +</script> | ||
15 | +<style> | ||
16 | +.drawer { | ||
17 | + position: fixed; | ||
18 | + top: 0; | ||
19 | + right: 0; | ||
20 | + bottom: 0; | ||
21 | + left: 0; | ||
22 | + background-color: rgba(0, 0, 0, 0.6); | ||
23 | +} | ||
24 | + | ||
25 | +.drawer-main { | ||
26 | + position: absolute; | ||
27 | + top: 0; | ||
28 | + right: 0%; | ||
29 | + bottom: 0; | ||
30 | + min-width: 80%; | ||
31 | + max-width: 100%; | ||
32 | + background-color: #fff; | ||
33 | + transition: all 0.3s 0.2s; | ||
34 | +} | ||
35 | +</style> |
1 | <template> | 1 | <template> |
2 | <div class="filter"> | 2 | <div class="filter"> |
3 | <div class="filter-actions"> | 3 | <div class="filter-actions"> |
4 | - <a href="javascript:; filter-action">清空</a> | 4 | + <a href="javascript:;" class="filter-action" @click="clearVals">清空</a> |
5 | <button class="button button-small filter-action">确定</button> | 5 | <button class="button button-small filter-action">确定</button> |
6 | </div> | 6 | </div> |
7 | <div class="filter-params"> | 7 | <div class="filter-params"> |
8 | <ul class="filter-cates"> | 8 | <ul class="filter-cates"> |
9 | <li class="filter-cate" v-for="filter in filters"> | 9 | <li class="filter-cate" v-for="filter in filters"> |
10 | - <i class="icon icon-right"></i> | ||
11 | - <span>{{filter.classfly}}</span> | ||
12 | - <span class="filter-cate-val">{{val[filter.key]}}</span> | 10 | + <i class="icon icon-right right"></i> |
11 | + <span class="filter-cate-label">{{filter.classfly}}</span> | ||
12 | + <span class="filter-cate-val">{{vals[filter.key]}}</span> | ||
13 | </li> | 13 | </li> |
14 | </ul> | 14 | </ul> |
15 | </div> | 15 | </div> |
16 | </div> | 16 | </div> |
17 | </template> | 17 | </template> |
18 | +<script> | ||
19 | +const $ = require('yoho-jquery'); | ||
20 | + | ||
21 | +module.exports = { | ||
22 | + data: function() { | ||
23 | + return { | ||
24 | + vals: { | ||
25 | + brand: 'Supreme', | ||
26 | + category: '夹克' | ||
27 | + }, | ||
28 | + filters: [{ | ||
29 | + classfly: 'Brand品牌', | ||
30 | + key: 'brand', | ||
31 | + itemArray: [] | ||
32 | + }, { | ||
33 | + classfly: 'Category品类', | ||
34 | + key: 'category', | ||
35 | + itemArray: [] | ||
36 | + }, { | ||
37 | + classfly: 'Color颜色', | ||
38 | + key: 'color', | ||
39 | + itemArray: [] | ||
40 | + }, { | ||
41 | + classfly: 'Size尺寸', | ||
42 | + key: 'size', | ||
43 | + itemArray: [] | ||
44 | + }] | ||
45 | + }; | ||
46 | + }, | ||
47 | + methods: { | ||
48 | + clearVals: function() { | ||
49 | + const self = this; | ||
50 | + | ||
51 | + $.each(this.vals, (k) => { | ||
52 | + self.vals[k] = ''; | ||
53 | + }); | ||
54 | + } | ||
55 | + } | ||
56 | +}; | ||
57 | +</script> | ||
18 | <style> | 58 | <style> |
19 | @import "../../scss/common/color"; | 59 | @import "../../scss/common/color"; |
20 | 60 | ||
21 | .filter { | 61 | .filter { |
22 | - padding: 0 20px; | 62 | + padding: 0 30px; |
23 | } | 63 | } |
24 | 64 | ||
25 | .filter-actions { | 65 | .filter-actions { |
66 | + font-size: 34px; | ||
26 | text-align: right; | 67 | text-align: right; |
27 | - padding: 10px 0; | 68 | + padding: 45px 0; |
28 | } | 69 | } |
29 | 70 | ||
30 | .filter-action { | 71 | .filter-action { |
31 | - margin-left: 20px; | 72 | + font-size: inherit; |
73 | + margin-left: 40px; | ||
32 | } | 74 | } |
33 | 75 | ||
34 | .filter-actions, | 76 | .filter-actions, |
@@ -42,14 +84,24 @@ | @@ -42,14 +84,24 @@ | ||
42 | padding: 0; | 84 | padding: 0; |
43 | } | 85 | } |
44 | 86 | ||
45 | -.filter-cate { | ||
46 | - .icon-right { | ||
47 | - float: right; | ||
48 | - } | 87 | +.filter-cate .icon-right { |
88 | + margin-left: 24px; | ||
89 | +} | ||
90 | + | ||
91 | +.filter-cate, | ||
92 | +.icon-right { | ||
93 | + height: 118px; | ||
94 | + line-height: 118px; | ||
95 | +} | ||
96 | + | ||
97 | +.filter-cate-label { | ||
98 | + font-size: 36px; | ||
99 | + font-weight: bold; | ||
49 | } | 100 | } |
50 | 101 | ||
51 | .filter-cate-val { | 102 | .filter-cate-val { |
52 | float: right; | 103 | float: right; |
104 | + font-size: 28px; | ||
53 | } | 105 | } |
54 | 106 | ||
55 | .filter-cate-val, | 107 | .filter-cate-val, |
@@ -57,32 +109,3 @@ | @@ -57,32 +109,3 @@ | ||
57 | color: $grey; | 109 | color: $grey; |
58 | } | 110 | } |
59 | </style> | 111 | </style> |
60 | -<script> | ||
61 | -module.exports = { | ||
62 | - data: function() { | ||
63 | - return { | ||
64 | - val: { | ||
65 | - brand: 'Supreme', | ||
66 | - category: '夹克' | ||
67 | - }, | ||
68 | - filters: [{ | ||
69 | - classfly: 'Brand品牌', | ||
70 | - key: 'brand', | ||
71 | - itemArray: [] | ||
72 | - }, { | ||
73 | - classfly: 'Category品类', | ||
74 | - key: 'category', | ||
75 | - itemArray: [] | ||
76 | - }, { | ||
77 | - classfly: 'Color颜色', | ||
78 | - key: 'color', | ||
79 | - itemArray: [] | ||
80 | - }, { | ||
81 | - classfly: 'Size尺寸', | ||
82 | - key: 'size', | ||
83 | - itemArray: [] | ||
84 | - }] | ||
85 | - }; | ||
86 | - } | ||
87 | -}; | ||
88 | -</script> |
1 | <template> | 1 | <template> |
2 | - <div class="goods-box"> | ||
3 | - <ul class="cardlist card-large"> | 2 | + <div class="goods-box" v-infinite-scroll="fetch()" infinite-scroll-disable="disableFetch"> |
3 | + <ul class="cardlist card-large clearfix"> | ||
4 | <li class="card" v-for="item in products"> | 4 | <li class="card" v-for="item in products"> |
5 | <div class="card-pic"> | 5 | <div class="card-pic"> |
6 | <a href=""> | 6 | <a href=""> |
7 | - <img :src="item.goodsList[0].imagesUrl | resize 372 499" alt="{{item.productName}}"> | 7 | + <img v-lazy="item.goodsList[0].imagesUrl | resize 372 499" alt="{{item.productName}}"> |
8 | </a> | 8 | </a> |
9 | </div> | 9 | </div> |
10 | <div class="card-bd"> | 10 | <div class="card-bd"> |
@@ -16,43 +16,76 @@ | @@ -16,43 +16,76 @@ | ||
16 | </div> | 16 | </div> |
17 | </li> | 17 | </li> |
18 | </ul> | 18 | </ul> |
19 | + <p class="cardlist--loading text-center" v-show="inLoading">正在加载...</p> | ||
20 | + <p class="cardlist--end text-center" v-show="atEnd ">--End--</p> | ||
19 | </div> | 21 | </div> |
20 | </template> | 22 | </template> |
21 | <script> | 23 | <script> |
22 | let $ = require('yoho-jquery'); | 24 | let $ = require('yoho-jquery'); |
23 | 25 | ||
26 | +/** | ||
27 | + * @example | ||
28 | + * <List url='' :query='{}' disable-fetch></List> | ||
29 | + * <List :init-data='{}'></List> | ||
30 | + */ | ||
31 | + | ||
24 | module.exports = { | 32 | module.exports = { |
25 | props: { | 33 | props: { |
34 | + | ||
26 | /* 请求地址 */ | 35 | /* 请求地址 */ |
27 | url: { | 36 | url: { |
28 | type: String, | 37 | type: String, |
29 | required: true | 38 | required: true |
30 | }, | 39 | }, |
31 | - initData: Array, /* 初始数据, 应该只单次绑定, 然后fetch数据全靠url */ | ||
32 | - query: Object /* 请求参数 */ | 40 | + |
41 | + /* 初始数据, 应该只单次绑定, 然后fetch数据全靠url */ | ||
42 | + initData: Array, | ||
43 | + | ||
44 | + /* 请求参数 */ | ||
45 | + query: Object, | ||
46 | + | ||
47 | + /* 开启滚动加载 */ | ||
48 | + disableFetch: Boolean | ||
33 | }, | 49 | }, |
34 | data: function() { | 50 | data: function() { |
35 | return { | 51 | return { |
36 | - products: [] | 52 | + state: { |
53 | + curPage: 0, | ||
54 | + totalPage: 10 | ||
55 | + }, | ||
56 | + products: [], | ||
57 | + inLoading: false, | ||
58 | + atEnd: false | ||
37 | }; | 59 | }; |
38 | }, | 60 | }, |
39 | methods: { | 61 | methods: { |
40 | fetch: function() { | 62 | fetch: function() { |
63 | + if (this.atEnd) { | ||
64 | + return; | ||
65 | + } | ||
41 | let self = this; | 66 | let self = this; |
42 | 67 | ||
68 | + this.state.curPage++; | ||
69 | + this.inLoading = true; | ||
43 | $.ajax({ | 70 | $.ajax({ |
44 | url: this.url, | 71 | url: this.url, |
45 | type: 'POST', | 72 | type: 'POST', |
46 | }) | 73 | }) |
47 | - .then(result => { | 74 | + .done(result => { |
48 | self.$set('products', self.products.concat(result.data.productList)); | 75 | self.$set('products', self.products.concat(result.data.productList)); |
76 | + }) | ||
77 | + .always(() => { | ||
78 | + self.inLoading = false; | ||
79 | + self.atEnd = self.state.curPage === self.state.totalPage; | ||
49 | }); | 80 | }); |
81 | + | ||
50 | } | 82 | } |
51 | }, | 83 | }, |
52 | created: function() { | 84 | created: function() { |
53 | // 有初始数据,用初始数据 | 85 | // 有初始数据,用初始数据 |
54 | if (this.initData) { | 86 | if (this.initData) { |
55 | - self.$set('products', self.products.concat(this.initData)); | 87 | + this.$set('products', this.products.concat(this.initData)); |
88 | + this.atEnd = true; | ||
56 | } else if (this.url) { | 89 | } else if (this.url) { |
57 | this.fetch(); | 90 | this.fetch(); |
58 | } | 91 | } |
@@ -115,23 +148,4 @@ module.exports = { | @@ -115,23 +148,4 @@ module.exports = { | ||
115 | color: $red; | 148 | color: $red; |
116 | } | 149 | } |
117 | } | 150 | } |
118 | - | ||
119 | -.drawer-slide { | ||
120 | - position: fixed; | ||
121 | - top: 0; | ||
122 | - right: 0; | ||
123 | - bottom: 0; | ||
124 | - left: 0; | ||
125 | - background-color: rgba(0, 0, 0, 0.6); | ||
126 | -} | ||
127 | - | ||
128 | -.drawer-main { | ||
129 | - position: absolute; | ||
130 | - top: 0; | ||
131 | - right: 0; | ||
132 | - bottom: 0; | ||
133 | - min-width: 80%; | ||
134 | - max-width: 100%; | ||
135 | - background-color: #fff; | ||
136 | -} | ||
137 | </style> | 151 | </style> |
@@ -3,22 +3,30 @@ | @@ -3,22 +3,30 @@ | ||
3 | <li class="sort-item active"><span>默认</span></li> | 3 | <li class="sort-item active"><span>默认</span></li> |
4 | <li class="sort-item"> | 4 | <li class="sort-item"> |
5 | <span class="sort-name">最新</span> | 5 | <span class="sort-name">最新</span> |
6 | + <span class="sort-icon"> | ||
7 | + <i class="icon icon-sort-asc"></i> | ||
8 | + <i class="icon icon-sort-desc"></i> | ||
9 | + </span> | ||
6 | </li> | 10 | </li> |
7 | <li class="sort-item"> | 11 | <li class="sort-item"> |
8 | <span class="sort-name">价格</span> | 12 | <span class="sort-name">价格</span> |
9 | </li> | 13 | </li> |
10 | <li class="sort-item"> | 14 | <li class="sort-item"> |
11 | <span class="sort-name">折扣</span> | 15 | <span class="sort-name">折扣</span> |
16 | + <span class="sort-icon"> | ||
17 | + <i class="icon icon-sort-asc"></i> | ||
18 | + <i class="icon icon-sort-desc"></i> | ||
19 | + </span> | ||
12 | </li> | 20 | </li> |
13 | </ul> | 21 | </ul> |
14 | </template> | 22 | </template> |
15 | <script> | 23 | <script> |
16 | module.exports = { | 24 | module.exports = { |
17 | 25 | ||
18 | -} | 26 | +}; |
19 | </script> | 27 | </script> |
20 | <style> | 28 | <style> |
21 | -@import '../../scss/common/color'; | 29 | +@import "../../scss/common/color"; |
22 | 30 | ||
23 | .sort-navs { | 31 | .sort-navs { |
24 | list-style: none; | 32 | list-style: none; |
@@ -35,7 +43,7 @@ module.exports = { | @@ -35,7 +43,7 @@ module.exports = { | ||
35 | text-align: center; | 43 | text-align: center; |
36 | 44 | ||
37 | &:after { | 45 | &:after { |
38 | - content: '|'; | 46 | + content: "|"; |
39 | position: absolute; | 47 | position: absolute; |
40 | right: 0; | 48 | right: 0; |
41 | color: $grey; | 49 | color: $grey; |
@@ -49,6 +57,18 @@ module.exports = { | @@ -49,6 +57,18 @@ module.exports = { | ||
49 | font-size: 28px; | 57 | font-size: 28px; |
50 | } | 58 | } |
51 | 59 | ||
60 | + .sort-icon { | ||
61 | + position: relative; | ||
62 | + margin-left: 10px; | ||
63 | + | ||
64 | + .icon-sort-asc, | ||
65 | + .icon-sort-desc { | ||
66 | + position: absolute; | ||
67 | + left: 0; | ||
68 | + top: 0; | ||
69 | + } | ||
70 | + } | ||
71 | + | ||
52 | &.active { | 72 | &.active { |
53 | color: $black; | 73 | color: $black; |
54 | } | 74 | } |
-
Please register or login to post a comment