Merge branch 'feature/params' into develop
Showing
11 changed files
with
88 additions
and
107 deletions
static/js/product/extract-url.js
deleted
100644 → 0
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 ? 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 | - opt[key] = val; | ||
23 | - | ||
24 | - //discount = p_d,同时需要两个参数 | ||
25 | - if (key === 'discount' || key === 'p_d') { | ||
26 | - opt.discount = val; | ||
27 | - opt.p_d = val; | ||
28 | - } | ||
29 | -} | ||
30 | - | ||
31 | -if (typeof opt.gender === 'undefined') { | ||
32 | - switch (window.cookie('_Channel')) { | ||
33 | - case 'boys': | ||
34 | - opt.gender = '1,3'; | ||
35 | - break; | ||
36 | - case 'girls': | ||
37 | - opt.gender = '2,3'; | ||
38 | - break; | ||
39 | - default: | ||
40 | - opt.gender = '1,2,3'; | ||
41 | - } | ||
42 | -} | ||
43 | - | ||
44 | -module.exports = opt; |
@@ -31,7 +31,7 @@ var $input = $('#search-input input'), | @@ -31,7 +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 = require('./extract-url'); | 34 | +var defaultOpt = require('./query-param'); |
35 | 35 | ||
36 | var $listNav = $('#list-nav'), | 36 | var $listNav = $('#list-nav'), |
37 | 37 |
@@ -24,7 +24,7 @@ var winH = $(window).height(), | @@ -24,7 +24,7 @@ var winH = $(window).height(), | ||
24 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; | 24 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; |
25 | 25 | ||
26 | //默认筛选条件 | 26 | //默认筛选条件 |
27 | -var defaultOpt = require('../extract-url'); | 27 | +var defaultOpt = require('../query-param'); |
28 | 28 | ||
29 | var $listNav = $('#list-nav'), | 29 | var $listNav = $('#list-nav'), |
30 | 30 |
@@ -27,7 +27,7 @@ var winH = $(window).height(), | @@ -27,7 +27,7 @@ var winH = $(window).height(), | ||
27 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; | 27 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; |
28 | 28 | ||
29 | //默认筛选条件 | 29 | //默认筛选条件 |
30 | -var defaultOpt = require('../extract-url'); | 30 | +var defaultOpt = require('../query-param'); |
31 | 31 | ||
32 | var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置 | 32 | var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置 |
33 | 33 |
static/js/product/query-param.js
0 → 100644
@@ -4,58 +4,6 @@ | @@ -4,58 +4,6 @@ | ||
4 | {{> product/banner-swipe-and-single}} | 4 | {{> product/banner-swipe-and-single}} |
5 | {{/ headerBanner}} | 5 | {{/ headerBanner}} |
6 | <div id="hotRank"></div> | 6 | <div id="hotRank"></div> |
7 | - {{#if brand}} | ||
8 | - <input id="brand" type="hidden" value={{brand}}> | ||
9 | - {{/if}} | ||
10 | - | ||
11 | - {{#if gender}} | ||
12 | - <input id="gender" type="hidden" value={{gender}}> | ||
13 | - {{/if}} | ||
14 | - | ||
15 | - {{#if sort}} | ||
16 | - <input id="sort" type="hidden" value={{sort}}> | ||
17 | - {{/if}} | ||
18 | - | ||
19 | - {{#if msort}} | ||
20 | - <input id="msort" type="hidden" value={{msort}}> | ||
21 | - {{/if}} | ||
22 | - | ||
23 | - {{#if misort}} | ||
24 | - <input id="misort" type="hidden" value={{misort}}> | ||
25 | - {{/if}} | ||
26 | - | ||
27 | - {{#if color}} | ||
28 | - <input id="color" type="hidden" value={{color}}> | ||
29 | - {{/if}} | ||
30 | - | ||
31 | - {{#if size}} | ||
32 | - <input id="size" type="hidden" value={{size}}> | ||
33 | - {{/if}} | ||
34 | - | ||
35 | - {{#if price}} | ||
36 | - <input id="price" type="hidden" value={{price}}> | ||
37 | - {{/if}} | ||
38 | - | ||
39 | - {{#if p_d}} | ||
40 | - <input id="p_d" type="hidden" value={{p_d}}> | ||
41 | - {{/if}} | ||
42 | - | ||
43 | - {{#if channel}} | ||
44 | - <input id="channel" type="hidden" value={{channel}}> | ||
45 | - {{/if}} | ||
46 | - | ||
47 | - {{#if limit}} | ||
48 | - <input id="limit" type="hidden" value={{limit}}> | ||
49 | - {{/if}} | ||
50 | - | ||
51 | - {{#if page}} | ||
52 | - <input id="page" type="hidden" value={{page}}> | ||
53 | - {{/if}} | ||
54 | - | ||
55 | - {{#if discount}} | ||
56 | - <input id="discount" type="hidden" value={{discount}}> | ||
57 | - {{/if}} | ||
58 | - | ||
59 | {{> product/suspend-cart}} | 7 | {{> product/suspend-cart}} |
60 | </div> | 8 | </div> |
61 | {{> layout/footer}} | 9 | {{> layout/footer}} |
@@ -37,6 +37,9 @@ | @@ -37,6 +37,9 @@ | ||
37 | <div class="container hide clearfix"></div> | 37 | <div class="container hide clearfix"></div> |
38 | {{> filter}} | 38 | {{> filter}} |
39 | </div> | 39 | </div> |
40 | + | ||
41 | + {{> product/query-param}} | ||
42 | + | ||
40 | {{> product/suspend-cart}} | 43 | {{> product/suspend-cart}} |
41 | </div> | 44 | </div> |
42 | {{> layout/footer}} | 45 | {{> layout/footer}} |
1 | +{{#if brand}} | ||
2 | + <input class="query-param" type="hidden" data-attr="brand" value="{{brand}}"> | ||
3 | +{{/if}} | ||
4 | + | ||
5 | +{{#if gender}} | ||
6 | + <input class="query-param" type="hidden" data-attr="gender" value="{{gender}}"> | ||
7 | +{{/if}} | ||
8 | + | ||
9 | +{{#if sort}} | ||
10 | + <input class="query-param" type="hidden" data-attr="sort" value="{{sort}}"> | ||
11 | +{{/if}} | ||
12 | + | ||
13 | +{{#if msort}} | ||
14 | + <input class="query-param" type="hidden" data-attr="msort" value="{{msort}}"> | ||
15 | +{{/if}} | ||
16 | + | ||
17 | +{{#if misort}} | ||
18 | + <input class="query-param" type="hidden" data-attr="misort" value="{{misort}}"> | ||
19 | +{{/if}} | ||
20 | + | ||
21 | +{{#if color}} | ||
22 | + <input class="query-param" type="hidden" data-attr="color" value="{{color}}"> | ||
23 | +{{/if}} | ||
24 | + | ||
25 | +{{#if size}} | ||
26 | + <input class="query-param" type="hidden" data-attr="size" value="{{size}}"> | ||
27 | +{{/if}} | ||
28 | + | ||
29 | +{{#if price}} | ||
30 | + <input class="query-param" type="hidden" data-attr="price" value="{{price}}"> | ||
31 | +{{/if}} | ||
32 | + | ||
33 | +{{#if discount}} | ||
34 | + <input class="query-param" type="hidden" data-attr="discount" value="{{discount}}"> | ||
35 | +{{/if}} | ||
36 | + | ||
37 | +{{#if query}} | ||
38 | + <input class="query-param" type="hidden" data-attr="query" value="{{query}}"> | ||
39 | +{{/if}} | ||
40 | + | ||
41 | +{{#if style}} | ||
42 | + <input class="query-param" type="hidden" data-attr="style" value="{{style}}"> | ||
43 | +{{/if}} | ||
44 | + | ||
45 | +{{#if p_d}} | ||
46 | + <input class="query-param" type="hidden" data-attr="p_d" value="{{p_d}}"> | ||
47 | +{{/if}} | ||
48 | + | ||
49 | +{{#if channel}} | ||
50 | + <input class="query-param" type="hidden" data-attr="channel" value="{{channel}}"> | ||
51 | +{{/if}} | ||
52 | + | ||
53 | +{{#if dayLimit}} | ||
54 | + <input class="query-param" type="hidden" data-attr="dayLimit" value="{{dayLimit}}"> | ||
55 | +{{/if}} | ||
56 | + | ||
57 | +{{#if limit}} | ||
58 | + <input class="query-param" type="hidden" data-attr="limit" value="{{limit}}"> | ||
59 | +{{/if}} |
-
Please register or login to post a comment