Authored by 王水玲

outlet bug 修改

... ... @@ -29,10 +29,10 @@ const typeCont = {
sale: ['s_n_desc', 's_n_asc'],
// newest: ['s_t_desc,s_s_desc', 's_t_asc,s_s_asc'],
newest: ['s_t_desc', 's_t_asc'],
stock: ['s_s_desc', 's_s_asc'],
all: ['d_s_desc', 'd_s_asc']
all: ['d_s_desc', 'd_s_asc'],
category: ['s_t_desc', 's_t_asc']
};
const channelType = {
... ...
... ... @@ -9,11 +9,31 @@ var $categoryNavItem = $('.outlet-category-nav a');
var search = require('./sale/search');
var iscroll = require('./outlet/nav');
require('./sale/search');
lazyLoad($('img.lazy'));
// 搜索条件初始化
function searchInitParam(dom) {
var href = dom.attr('href'),
querys = href.split('?')[1].split('&');
var query = {};
querys.forEach(function(value) {
var queryPairs = value.split('='),
key = queryPairs[0],
val = queryPairs[1];
if (key === 'actiontype') {
return;
}
query[key] = val;
});
return query;
}
if ($el.length > 0) {
$el.each(function() {
new Countdown.Countdown({
... ... @@ -34,26 +54,14 @@ if ($('.swiper-container .swiper-slide').length > 1) {
});
}
$categoryNavItem.on('click', function(e) {
var href = $(this).attr('href'),
querys = href.split('?')[1].split('&');
var query = {};
var query = searchInitParam($(this));
$('.category a').removeClass('active');
$(this).addClass('active');
e.preventDefault();
querys.forEach(function(value) {
var queryPairs = value.split('='),
key = queryPairs[0],
val = queryPairs[1];
query[key] = val;
});
search.start({
type: 'category'
}, query);
... ... @@ -61,7 +69,11 @@ $categoryNavItem.on('click', function(e) {
// 触发第一个search
if ($categoryNavItem.length > 0) {
$categoryNavItem.eq(0).trigger('click');
// $categoryNavItem.eq(0).trigger('click');
search.start({
type: 'category'
}, searchInitParam($categoryNavItem.eq(0)));
}
// 导航滚动
... ... @@ -77,7 +89,7 @@ if ($('.outlet-category-nav').length > 0) {
}).goto(0);
}
//更多活动按钮
// 更多活动按钮
if ($('.back-ground-white').length > 10) {
$('.more-activity').show();
$('.back-ground-white').each(function(index, e) {
... ...
... ... @@ -323,26 +323,33 @@ function search(opt, params) {
}
$.ajax({
type: 'GET',
url: '/product/sale/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');
},
missStatus: true
});
}
});
function filterInit() {
$.ajax({
type: 'GET',
url: '/product/sale/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');
},
missStatus: true
});
}
});
}
if ($('.outlet-index-page').length === 0) {
filterInit();
}
lazyLoad($('.lazy'));
// 导航栏点击逻辑说明:
... ... @@ -479,7 +486,9 @@ function scrollHandler() {
// srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
if ($('.outlet-index-page').length === 0) {
window.requestAnimationFrame(scrollHandler);
}
});
... ...