Authored by xuqi

extract url param

/**
* 提取URL中的参数
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/11/19
*/
var opt = {};
var paramStr = window.location.search.split('?')[1];
var keyVal = paramStr.split('&');
var i, key, val;
for (i = keyVal.length; i > 0; i--) {
key = keyVal[i - 1].split('=');
val = key[1];
key = key[0];
//初始化默认参数
switch (key) {
case 'gender':
opt.gender = val;
break;
case 'brand':
opt.brand = val;
break;
case 'sort':
opt.sort = val;
break;
case 'msort':
opt.msort = val;
break;
case 'misort':
opt.misort = val;
break;
case 'color':
opt.color = val;
break;
case 'size':
opt.size = val;
break;
case 'price':
opt.price = val;
break;
case 'discount':
opt.discount = val;
break;
case 'query':
opt.query = val;
break;
case 'style':
opt.style = val;
break;
case 'limit':
opt.limit = val;
break;
case 'channel':
opt.channel = val;
break;
case 'p_d':
opt.p_d = val;
break;
case 'dayLimit':
opt.dayLimit = val;
break;
}
}
module.exports = opt;
\ No newline at end of file
... ...
... ... @@ -31,19 +31,7 @@ var $input = $('#search-input input'),
$clear = $('#search-input .clear-input');
//默认筛选条件
var defaultOpt = {
gender: $('#gender').val(),
brand: $('#brand').val(),
sort: $('#sort').val(),
msort: $('#msort').val(),
misort: $('#misort').val(),
color: $('#color').val(),
size: $('#size').val(),
price: $('#price').val(),
discount: $('#discount').val(),
query: $('#query').val(),
style: $('#style').val()
};
var defaultOpt = require('./extract-url');
var $listNav = $('#list-nav'),
... ...
... ... @@ -25,18 +25,7 @@ var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
//默认筛选条件
var defaultOpt = {
gender: $('#gender').val(),
brand: $('#brand').val(),
sort: $('#sort').val(),
msort: $('#msort').val(),
misort: $('#misort').val(),
color: $('#color').val(),
size: $('#size').val(),
price: $('#price').val(),
discount: $('#discount').val(),
style: $('#style').val()
};
var defaultOpt = require('../extract-url');
var $listNav = $('#list-nav'),
... ...
... ... @@ -28,22 +28,7 @@ var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
//默认筛选条件
var defaultOpt = {
gender: $('#gender').val(),
brand: $('#brand').val(),
sort: $('#sort').val(),
msort: $('#msort').val(),
misort: $('#misort').val(),
color: $('#color').val(),
size: $('#size').val(),
price: $('#price').val(),
discount: $('#discount').val(),
limit: $('#limit').val(),
channel: $('#channel').val(),
p_d: $('#p_d').val(),
dayLimit: 1,
style: $('#style').val()
};
var defaultOpt = require('../extract-url');
var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置
... ...
... ... @@ -37,59 +37,6 @@
<div class="container hide clearfix"></div>
{{> filter}}
</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 dayLimit}}
<input id="dayLimit" type="hidden" value={{dayLimit}}>
{{/if}}
{{#if limit}}
<input id="limit" type="hidden" value={{limit}}>
{{/if}}
{{#if style}}
<input id="style" type="hidden" value={{style}}>
{{/if}}
{{> product/suspend-cart}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -48,59 +48,6 @@
{{> filter}}
</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 discount}}
<input id="discount" type="hidden" value={{discount}}>
{{/if}}
{{#if style}}
<input id="style" type="hidden" value={{style}}>
{{/if}}
{{> product/suspend-cart}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -89,50 +89,5 @@
{{> filter}}
</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 discount}}
<input id="discount" type="hidden" value={{discount}}>
{{/if}}
{{#if query}}
<input id="query" type="hidden" value={{query}}>
{{/if}}
{{#if style}}
<input id="style" type="hidden" value={{style}}>
{{/if}}
{{> product/suspend-cart}}
{{/ goodList}}
\ No newline at end of file
... ...