...
|
...
|
@@ -57,6 +57,8 @@ var sizeTmpl = '{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{ |
|
|
sizeCache = {}, // 缓存一下尺寸信息
|
|
|
$sizeWrap = $('.filter-box .size');
|
|
|
|
|
|
var staticPage = $('.yoho-page.static-list-page').length; // 是否是伪静态页面
|
|
|
|
|
|
if ($hideInfo && $hideInfo.length) {
|
|
|
hideInfo = $hideInfo.data();
|
|
|
$hideInfo.remove();
|
...
|
...
|
@@ -91,16 +93,35 @@ function brandHideMore() { |
|
|
}
|
|
|
|
|
|
// url构造&跳转
|
|
|
function uriLoc(attr, val) {
|
|
|
function uriLoc(attr, val, uri) {
|
|
|
var qs = window.queryString(),
|
|
|
newHref;
|
|
|
|
|
|
qs[attr] = val;
|
|
|
delete qs.page;
|
|
|
newHref = '?' + decodeURIComponent($.param(qs));
|
|
|
if (staticPage && uri) {
|
|
|
newHref = uri.replace('{seat}', val);
|
|
|
} else {
|
|
|
qs[attr] = val;
|
|
|
delete qs.page;
|
|
|
newHref = '?' + decodeURIComponent($.param(qs));
|
|
|
}
|
|
|
|
|
|
window.location.href = newHref;
|
|
|
}
|
|
|
|
|
|
function replceStaticUrl(list, uri) {
|
|
|
var i;
|
|
|
|
|
|
list = list || [];
|
|
|
|
|
|
if (staticPage && uri) {
|
|
|
for (i = 0; i < list.length; i++) {
|
|
|
list[i].href = uri.replace('{seat}', list[i].id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
// 隐藏高级选项面板
|
|
|
function hideSeniorPanel() {
|
|
|
$seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide');
|
...
|
...
|
@@ -185,6 +206,10 @@ function checkMoreBrands(callback) { |
|
|
$brandsIndex = $('.brands-index');
|
|
|
}
|
|
|
|
|
|
if (staticPage) { // 伪静态化页面参数特殊处理
|
|
|
params = {pathname: window.location.pathname};
|
|
|
}
|
|
|
|
|
|
if (params.query && $changeKey.length) {
|
|
|
params.query = $changeKey.text();
|
|
|
}
|
...
|
...
|
@@ -199,24 +224,32 @@ function checkMoreBrands(callback) { |
|
|
|
|
|
moreBrandLoaded = 'loading';
|
|
|
$.getJSON(url, params, function(jsonData) {
|
|
|
var resData, seatUrl;
|
|
|
|
|
|
if (jsonData.code === 200) {
|
|
|
if (jsonData.code !== 200) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (jsonData.data) {
|
|
|
brandsHtml = Handlebars.compile($('#yo-brands-tpl').html() || '');
|
|
|
$filterBrands.find('.attr-content [data-role=all-brand]').html(brandsHtml(jsonData.data));
|
|
|
}
|
|
|
resData = jsonData.data;
|
|
|
|
|
|
moreBrandLoaded = true;
|
|
|
if (resData) {
|
|
|
seatUrl = $filterBrands.data('url');
|
|
|
|
|
|
// init brand vars
|
|
|
$brandInput = $filterBrands.find('#brand-search-input');
|
|
|
$brandPanel = $filterBrands.find('.brand-panel');
|
|
|
$brandAttrs = $brandPanel.find('.attr');
|
|
|
$brandsIndex = $('.brands-index');
|
|
|
replceStaticUrl(resData.brandsShow, seatUrl);
|
|
|
|
|
|
return callback && callback();
|
|
|
brandsHtml = Handlebars.compile($('#yo-brands-tpl').html() || '');
|
|
|
$filterBrands.find('.attr-content [data-role=all-brand]').html(brandsHtml(resData));
|
|
|
}
|
|
|
|
|
|
moreBrandLoaded = true;
|
|
|
|
|
|
// init brand vars
|
|
|
$brandInput = $filterBrands.find('#brand-search-input');
|
|
|
$brandPanel = $filterBrands.find('.brand-panel');
|
|
|
$brandAttrs = $brandPanel.find('.attr');
|
|
|
$brandsIndex = $('.brands-index');
|
|
|
|
|
|
return callback && callback();
|
|
|
});
|
|
|
} else {
|
|
|
return callback && callback();
|
...
|
...
|
@@ -312,7 +345,7 @@ $filterBrands.on('click', '#brand-multi-ok', function() { |
|
|
val.push($(this).data('id'));
|
|
|
});
|
|
|
|
|
|
uriLoc('brand', val.join(','));
|
|
|
uriLoc('brand', val.join(','), $filterBrands.data('url'));
|
|
|
});
|
|
|
|
|
|
// 【品牌/高级选项】多选取消
|
...
|
...
|
@@ -417,7 +450,7 @@ if ($udPrice.length > 0) { |
|
|
min = tmp;
|
|
|
}
|
|
|
|
|
|
uriLoc('price', min + ',' + max);
|
|
|
uriLoc('price', min + ',' + max, $(this).data('url'));
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -499,7 +532,7 @@ $('.senior-sub').on('click', '.multi-select', function() { |
|
|
val.push($(this).data('id'));
|
|
|
});
|
|
|
|
|
|
uriLoc($sub.data('attr'), val.join(','));
|
|
|
uriLoc($sub.data('attr'), val.join(','), $sub.data('url'));
|
|
|
}).on('click', '.multi-select-cancel', function() {
|
|
|
var $panel = $(this).closest('.multi');
|
|
|
|
...
|
...
|
|