...
|
...
|
@@ -17,9 +17,133 @@ const searchHandler = require('./search-handler'); |
|
|
const pager = require(`${global.utils}/pager`).setPager;
|
|
|
const productProcess = require(`${global.utils}/product-process`);
|
|
|
|
|
|
const GLOBAL_LIST_URI = '/product/global/list';
|
|
|
|
|
|
const _handelGlobalPathNav = (data, channel, page) => {
|
|
|
let rootName = '首页';
|
|
|
|
|
|
if (channel && _.isString(channel)) {
|
|
|
rootName = `${channel.toUpperCase()}首页`;
|
|
|
}
|
|
|
|
|
|
let pathNav = [{
|
|
|
href: channel === 'boys' ? '/' : helpers.urlFormat(`/${channel}/`),
|
|
|
name: rootName,
|
|
|
pathTitle: rootName
|
|
|
}, {
|
|
|
href: helpers.urlFormat(GLOBAL_LIST_URI),
|
|
|
name: '全球购',
|
|
|
pathTitle: '全球购'
|
|
|
}];
|
|
|
|
|
|
if (data.sort) {
|
|
|
pathNav.push({
|
|
|
href: helpers.urlFormat(GLOBAL_LIST_URI, data.sort.params),
|
|
|
name: data.sort.name,
|
|
|
pathTitle: data.sort.name
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (data.brand) {
|
|
|
pathNav.push({
|
|
|
name: data.brand.name,
|
|
|
pathTitle: data.brand.name
|
|
|
});
|
|
|
page = 'global-brand';
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
pathNav: pathNav,
|
|
|
listType: page
|
|
|
};
|
|
|
};
|
|
|
|
|
|
const _checkSortEqual = (rp, params) => {
|
|
|
let status = true;
|
|
|
|
|
|
_.forEach(rp, (value, key) => {
|
|
|
if (status && params[key] !== value) {
|
|
|
status = false;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return status;
|
|
|
};
|
|
|
|
|
|
const _handelGlobalSort = (origin, params, originParams) => {
|
|
|
let all = [{
|
|
|
name: '全部品类',
|
|
|
href: `${searchHandler.handleFilterUrl(params, {}, {msort: true, misort: true, sort: true})}`
|
|
|
}];
|
|
|
let list = [];
|
|
|
let selectSort = {};
|
|
|
|
|
|
_.forEach(origin, value => {
|
|
|
let equalCategory = _checkSortEqual(value.relation_parameter, originParams);
|
|
|
let category = {
|
|
|
name: value.category_name,
|
|
|
num: value.node_count,
|
|
|
childList: [
|
|
|
{
|
|
|
name: `全部${value.category_name}`,
|
|
|
num: value.node_count,
|
|
|
href: `${searchHandler.handleFilterUrl(params, value.relation_parameter)}`,
|
|
|
childActive: _checkSortEqual(value.relation_parameter, originParams)
|
|
|
}
|
|
|
]
|
|
|
};
|
|
|
|
|
|
if (equalCategory) {
|
|
|
Object.assign(selectSort, {
|
|
|
name: value.category_name,
|
|
|
params: value.relation_parameter
|
|
|
});
|
|
|
}
|
|
|
|
|
|
_.forEach(value.sub, subValue => {
|
|
|
let child = {
|
|
|
name: subValue.category_name,
|
|
|
num: subValue.node_count,
|
|
|
href: `${searchHandler.handleFilterUrl(params, subValue.relation_parameter)}`,
|
|
|
childActive: _checkSortEqual(subValue.relation_parameter, originParams)
|
|
|
};
|
|
|
|
|
|
category.childList.push(child);
|
|
|
|
|
|
if (child.childActive) {
|
|
|
category.active = true;
|
|
|
Object.assign(selectSort, {
|
|
|
name: subValue.category_name,
|
|
|
params: subValue.relation_parameter
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
list.push(category);
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
allSort: {
|
|
|
all: all,
|
|
|
list: list
|
|
|
},
|
|
|
selectSort: selectSort
|
|
|
};
|
|
|
};
|
|
|
|
|
|
const getGlobalProductListData = (params, yoho) => {
|
|
|
let dps = {};
|
|
|
|
|
|
if (params.brand) {
|
|
|
dps.brand = params.brand;
|
|
|
}
|
|
|
|
|
|
return Promise.props({
|
|
|
header: headerModel.requestHeaderData(yoho.channel),
|
|
|
fullList: globalApi.getGlobalProductListAsync({
|
|
|
physical_channel: yoho.channelNum,
|
|
|
limit: 1
|
|
|
}),
|
|
|
list: globalApi.getGlobalProductListAsync(Object.assign({
|
|
|
physical_channel: yoho.channelNum
|
|
|
}, params, {limit: params.limit ? params.limit - 1 : 59}))
|
...
|
...
|
@@ -29,23 +153,49 @@ const getGlobalProductListData = (params, yoho) => { |
|
|
Object.assign(resData, result.header);
|
|
|
|
|
|
if (result.list.code === 200) {
|
|
|
let totalNum = _.get(result.list, 'data.total', 0);
|
|
|
let listData = _.get(result.list, 'data', {});
|
|
|
let totalNum = _.get(listData, 'total', 0);
|
|
|
|
|
|
// let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, params),
|
|
|
// finalResult.list.leftContent.sort);
|
|
|
// opts 显示新品、折扣
|
|
|
listData.filter = listData.filter || {};
|
|
|
Object.assign(listData.filter, {
|
|
|
new: 'Y',
|
|
|
specialoffer: 'Y'
|
|
|
});
|
|
|
|
|
|
// filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
|
|
|
// finalResult.list.leftContent.checked);
|
|
|
resData.list = {
|
|
|
// filters: filters,
|
|
|
// opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
|
|
|
leftContent: _handelGlobalSort(_.get(result.fullList, 'data.filter.group_sort', []), dps, params),
|
|
|
filters: searchHandler.handleFilterDataAll(listData, params),
|
|
|
opts: searchHandler.handleOptsData(params, totalNum, listData.filter),
|
|
|
totalCount: totalNum,
|
|
|
footPager: pager(_.get(result.list, 'data.page_total', 0), params),
|
|
|
goods: productProcess.processProductList(_.get(result.list, 'data.product_list', []),
|
|
|
footPager: pager(_.get(listData, 'page_total', 0), params),
|
|
|
goods: productProcess.processProductList(_.get(listData, 'product_list', []),
|
|
|
Object.assign({showDiscount: false, isGlobal: true}, params)),
|
|
|
hasNextPage: searchHandler.handleNextPage(params, totalNum),
|
|
|
latestWalk: 6 // 最近浏览记录
|
|
|
};
|
|
|
|
|
|
let pathInfo = {};
|
|
|
|
|
|
if (dps.brand) {
|
|
|
let bandInfo = _.find(_.get(result.fullList, 'data.filter.brand', []), o => {
|
|
|
return o.id * 1 === dps.brand * 1;
|
|
|
});
|
|
|
|
|
|
if (bandInfo) {
|
|
|
pathInfo.brand = {
|
|
|
name: bandInfo.brand_name
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let selectedSort = _.get(resData.list, 'leftContent.selectSort', {});
|
|
|
|
|
|
if (!_.isEmpty(selectedSort)) {
|
|
|
pathInfo.sort = selectedSort;
|
|
|
}
|
|
|
|
|
|
Object.assign(resData.list, _handelGlobalPathNav(pathInfo, yoho.channel, 'global-list'));
|
|
|
}
|
|
|
|
|
|
return resData;
|
...
|
...
|
@@ -68,7 +218,7 @@ const getGlobalProductDetailData = (skn, channelNum, channel) => { |
|
|
|
|
|
resData.banner = {
|
|
|
bgColor: '#000',
|
|
|
homeUrl: helpers.urlFormat('/product/global/list', {brand: brandInfo.brand_id}),
|
|
|
homeUrl: helpers.urlFormat(GLOBAL_LIST_URI, {brand: brandInfo.brand_id}),
|
|
|
brandName: brandInfo.brand_name,
|
|
|
logo: brandInfo.brand_ico
|
|
|
};
|
...
|
...
|
@@ -76,7 +226,7 @@ const getGlobalProductDetailData = (skn, channelNum, channel) => { |
|
|
resData.pathNav = _.concat(
|
|
|
homeService.getHomeChannelNav(channel),
|
|
|
[
|
|
|
{name: '全球购', href: helpers.urlFormat('/product/global/list')},
|
|
|
{name: '全球购', href: helpers.urlFormat(GLOBAL_LIST_URI)},
|
|
|
{name: detailInfo.product_name || ''}
|
|
|
]
|
|
|
);
|
...
|
...
|
@@ -137,7 +287,7 @@ const getGlobalProductDetailData = (skn, channelNum, channel) => { |
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result.html) {
|
|
|
if (result.html && !_.get(result.html, 'code', '')) {
|
|
|
let regContent = /<body[^>]*>([\s\S]*)<\/body>/.exec(result.html);
|
|
|
|
|
|
html = regContent[1] || '';
|
...
|
...
|
|