Authored by yyq

高级选项

... ... @@ -85,15 +85,15 @@ exports.brand = (req, res, next) => {
if (req.shopId) {
return shop(req.shopId, req, res, next);
}
let brandDomain = 'colormad';
// let brandDomain = 'colormad';
// let brandDomain = req.brandDomain || 'shop$15';
let brandDomain = req.brandDomain || 'shop$15';
// 获取品牌信息
list.getBrandInfo({domain: brandDomain}).then(brandInfo => {
// brandInfo.type = 2;
// brandInfo.shopId = 15;
brandInfo.type = 2;
brandInfo.shopId = 15;
switch (parseInt(brandInfo.type, 10)) {
case 1:
// 搜索
... ...
... ... @@ -75,6 +75,13 @@ exports.getListData = (params) => {
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params))
});
// 获取高级筛选条件
if (finalResult.list && finalResult.list.filters) {
Object.assign(finalResult.list.filters, searchHandler.handleSeniorFilterData({
style: _.get(result[2], 'data.filter.style', []),
standard: _.get(result[2], 'data.standard', [])
}, params));
}
}
// 分类介绍
... ... @@ -131,6 +138,14 @@ exports.getListNewData = (params) => {
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params))
});
// 获取高级筛选条件
if (finalResult.list && finalResult.list.filters) {
Object.assign(finalResult.list.filters, searchHandler.handleSeniorFilterData({
style: _.get(result[2], 'data.filter.style', []),
standard: _.get(result[2], 'data.standard', [])
}, params));
}
}
// 新品上架
... ... @@ -216,6 +231,14 @@ exports.getBrandData = (params, extra) => {
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params))
});
// 获取高级筛选条件
if (finalResult.list && finalResult.list.filters) {
Object.assign(finalResult.list.filters, searchHandler.handleSeniorFilterData({
style: _.get(result[2], 'data.filter.style', []),
standard: _.get(result[2], 'data.standard', [])
}, params));
}
}
// 品牌页不显示品牌筛选项
... ... @@ -456,6 +479,14 @@ exports.getShopListData = (params) => {
goods: productProcess.processProductList(_.get(result[2], 'data.product_list', [])),
footPager: {tip: tip}
});
// 获取高级筛选条件
if (finalResult.list && finalResult.list.filters) {
Object.assign(finalResult.list.filters, searchHandler.handleSeniorFilterData({
style: _.get(result[2], 'data.filter.style', []),
standard: _.get(result[2], 'data.standard', [])
}, params));
}
}
if (result[3].code === 200) {
... ...
... ... @@ -30,7 +30,8 @@ const relateArticleUrl = 'guang/service/v2/article/getArticleByBrand';
*/
const getProductList = (params) => {
let finalParams = {
method: 'app.search.li',
method: 'web.search.search',
// method: 'app.search.li',
order: 's_n_desc',
limit: 60
};
... ... @@ -45,9 +46,7 @@ const getProductList = (params) => {
*/
const getSortList = (params) => {
let finalParams = {
method: 'app.search.li',
// method: 'web.regular.groupsort',
method: 'web.regular.groupsort',
sales: 'Y', // 在销售商品分类
status: 1, // 上架商品分类
stocknumber: 1 // 过滤掉已售罄
... ...
... ... @@ -23,20 +23,25 @@ const checksName = {
* @param newParam 要拼接的 参数
* @returns {string}
*/
const handleFilterUrl = (originParam, newParam) => {
let dest = '?';
const handleFilterUrl = (originParam, newParam, delParam) => {
let dest = '';
let tempOriginParam = {};
delParam = delParam || {};
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
delete tempOriginParam.uid;
_.forEach(tempOriginParam, function(value, key) {
dest = dest + key + '=' + value + '&';
if (!delParam[key]) {
dest += `${key}=${value}&`;
}
});
return _.trim(dest, '&');
};
dest = dest ? _.trim(`?${dest}`, '&') : '';
return dest;
};
/**
* 处理选中数据
... ... @@ -626,6 +631,71 @@ exports.handleFilterData = (origin, params) => {
};
/**
* 处理高级选项数据
* @param origin 要处理的筛选数据 filter
* @param params 当前 URL 中已有的参数,处理选中状态使用
* @returns {{}}
*/
exports.handleSeniorFilterData = (data, params) => {
let resData = {
checkedConditions: {
conditions: []
}
};
if (data) {
let chose = [];
if (!_.isEmpty(data.style)) {
let sub = [];
_.forEach(data.style, value => {
sub.push({
id: value.style_id,
checked: parseInt(params.style, 10) === parseInt(value.style_id, 10),
href: handleFilterUrl(params, {style: value.style_id}),
name: value.style_name
});
});
chose.push({
name: '风格',
showMulti: true,
sub: sub,
attr: 'style'
});
}
if (!_.isEmpty(data.standard)) {
_.forEach(data.standard, value => {
let sub = [];
_.forEach(value.sub, subValue => {
sub.push({
id: value.standard_id,
checked: parseInt(params.standard_val, 10) === parseInt(subValue.standard_id, 10),
href: handleFilterUrl(params, {
standard_id: value.standard_id,
standard_val: subValue.standard_id
}),
name: subValue.standard_name
});
})
chose.push({
name: value.standard_name,
sub: sub
});
})
}
if (!_.isEmpty(chose)) {
resData.seniorChose = chose;
}
}
return resData;
}
/**
* 根据页面设置面包屑导航
* @type {[type]}
*/
... ...
... ... @@ -98,6 +98,7 @@
"yoho-handlebars": "^4.0.5",
"yoho-jquery": "^1.12.4",
"yoho-jquery-lazyload": "^1.9.7",
"yoho-jquery-pjax": "0.0.1",
"yoho-jquery-placeholder": "0.0.3",
"yoho-slider": "0.0.2"
}
... ...
... ... @@ -12,28 +12,28 @@ var product = require('./index/product');
var $shopIntro = $('.shop-intro'),
$shopCollect = $('.shop-collect'),
// $sliderLeft = $('.slider-left'),
$sliderLeft = $('.slider-left'),
$allGoods = $('.all-goods'),
$fixedArea = $allGoods.find('.fixed-area'),
fixedAreaTop = $fixedArea.offset() ? $fixedArea.offset().top : 0;
// Pjax
// require('yoho-pjax');
require('yoho-jquery-pjax');
require('../common');
require('../plugins/filter');
require('../plugins/sort-pager');
// require('../common/slider');
require('../plugins/slider');
// require('../product/list');
product.init(4);
lazyLoad($('img.lazy'));
// if ($sliderLeft.length) {
// $sliderLeft.slider();
// }
if ($sliderLeft.length) {
$sliderLeft.slider();
}
$shopIntro.on('click', function() {
$('.pop-shop-intro').show();
... ... @@ -101,25 +101,25 @@ if (window.cookie('needColloect') * 1 === 1 && window.getUid()) {
}
// 全部商品使用 pjax 翻页
// $allGoods.pjax('a.pjax', '.goods-wrap', {
// timeout: 5000,
// scrollTo: false // 默认滚动没有动画,禁止掉
// }).on('pjax:end', function() {
// product.init(4);
// lazyLoad($('img.lazy'));
// $fixedArea = $allGoods.find('.fixed-area'); // 翻页后 fixed-area 区域有变化,需要更新选择器
// // 分页后移动到全部商品
// $('html, body').animate({
// scrollTop: $allGoods.offset().top - 30
// });
// }).on('click', '.menu-list li', function() {
// var $this = $(this);
// $this.siblings().removeClass('on');
// $this.addClass('on');
// });
$allGoods.pjax('a.pjax', '.goods-wrap', {
timeout: 5000,
scrollTo: false // 默认滚动没有动画,禁止掉
}).on('pjax:end', function() {
product.init(4);
lazyLoad($('img.lazy'));
$fixedArea = $allGoods.find('.fixed-area'); // 翻页后 fixed-area 区域有变化,需要更新选择器
// 分页后移动到全部商品
$('html, body').animate({
scrollTop: $allGoods.offset().top - 30
});
}).on('click', '.menu-list li', function() {
var $this = $(this);
$this.siblings().removeClass('on');
$this.addClass('on');
});
$(window).on('scroll', function() {
var scrollTop = $(this).scrollTop();
... ...