Authored by xuqi

Merge branch 'feature/params' into develop

... ... @@ -752,14 +752,7 @@
],
filter: {
.. //筛选数据结构
},
brand: '',
gender: '',
sort: '',
color: '',
size: '',
price: '',
discount: ''
}
}
}
... ...
/**
* 提取URL中的参数
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/11/19
*/
var opt = {};
var paramStr = window.location.search.split('?')[1];
var keyVal = paramStr ? paramStr.split('&') : [];
var i, key, val;
for (i = keyVal.length; i > 0; i--) {
key = keyVal[i - 1].split('=');
val = key[1];
key = key[0];
//初始化默认参数
opt[key] = val;
//discount = p_d,同时需要两个参数
if (key === 'discount' || key === 'p_d') {
opt.discount = val;
opt.p_d = val;
}
}
if (typeof opt.gender === 'undefined') {
switch (window.cookie('_Channel')) {
case 'boys':
opt.gender = '1,3';
break;
case 'girls':
opt.gender = '2,3';
break;
default:
opt.gender = '1,2,3';
}
}
module.exports = opt;
\ No newline at end of file
... ... @@ -31,7 +31,7 @@ var $input = $('#search-input input'),
$clear = $('#search-input .clear-input');
//默认筛选条件
var defaultOpt = require('./extract-url');
var defaultOpt = require('./query-param');
var $listNav = $('#list-nav'),
... ...
... ... @@ -24,7 +24,7 @@ var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
//默认筛选条件
var defaultOpt = require('../extract-url');
var defaultOpt = require('../query-param');
var $listNav = $('#list-nav'),
... ...
... ... @@ -27,7 +27,7 @@ var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
//默认筛选条件
var defaultOpt = require('../extract-url');
var defaultOpt = require('../query-param');
var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置
... ...
/**
* 提取查询参数
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/11/19
*/
var $ = require('jquery'),
opt = {};
$('.query-param').each(function() {
var $this = $(this);
opt[$this.data('attr')] = $this.val();
});
module.exports = opt;
\ No newline at end of file
... ...
... ... @@ -4,58 +4,6 @@
{{> product/banner-swipe-and-single}}
{{/ headerBanner}}
<div id="hotRank"></div>
{{#if brand}}
<input id="brand" type="hidden" value={{brand}}>
{{/if}}
{{#if gender}}
<input id="gender" type="hidden" value={{gender}}>
{{/if}}
{{#if sort}}
<input id="sort" type="hidden" value={{sort}}>
{{/if}}
{{#if msort}}
<input id="msort" type="hidden" value={{msort}}>
{{/if}}
{{#if misort}}
<input id="misort" type="hidden" value={{misort}}>
{{/if}}
{{#if color}}
<input id="color" type="hidden" value={{color}}>
{{/if}}
{{#if size}}
<input id="size" type="hidden" value={{size}}>
{{/if}}
{{#if price}}
<input id="price" type="hidden" value={{price}}>
{{/if}}
{{#if p_d}}
<input id="p_d" type="hidden" value={{p_d}}>
{{/if}}
{{#if channel}}
<input id="channel" type="hidden" value={{channel}}>
{{/if}}
{{#if limit}}
<input id="limit" type="hidden" value={{limit}}>
{{/if}}
{{#if page}}
<input id="page" type="hidden" value={{page}}>
{{/if}}
{{#if discount}}
<input id="discount" type="hidden" value={{discount}}>
{{/if}}
{{> product/suspend-cart}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -37,6 +37,9 @@
<div class="container hide clearfix"></div>
{{> filter}}
</div>
{{> product/query-param}}
{{> product/suspend-cart}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -48,6 +48,9 @@
{{> filter}}
</div>
{{> product/query-param}}
{{> product/suspend-cart}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -89,5 +89,8 @@
{{> filter}}
</div>
{{> product/query-param}}
{{> product/suspend-cart}}
{{/ goodList}}
\ No newline at end of file
... ...
{{#if brand}}
<input class="query-param" type="hidden" data-attr="brand" value="{{brand}}">
{{/if}}
{{#if gender}}
<input class="query-param" type="hidden" data-attr="gender" value="{{gender}}">
{{/if}}
{{#if sort}}
<input class="query-param" type="hidden" data-attr="sort" value="{{sort}}">
{{/if}}
{{#if msort}}
<input class="query-param" type="hidden" data-attr="msort" value="{{msort}}">
{{/if}}
{{#if misort}}
<input class="query-param" type="hidden" data-attr="misort" value="{{misort}}">
{{/if}}
{{#if color}}
<input class="query-param" type="hidden" data-attr="color" value="{{color}}">
{{/if}}
{{#if size}}
<input class="query-param" type="hidden" data-attr="size" value="{{size}}">
{{/if}}
{{#if price}}
<input class="query-param" type="hidden" data-attr="price" value="{{price}}">
{{/if}}
{{#if discount}}
<input class="query-param" type="hidden" data-attr="discount" value="{{discount}}">
{{/if}}
{{#if query}}
<input class="query-param" type="hidden" data-attr="query" value="{{query}}">
{{/if}}
{{#if style}}
<input class="query-param" type="hidden" data-attr="style" value="{{style}}">
{{/if}}
{{#if p_d}}
<input class="query-param" type="hidden" data-attr="p_d" value="{{p_d}}">
{{/if}}
{{#if channel}}
<input class="query-param" type="hidden" data-attr="channel" value="{{channel}}">
{{/if}}
{{#if dayLimit}}
<input class="query-param" type="hidden" data-attr="dayLimit" value="{{dayLimit}}">
{{/if}}
{{#if limit}}
<input class="query-param" type="hidden" data-attr="limit" value="{{limit}}">
{{/if}}
\ No newline at end of file
... ...