...
|
...
|
@@ -18,6 +18,7 @@ const crypto = global.yoho.crypto; |
|
|
const _ = require('lodash');
|
|
|
const md5 = require('md5');
|
|
|
const redis = global.yoho.redis;
|
|
|
const cache = global.yoho.cache;
|
|
|
|
|
|
// const limitNum = 60; // 商品每页显示数目
|
|
|
const needParams = ['query', 'msort', 'misort', 'category_id', 'gender', 'shelveTime'];
|
...
|
...
|
@@ -33,6 +34,20 @@ const positionId = 10; |
|
|
// 获取分类左侧广告id
|
|
|
const sortAdsId = 79;
|
|
|
|
|
|
const sortCache = {
|
|
|
key: 'global:yoho:category:name:',
|
|
|
get(categoryId) {
|
|
|
if (!categoryId) {
|
|
|
return Promise.resolve(false);
|
|
|
}
|
|
|
|
|
|
return cache.get(this.key + categoryId);
|
|
|
},
|
|
|
set(categoryId, sortName) {
|
|
|
return cache.set(this.key + categoryId, sortName);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取商品分类列表数据
|
|
|
*/
|
...
|
...
|
@@ -58,7 +73,8 @@ function getListData(params, channel) { |
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(channel, true),
|
|
|
this.searchApi.getSortList({}, channel),
|
|
|
this.searchApi.getProductList(searchParams, 'categoryList')
|
|
|
this.searchApi.getProductList(searchParams, 'categoryList'),
|
|
|
sortCache.get(searchParams.category_id)
|
|
|
];
|
|
|
|
|
|
// 搜索分类介绍和广告
|
...
|
...
|
@@ -125,13 +141,13 @@ function getListData(params, channel) { |
|
|
}
|
|
|
|
|
|
// 分类介绍
|
|
|
if (result[3] && result[3].code === 200) {
|
|
|
finalResult.list.sortIntro = searchHandler.handleSortIntro(result[3].data);
|
|
|
if (result[4] && result[4].code === 200) {
|
|
|
finalResult.list.sortIntro = searchHandler.handleSortIntro(result[4].data);
|
|
|
}
|
|
|
|
|
|
// 分类广告
|
|
|
if (result[4] && result[4].code === 200) {
|
|
|
Object.assign(finalResult.list.leftContent, searchHandler.handleSortAds(result[4].data));
|
|
|
if (result[5] && result[5].code === 200) {
|
|
|
Object.assign(finalResult.list.leftContent, searchHandler.handleSortAds(result[5].data));
|
|
|
}
|
|
|
|
|
|
let sortName;
|
...
|
...
|
@@ -150,7 +166,20 @@ function getListData(params, channel) { |
|
|
}
|
|
|
});
|
|
|
|
|
|
const seo = seoHandler.getListSeo(sortList, checkedList);
|
|
|
let extendParam = {};
|
|
|
|
|
|
if (searchParams.category_id) {
|
|
|
let cacheSortName = result[3];
|
|
|
|
|
|
if (!sortName && cacheSortName) {
|
|
|
sortName = cacheSortName;
|
|
|
extendParam.sort = cacheSortName;
|
|
|
} else if (sortName && sortName !== cacheSortName) {
|
|
|
sortCache.set(searchParams.category_id, sortName);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const seo = seoHandler.getListSeo(sortList, checkedList, extendParam);
|
|
|
|
|
|
if (sortName) {
|
|
|
return redis.all([
|
...
|
...
|
|