Showing
4 changed files
with
124 additions
and
5 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 | </div> | 9 | </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'); | 2 | +const sort = require('component/sort.vue'); |
3 | +const list = require('component/list.vue'); | ||
4 | +const filter = require('component/filter.vue'); | ||
4 | 5 | ||
5 | require('common/vue-filter'); | 6 | require('common/vue-filter'); |
6 | 7 | ||
7 | new Vue({ | 8 | new Vue({ |
8 | el: '#product-list', | 9 | el: '#product-list', |
9 | components: { | 10 | components: { |
10 | - List, Sort | 11 | + list, sort, filter |
11 | } | 12 | } |
12 | }); | 13 | }); |
public/vue/component/filter.vue
0 → 100644
1 | +<template> | ||
2 | + <div class="filter"> | ||
3 | + <div class="filter-actions"> | ||
4 | + <a href="javascript:; filter-action">清空</a> | ||
5 | + <button class="button button-small filter-action">确定</button> | ||
6 | + </div> | ||
7 | + <div class="filter-params"> | ||
8 | + <ul class="filter-cates"> | ||
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> | ||
13 | + </li> | ||
14 | + </ul> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | +</template> | ||
18 | +<style> | ||
19 | +@import "../../scss/common/color"; | ||
20 | + | ||
21 | +.filter { | ||
22 | + padding: 0 20px; | ||
23 | +} | ||
24 | + | ||
25 | +.filter-actions { | ||
26 | + text-align: right; | ||
27 | + padding: 10px 0; | ||
28 | +} | ||
29 | + | ||
30 | +.filter-action { | ||
31 | + margin-left: 20px; | ||
32 | +} | ||
33 | + | ||
34 | +.filter-actions, | ||
35 | +.filter-cate { | ||
36 | + border-bottom: 1px solid $grey; | ||
37 | +} | ||
38 | + | ||
39 | +.filter-cates { | ||
40 | + list-style: none; | ||
41 | + margin: 0; | ||
42 | + padding: 0; | ||
43 | +} | ||
44 | + | ||
45 | +.filter-cate { | ||
46 | + .icon-right { | ||
47 | + float: right; | ||
48 | + } | ||
49 | +} | ||
50 | + | ||
51 | +.filter-cate-val { | ||
52 | + float: right; | ||
53 | +} | ||
54 | + | ||
55 | +.filter-cate-val, | ||
56 | +.filter-cate .icon { | ||
57 | + color: $grey; | ||
58 | +} | ||
59 | +</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> |
@@ -28,6 +28,7 @@ module.exports = { | @@ -28,6 +28,7 @@ module.exports = { | ||
28 | type: String, | 28 | type: String, |
29 | required: true | 29 | required: true |
30 | }, | 30 | }, |
31 | + initData: Array, /* 初始数据, 应该只单次绑定, 然后fetch数据全靠url */ | ||
31 | query: Object /* 请求参数 */ | 32 | query: Object /* 请求参数 */ |
32 | }, | 33 | }, |
33 | data: function() { | 34 | data: function() { |
@@ -48,8 +49,13 @@ module.exports = { | @@ -48,8 +49,13 @@ module.exports = { | ||
48 | }); | 49 | }); |
49 | } | 50 | } |
50 | }, | 51 | }, |
51 | - ready: function() { | ||
52 | - this.fetch(); | 52 | + created: function() { |
53 | + // 有初始数据,用初始数据 | ||
54 | + if (this.initData) { | ||
55 | + self.$set('products', self.products.concat(this.initData)); | ||
56 | + } else if (this.url) { | ||
57 | + this.fetch(); | ||
58 | + } | ||
53 | }, | 59 | }, |
54 | }; | 60 | }; |
55 | </script> | 61 | </script> |
@@ -109,4 +115,23 @@ module.exports = { | @@ -109,4 +115,23 @@ module.exports = { | ||
109 | color: $red; | 115 | color: $red; |
110 | } | 116 | } |
111 | } | 117 | } |
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 | +} | ||
112 | </style> | 137 | </style> |
-
Please register or login to post a comment