Authored by yyq

Merge branch 'release/newSearch' of git.yoho.cn:fe/yohobuy-node into release/newSearch

... ... @@ -47,11 +47,14 @@ const _getGender = (channel) => {
* 获取商品分类列表数据
*/
exports.getListData = (params, channel) => {
let searchParams = searchHandler.getSearchParams(params);
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(channel),
searchApi.getSortList(),
searchApi.getProductList(params)
searchApi.getSortList(params),
searchApi.getProductList(searchParams)
];
// 搜索分类介绍和广告
... ... @@ -93,6 +96,7 @@ exports.getListData = (params, channel) => {
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
latestWalk: 7
... ... @@ -124,11 +128,13 @@ exports.getListData = (params, channel) => {
*/
exports.getListNewData = (params, channel) => {
let searchParams = searchHandler.getSearchParams(params);
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(channel),
searchApi.getSortList(),
searchApi.getProductList(Object.assign({new: 'Y'}, params)),
searchApi.getSortList(searchParams),
searchApi.getProductList(Object.assign({new: 'Y'}, searchParams)),
searchApi.getWeekNew(params)
];
... ... @@ -159,6 +165,7 @@ exports.getListNewData = (params, channel) => {
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
latestWalk: 7
... ... @@ -211,14 +218,16 @@ exports.getBrandInfo = (params) => {
*/
exports.getBrandData = (params, extra, channel) => {
let searchParams = searchHandler.getSearchParams(params);
// 设置品牌默认排序方式
let order = params.order || 'b_w_desc';
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(channel),
searchApi.getSortList({brand: extra.brandId}),
searchApi.getProductList(Object.assign({order: order, brand: extra.brandId}, params))
searchApi.getSortList(Object.assign({}, params, {brand: extra.brandId})),
searchApi.getProductList(Object.assign({order: order, brand: extra.brandId}, searchParams))
];
... ... @@ -250,6 +259,7 @@ exports.getBrandData = (params, extra, channel) => {
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
latestWalk: 7
... ...
... ... @@ -923,7 +923,7 @@ exports.handlePathNavData = (data, params, page) => {
* @param {[type]} params 筛选条件
* @return {[type]} [description]
*/
exports.handlePagerData = (total, params) => {
exports.handlePagerData = (total, params, noNextBtn) => {
let dest = {
prePage: {
url: ''
... ... @@ -934,8 +934,8 @@ exports.handlePagerData = (total, params) => {
pages: []
};
let currentPage = parseInt((_.isEmpty(params.page) ? 1 : params.page), 10); // 当前页
let perPageCount = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10); // 每页商品数
let currentPage = parseInt(_.get(params, 'page', 1), 10); // 当前页
let perPageCount = parseInt(_.get(params, 'limit', true === noNextBtn ? 60 : 59), 10); // 每页商品数
let totalPage = parseInt(total / perPageCount, 10) + 1; // 总页数
if (currentPage === 1) {
... ... @@ -1332,8 +1332,10 @@ exports.getCriteo = (glist) => {
if (glist) {
_.forEach(glist, (val) => {
if (sknArr.length < 3 && val && val.product_skn) {
sknArr.push(val.product_skn);
if (sknArr.length < 3) {
if (val && val.product_skn) {
sknArr.push(val.product_skn);
}
} else {
return false;
}
... ... @@ -1342,3 +1344,41 @@ exports.getCriteo = (glist) => {
return sknArr;
};
// handlePagerData
exports.getSearchParams = params => {
let mlimit = 59;
if (params && params.limit) {
let olimit = parseInt(params.limit, 10);
switch (olimit) {
case 100:
mlimit = 99;
break;
case 200:
mlimit = 199;
break;
default:
mlimit = 59;
}
}
/** 处理页面数据 **/
let nparams = {
limit: mlimit
};
if (params && params.price) {
let mp = params.price.split(',');
let nmp = [];
nmp[0] = (mp && mp[0]) || 0;
nmp[1] = (mp && mp[1]) || 99999;
nparams.price = nmp.join(',');
}
return Object.assign({}, params, nparams);
};
... ...
... ... @@ -18,25 +18,14 @@ const _ = require('lodash');
* @return {[type]} [description]
*/
exports.getSearchData = (params, channel) => {
let mlimit = params && params.limit && params.limit > 0 ? params.limit - 1 : 59;
/** 处理页面数据 **/
let nparams = {};
if (params && params.price) {
let mp = params.price.split(',');
let nmp = [];
nmp[0] = (mp && mp[0]) || 0;
nmp[1] = (mp && mp[1]) || 99999;
nparams.price = nmp.join(',');
}
let searchParams = searchHandler.getSearchParams(params);
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(channel),
searchApi.getSortList(Object.assign({}, params, nparams, {msort: '', misort: ''})),
searchApi.getProductList(Object.assign({}, params, {limit: mlimit}, nparams)),
searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: ''})),
searchApi.getProductList(searchParams),
searchApi.getShopList(params)
];
... ...