Showing
7 changed files
with
74 additions
and
192 deletions
static/js/product/extract-url.js
0 → 100644
1 | +/** | ||
2 | + * 提取URL中的参数 | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2015/11/19 | ||
5 | + */ | ||
6 | + | ||
7 | +var opt = {}; | ||
8 | + | ||
9 | +var paramStr = window.location.search.split('?')[1]; | ||
10 | + | ||
11 | +var keyVal = paramStr.split('&'); | ||
12 | + | ||
13 | +var i, key, val; | ||
14 | + | ||
15 | +for (i = keyVal.length; i > 0; i--) { | ||
16 | + key = keyVal[i - 1].split('='); | ||
17 | + | ||
18 | + val = key[1]; | ||
19 | + key = key[0]; | ||
20 | + | ||
21 | + //初始化默认参数 | ||
22 | + switch (key) { | ||
23 | + case 'gender': | ||
24 | + opt.gender = val; | ||
25 | + break; | ||
26 | + case 'brand': | ||
27 | + opt.brand = val; | ||
28 | + break; | ||
29 | + case 'sort': | ||
30 | + opt.sort = val; | ||
31 | + break; | ||
32 | + case 'msort': | ||
33 | + opt.msort = val; | ||
34 | + break; | ||
35 | + case 'misort': | ||
36 | + opt.misort = val; | ||
37 | + break; | ||
38 | + case 'color': | ||
39 | + opt.color = val; | ||
40 | + break; | ||
41 | + case 'size': | ||
42 | + opt.size = val; | ||
43 | + break; | ||
44 | + case 'price': | ||
45 | + opt.price = val; | ||
46 | + break; | ||
47 | + case 'discount': | ||
48 | + opt.discount = val; | ||
49 | + break; | ||
50 | + case 'query': | ||
51 | + opt.query = val; | ||
52 | + break; | ||
53 | + case 'style': | ||
54 | + opt.style = val; | ||
55 | + break; | ||
56 | + case 'limit': | ||
57 | + opt.limit = val; | ||
58 | + break; | ||
59 | + case 'channel': | ||
60 | + opt.channel = val; | ||
61 | + break; | ||
62 | + case 'p_d': | ||
63 | + opt.p_d = val; | ||
64 | + break; | ||
65 | + case 'dayLimit': | ||
66 | + opt.dayLimit = val; | ||
67 | + break; | ||
68 | + } | ||
69 | +} | ||
70 | + | ||
71 | +module.exports = opt; |
@@ -31,19 +31,7 @@ var $input = $('#search-input input'), | @@ -31,19 +31,7 @@ var $input = $('#search-input input'), | ||
31 | $clear = $('#search-input .clear-input'); | 31 | $clear = $('#search-input .clear-input'); |
32 | 32 | ||
33 | //默认筛选条件 | 33 | //默认筛选条件 |
34 | -var defaultOpt = { | ||
35 | - gender: $('#gender').val(), | ||
36 | - brand: $('#brand').val(), | ||
37 | - sort: $('#sort').val(), | ||
38 | - msort: $('#msort').val(), | ||
39 | - misort: $('#misort').val(), | ||
40 | - color: $('#color').val(), | ||
41 | - size: $('#size').val(), | ||
42 | - price: $('#price').val(), | ||
43 | - discount: $('#discount').val(), | ||
44 | - query: $('#query').val(), | ||
45 | - style: $('#style').val() | ||
46 | -}; | 34 | +var defaultOpt = require('./extract-url'); |
47 | 35 | ||
48 | var $listNav = $('#list-nav'), | 36 | var $listNav = $('#list-nav'), |
49 | 37 |
@@ -25,18 +25,7 @@ var winH = $(window).height(), | @@ -25,18 +25,7 @@ var winH = $(window).height(), | ||
25 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; | 25 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; |
26 | 26 | ||
27 | //默认筛选条件 | 27 | //默认筛选条件 |
28 | -var defaultOpt = { | ||
29 | - gender: $('#gender').val(), | ||
30 | - brand: $('#brand').val(), | ||
31 | - sort: $('#sort').val(), | ||
32 | - msort: $('#msort').val(), | ||
33 | - misort: $('#misort').val(), | ||
34 | - color: $('#color').val(), | ||
35 | - size: $('#size').val(), | ||
36 | - price: $('#price').val(), | ||
37 | - discount: $('#discount').val(), | ||
38 | - style: $('#style').val() | ||
39 | -}; | 28 | +var defaultOpt = require('../extract-url'); |
40 | 29 | ||
41 | var $listNav = $('#list-nav'), | 30 | var $listNav = $('#list-nav'), |
42 | 31 |
@@ -28,22 +28,7 @@ var winH = $(window).height(), | @@ -28,22 +28,7 @@ var winH = $(window).height(), | ||
28 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; | 28 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; |
29 | 29 | ||
30 | //默认筛选条件 | 30 | //默认筛选条件 |
31 | -var defaultOpt = { | ||
32 | - gender: $('#gender').val(), | ||
33 | - brand: $('#brand').val(), | ||
34 | - sort: $('#sort').val(), | ||
35 | - msort: $('#msort').val(), | ||
36 | - misort: $('#misort').val(), | ||
37 | - color: $('#color').val(), | ||
38 | - size: $('#size').val(), | ||
39 | - price: $('#price').val(), | ||
40 | - discount: $('#discount').val(), | ||
41 | - limit: $('#limit').val(), | ||
42 | - channel: $('#channel').val(), | ||
43 | - p_d: $('#p_d').val(), | ||
44 | - dayLimit: 1, | ||
45 | - style: $('#style').val() | ||
46 | -}; | 31 | +var defaultOpt = require('../extract-url'); |
47 | 32 | ||
48 | var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置 | 33 | var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置 |
49 | 34 |
@@ -37,59 +37,6 @@ | @@ -37,59 +37,6 @@ | ||
37 | <div class="container hide clearfix"></div> | 37 | <div class="container hide clearfix"></div> |
38 | {{> filter}} | 38 | {{> filter}} |
39 | </div> | 39 | </div> |
40 | - | ||
41 | - {{#if brand}} | ||
42 | - <input id="brand" type="hidden" value={{brand}}> | ||
43 | - {{/if}} | ||
44 | - | ||
45 | - {{#if gender}} | ||
46 | - <input id="gender" type="hidden" value={{gender}}> | ||
47 | - {{/if}} | ||
48 | - | ||
49 | - {{#if sort}} | ||
50 | - <input id="sort" type="hidden" value={{sort}}> | ||
51 | - {{/if}} | ||
52 | - | ||
53 | - {{#if msort}} | ||
54 | - <input id="msort" type="hidden" value={{msort}}> | ||
55 | - {{/if}} | ||
56 | - | ||
57 | - {{#if misort}} | ||
58 | - <input id="misort" type="hidden" value={{misort}}> | ||
59 | - {{/if}} | ||
60 | - | ||
61 | - {{#if color}} | ||
62 | - <input id="color" type="hidden" value={{color}}> | ||
63 | - {{/if}} | ||
64 | - | ||
65 | - {{#if size}} | ||
66 | - <input id="size" type="hidden" value={{size}}> | ||
67 | - {{/if}} | ||
68 | - | ||
69 | - {{#if price}} | ||
70 | - <input id="price" type="hidden" value={{price}}> | ||
71 | - {{/if}} | ||
72 | - | ||
73 | - {{#if p_d}} | ||
74 | - <input id="p_d" type="hidden" value={{p_d}}> | ||
75 | - {{/if}} | ||
76 | - | ||
77 | - {{#if channel}} | ||
78 | - <input id="channel" type="hidden" value={{channel}}> | ||
79 | - {{/if}} | ||
80 | - | ||
81 | - {{#if dayLimit}} | ||
82 | - <input id="dayLimit" type="hidden" value={{dayLimit}}> | ||
83 | - {{/if}} | ||
84 | - | ||
85 | - {{#if limit}} | ||
86 | - <input id="limit" type="hidden" value={{limit}}> | ||
87 | - {{/if}} | ||
88 | - | ||
89 | - {{#if style}} | ||
90 | - <input id="style" type="hidden" value={{style}}> | ||
91 | - {{/if}} | ||
92 | - | ||
93 | {{> product/suspend-cart}} | 40 | {{> product/suspend-cart}} |
94 | </div> | 41 | </div> |
95 | {{> layout/footer}} | 42 | {{> layout/footer}} |
@@ -48,59 +48,6 @@ | @@ -48,59 +48,6 @@ | ||
48 | 48 | ||
49 | {{> filter}} | 49 | {{> filter}} |
50 | </div> | 50 | </div> |
51 | - | ||
52 | - {{#if brand}} | ||
53 | - <input id="brand" type="hidden" value={{brand}}> | ||
54 | - {{/if}} | ||
55 | - | ||
56 | - {{#if gender}} | ||
57 | - <input id="gender" type="hidden" value={{gender}}> | ||
58 | - {{/if}} | ||
59 | - | ||
60 | - {{#if sort}} | ||
61 | - <input id="sort" type="hidden" value={{sort}}> | ||
62 | - {{/if}} | ||
63 | - | ||
64 | - {{#if msort}} | ||
65 | - <input id="msort" type="hidden" value={{msort}}> | ||
66 | - {{/if}} | ||
67 | - | ||
68 | - {{#if misort}} | ||
69 | - <input id="misort" type="hidden" value={{misort}}> | ||
70 | - {{/if}} | ||
71 | - | ||
72 | - {{#if color}} | ||
73 | - <input id="color" type="hidden" value={{color}}> | ||
74 | - {{/if}} | ||
75 | - | ||
76 | - {{#if size}} | ||
77 | - <input id="size" type="hidden" value={{size}}> | ||
78 | - {{/if}} | ||
79 | - | ||
80 | - {{#if price}} | ||
81 | - <input id="price" type="hidden" value={{price}}> | ||
82 | - {{/if}} | ||
83 | - | ||
84 | - {{#if p_d}} | ||
85 | - <input id="p_d" type="hidden" value={{p_d}}> | ||
86 | - {{/if}} | ||
87 | - | ||
88 | - {{#if channel}} | ||
89 | - <input id="channel" type="hidden" value={{channel}}> | ||
90 | - {{/if}} | ||
91 | - | ||
92 | - {{#if limit}} | ||
93 | - <input id="limit" type="hidden" value={{limit}}> | ||
94 | - {{/if}} | ||
95 | - | ||
96 | - {{#if discount}} | ||
97 | - <input id="discount" type="hidden" value={{discount}}> | ||
98 | - {{/if}} | ||
99 | - | ||
100 | - {{#if style}} | ||
101 | - <input id="style" type="hidden" value={{style}}> | ||
102 | - {{/if}} | ||
103 | - | ||
104 | {{> product/suspend-cart}} | 51 | {{> product/suspend-cart}} |
105 | </div> | 52 | </div> |
106 | {{> layout/footer}} | 53 | {{> layout/footer}} |
@@ -89,50 +89,5 @@ | @@ -89,50 +89,5 @@ | ||
89 | 89 | ||
90 | {{> filter}} | 90 | {{> filter}} |
91 | </div> | 91 | </div> |
92 | - | ||
93 | - {{#if brand}} | ||
94 | - <input id="brand" type="hidden" value={{brand}}> | ||
95 | - {{/if}} | ||
96 | - | ||
97 | - {{#if gender}} | ||
98 | - <input id="gender" type="hidden" value={{gender}}> | ||
99 | - {{/if}} | ||
100 | - | ||
101 | - {{#if sort}} | ||
102 | - <input id="sort" type="hidden" value={{sort}}> | ||
103 | - {{/if}} | ||
104 | - | ||
105 | - {{#if msort}} | ||
106 | - <input id="msort" type="hidden" value={{msort}}> | ||
107 | - {{/if}} | ||
108 | - | ||
109 | - {{#if misort}} | ||
110 | - <input id="misort" type="hidden" value={{misort}}> | ||
111 | - {{/if}} | ||
112 | - | ||
113 | - {{#if color}} | ||
114 | - <input id="color" type="hidden" value={{color}}> | ||
115 | - {{/if}} | ||
116 | - | ||
117 | - {{#if size}} | ||
118 | - <input id="size" type="hidden" value={{size}}> | ||
119 | - {{/if}} | ||
120 | - | ||
121 | - {{#if price}} | ||
122 | - <input id="price" type="hidden" value={{price}}> | ||
123 | - {{/if}} | ||
124 | - | ||
125 | - {{#if discount}} | ||
126 | - <input id="discount" type="hidden" value={{discount}}> | ||
127 | - {{/if}} | ||
128 | - | ||
129 | - {{#if query}} | ||
130 | - <input id="query" type="hidden" value={{query}}> | ||
131 | - {{/if}} | ||
132 | - | ||
133 | - {{#if style}} | ||
134 | - <input id="style" type="hidden" value={{style}}> | ||
135 | - {{/if}} | ||
136 | - | ||
137 | {{> product/suspend-cart}} | 92 | {{> product/suspend-cart}} |
138 | {{/ goodList}} | 93 | {{/ goodList}} |
-
Please register or login to post a comment