...
|
...
|
@@ -5,6 +5,7 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('jquery'),
|
|
|
Hammer = require('hammer'),
|
|
|
lazyLoad = require('yoho.lazyload');
|
|
|
|
|
|
//品牌页参数
|
...
|
...
|
@@ -61,7 +62,11 @@ var $listNav = $('#list-nav'), |
|
|
}
|
|
|
},
|
|
|
$pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
|
|
|
searching;
|
|
|
searching,
|
|
|
navHammer,
|
|
|
btnIntroHammer,
|
|
|
introHammer,
|
|
|
brandColHammer;
|
|
|
|
|
|
/**
|
|
|
* 筛选注册的回调,筛选子项点击后逻辑
|
...
|
...
|
@@ -208,9 +213,27 @@ function search(opt) { |
|
|
|
|
|
}
|
|
|
|
|
|
lazyLoad($('.lazy'));
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/search/filter',
|
|
|
data: defaultOpt,
|
|
|
success: function(data) {
|
|
|
$goodsContainer.append(data);
|
|
|
|
|
|
//初始化filter&注册filter回调
|
|
|
filter.initFilter({
|
|
|
fCbFn: search,
|
|
|
hCbFn: function() {
|
|
|
|
|
|
//切换active状态到$pre上
|
|
|
$pre.addClass('active');
|
|
|
$pre.siblings('.filter').removeClass('active');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
filter.registerCbFn(search);
|
|
|
lazyLoad($('.lazy'));
|
|
|
|
|
|
writeSearch.bindWirteLocal($('#search-form'));
|
|
|
|
...
|
...
|
@@ -220,8 +243,9 @@ writeSearch.bindWirteLocal($('#search-form')); |
|
|
//3.筛选无active时点击展开筛选面板
|
|
|
//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
|
|
|
//5.当前active为筛选并且点击其他项时,隐藏筛选面板
|
|
|
$listNav.delegate('li', 'click', function() {
|
|
|
var $this = $(this),
|
|
|
navHammer = new Hammer($listNav[0]);
|
|
|
navHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target).closest('li'),
|
|
|
nav,
|
|
|
navType,
|
|
|
$active;
|
...
|
...
|
@@ -318,51 +342,65 @@ $(window).scroll(function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
//品牌介绍
|
|
|
$brandHeader.children('.btn-intro').bind('click', function() {
|
|
|
$introBox.removeClass('hide');
|
|
|
});
|
|
|
if ($brandHeader.length > 0) {
|
|
|
|
|
|
$('.close-intro, .brand-intro-box').click(function() {
|
|
|
$introBox.addClass('hide');
|
|
|
});
|
|
|
//品牌介绍
|
|
|
btnIntroHammer = new Hammer($brandHeader.children('.btn-intro')[0]);
|
|
|
btnIntroHammer.on('tap', function() {
|
|
|
$introBox.removeClass('hide');
|
|
|
|
|
|
$('#brand-intro').click(function(e) {
|
|
|
e.stopPropagation();
|
|
|
});
|
|
|
//防止混合scroll发生
|
|
|
$('body').addClass('overflow-hidden');
|
|
|
});
|
|
|
|
|
|
//品牌收藏
|
|
|
$brandHeader.children('.btn-col').bind('click', function() {
|
|
|
var $this = $(this);
|
|
|
//关闭品牌介绍
|
|
|
introHammer = new Hammer(document.getElementById('intro-box'));
|
|
|
introHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target);
|
|
|
|
|
|
var id = $brandHeader.data('id'),
|
|
|
opt;
|
|
|
e.srcEvent.preventDefault();
|
|
|
|
|
|
if ($this.hasClass('coled')) {
|
|
|
opt = 'cancel';
|
|
|
} else {
|
|
|
opt = 'ok';
|
|
|
}
|
|
|
//关闭品牌介绍box
|
|
|
if ($this.closest('#brand-intro').length === 0 || $this.hasClass('close-intro')) {
|
|
|
$introBox.addClass('hide');
|
|
|
$('body').removeClass('overflow-hidden');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: id,
|
|
|
opt: opt
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
$this.toggleClass('coled');
|
|
|
} else if (data.code === 400) {
|
|
|
tip.show('未登录');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
//品牌收藏
|
|
|
brandColHammer = new Hammer($brandHeader.children('.btn-col')[0]);
|
|
|
brandColHammer.on('tap', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
var id = $brandHeader.data('id'),
|
|
|
opt;
|
|
|
|
|
|
if ($this.hasClass('coled')) {
|
|
|
opt = 'cancel';
|
|
|
} else {
|
|
|
opt = 'ok';
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: id,
|
|
|
opt: opt
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
$this.toggleClass('coled');
|
|
|
} else {
|
|
|
tip.show(data.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//初始请求最新第一页数据
|
|
|
search(); |
|
|
\ No newline at end of file |
...
|
...
|
|