...
|
...
|
@@ -4,7 +4,8 @@ |
|
|
* @date: 2015/12/4
|
|
|
*/
|
|
|
|
|
|
var $ = require('yoho.jquery');
|
|
|
var $ = require('yoho.jquery'),
|
|
|
Handlebars = require('yoho.handlebars');
|
|
|
|
|
|
var checkUnicode = {
|
|
|
unchecked: '',
|
...
|
...
|
@@ -38,6 +39,13 @@ var $seniorSubWrap = $('.senior-sub-wrap'), |
|
|
|
|
|
var seniorHoverTime, hoveredIndex;
|
|
|
|
|
|
// 尺寸 handlebars 模板
|
|
|
var sizeTmpl = '{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>{{/ size}}',
|
|
|
sizeCache = {}, // 缓存一下尺寸信息
|
|
|
$sizeWrap = $('.filter-box .size');
|
|
|
|
|
|
sizeTmpl = Handlebars.compile(sizeTmpl);
|
|
|
|
|
|
//清除checkbox选中状态
|
|
|
function clearChecked($checkbox) {
|
|
|
$checkbox.removeClass('checked').html(checkUnicode.unchecked);
|
...
|
...
|
@@ -85,13 +93,36 @@ $('.filter-box').on('selectstart', '.attr, .brands-index span', function() { |
|
|
//【分类】
|
|
|
$('.sort-pre').on('click', 'li', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.index();
|
|
|
index = $this.index(),
|
|
|
id = $this.data('id');
|
|
|
|
|
|
$this.siblings('.active').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
|
|
|
$sortSub.children(':not(.hide)').addClass('hide');
|
|
|
$sortSub.children(':eq(' + index + ')').removeClass('hide');
|
|
|
|
|
|
if (sizeCache[id]) {
|
|
|
$sizeWrap.find('.attr-content').html(sizeCache[id]);
|
|
|
$sizeWrap.removeClass('hide');
|
|
|
} else {
|
|
|
$.ajax({
|
|
|
url: '/product/search/sortSize',
|
|
|
data: {
|
|
|
msort: id
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
if ($.type(res) === 'array' && res.length) {
|
|
|
sizeCache[id] = sizeTmpl({
|
|
|
size: res
|
|
|
});
|
|
|
$sizeWrap.find('.attr-content').html(sizeCache[id]);
|
|
|
$sizeWrap.removeClass('hide');
|
|
|
} else {
|
|
|
$sizeWrap.addClass('hide');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌】
|
...
|
...
|
|