...
|
...
|
@@ -10,6 +10,7 @@ const searchApi = require('./search-api'); |
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
const searchHandler = require('./search-handler');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
// 搜索分类信息需要的参数
|
|
|
const positionId = 10;
|
...
|
...
|
@@ -87,6 +88,7 @@ exports.getListData = (params) => { |
|
|
* 获取新品到着数据
|
|
|
*/
|
|
|
exports.getListNewData = (params) => {
|
|
|
|
|
|
// 调用接口
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(),
|
...
|
...
|
@@ -133,3 +135,108 @@ exports.getListNewData = (params) => { |
|
|
return finalResult;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 根据品牌域名查询品牌信息
|
|
|
*/
|
|
|
exports.getBrandInfo = (params) => {
|
|
|
return searchApi.getBrandData(params).then(result => {
|
|
|
|
|
|
if (result.code !== 200 || !result.data) {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
brandId: result.data.id,
|
|
|
brandNameEn: result.data.brand_name_en || '',
|
|
|
brandNameCn: result.data.brand_name_cn || '',
|
|
|
brandBanner: result.data.brand_banner || '',
|
|
|
node: result.data.static_content_code || '',
|
|
|
brandAbout: result.data.brand_intro || '',
|
|
|
shopTemplateType: result.data.shop_template_type || 0,
|
|
|
url: helpers.urlFormat('', '', result.data.brand_domain),
|
|
|
name: result.data.brand_name,
|
|
|
shopId: result.data.shop_id || 0,
|
|
|
type: result.data.type || 0,
|
|
|
brandDomain: result.data.brand_domain
|
|
|
};
|
|
|
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品牌页面数据
|
|
|
*/
|
|
|
exports.getBrandData = (params, extra) => {
|
|
|
|
|
|
// 设置品牌默认排序方式
|
|
|
let order = params.order || 'b_w_desc';
|
|
|
|
|
|
// 调用接口
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(),
|
|
|
searchApi.getSortList({brand: extra.brandId}),
|
|
|
searchApi.getProductList(Object.assign({order: order, brand: extra.brandId}, params))
|
|
|
|
|
|
];
|
|
|
|
|
|
return api.all(apiMethod).then(result => {
|
|
|
let finalResult = {
|
|
|
headerData: Object.assign(result[0].headerData, {
|
|
|
header: true
|
|
|
}),
|
|
|
brand: {
|
|
|
brandBanner: searchHandler.handleBrandBanner(extra),
|
|
|
leftContent: {},
|
|
|
node: extra.node || ''
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 获取左侧类目数据
|
|
|
if (result[1].code === 200) {
|
|
|
Object.assign(finalResult.brand, {
|
|
|
leftContent: searchHandler.handleSortData(result[1].data.sort, params),
|
|
|
pathNav: searchHandler.handlePathNavData(extra, params, 'brand')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[2].code === 200) {
|
|
|
Object.assign(finalResult.brand, {
|
|
|
filters: searchHandler.handleFilterData(result[2].data.filter, params),
|
|
|
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
|
|
|
totalCount: result[2].data.total,
|
|
|
footPager: searchHandler.handlePagerData(result[2].data.total, params),
|
|
|
goods: productProcess.processProductList(result[2].data.product_list,
|
|
|
Object.assign({showDiscount: false}, params))
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 品牌页不显示品牌筛选项
|
|
|
delete finalResult.brand.filters.brand;
|
|
|
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品牌页面水牌
|
|
|
*/
|
|
|
exports.getNodeContentData = (params) => {
|
|
|
return searchApi.getNodeContent(params).then(result => {
|
|
|
|
|
|
if (result.code === 200 && result.data) {
|
|
|
return result.data;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品牌页面系列
|
|
|
*/
|
|
|
exports.getAdnav = (params) => {
|
|
|
return searchApi.getNodeContent(params).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
}; |
...
|
...
|
|