...
|
...
|
@@ -10,7 +10,9 @@ const searchApi = require('./search-api'); |
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
const searchHandler = require('./search-handler');
|
|
|
const shopHandler = require('./shop-handler');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
// 品牌页folder名称
|
|
|
const brandFolderSeries = '经典系列';
|
...
|
...
|
@@ -218,7 +220,6 @@ exports.getBrandData = (params, extra) => { |
|
|
// 品牌页不显示品牌筛选项
|
|
|
delete finalResult.brand.filters.brand;
|
|
|
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
};
|
...
|
...
|
@@ -269,30 +270,132 @@ exports.getAdnav = (params) => { |
|
|
exports.getShopInfo = (shopId, uid) => {
|
|
|
|
|
|
return searchApi.getShopInfo(shopId, uid).then(result => {
|
|
|
return {
|
|
|
brandName: result.shop_name,
|
|
|
brandCont: result.shop_intro,
|
|
|
domain: result.shop_domain,
|
|
|
logo: result.shop_logo,
|
|
|
isFavorite: result.is_favorite === 'Y',
|
|
|
shopTemplateType: result.shop_template_type,
|
|
|
multBrandShopType: result.mult_brand_shop_type,
|
|
|
showShopName: result.is_show_shop_name === 'Y'
|
|
|
};
|
|
|
if (result.code === 200) {
|
|
|
return {
|
|
|
brandName: result.data.shop_name,
|
|
|
brandCont: result.data.shop_intro,
|
|
|
domain: result.data.shop_domain,
|
|
|
logo: result.data.shop_logo,
|
|
|
isFavorite: result.data.is_favorite === 'Y',
|
|
|
shopTemplateType: result.data.shop_template_type,
|
|
|
multBrandShopType: result.data.mult_brand_shop_type,
|
|
|
showShopName: result.data.is_show_shop_name === 'Y'
|
|
|
};
|
|
|
} else {
|
|
|
|
|
|
// log
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取店铺数据
|
|
|
* 获取经典模板店铺数据
|
|
|
* @param shopId
|
|
|
* @param uid
|
|
|
* @param params
|
|
|
* @param shopInfo 店铺介绍
|
|
|
*/
|
|
|
exports.getShopData = (shopId, uid) => {
|
|
|
exports.getShopData = (shopId, uid, params, shopInfo) => {
|
|
|
|
|
|
// 调用接口
|
|
|
// let apiMethod = [
|
|
|
// 店铺所有品牌
|
|
|
return searchApi.getShopBrands(shopId).then(shopBrands => {
|
|
|
if (shopBrands.code === 200 && shopBrands.data) {
|
|
|
return shopBrands.data;
|
|
|
}
|
|
|
}).then(shopBrands => {
|
|
|
|
|
|
// 店铺的所有品牌id
|
|
|
let shopBrandIds = [],
|
|
|
|
|
|
// 通过品牌获取相关文章接口
|
|
|
articleApiMethod = [],
|
|
|
|
|
|
// 需要调用的接口数组
|
|
|
apiMethod = [
|
|
|
|
|
|
// 头部数据
|
|
|
headerModel.requestHeaderData('boys'),
|
|
|
|
|
|
// 店铺装修数据
|
|
|
searchApi.getShopDecorator(shopId),
|
|
|
|
|
|
// 搜索店铺商品
|
|
|
searchApi.getProductList(params)
|
|
|
];
|
|
|
|
|
|
_.forEach(shopBrands, (value) => {
|
|
|
|
|
|
shopBrandIds.push(value.brand_id);
|
|
|
|
|
|
articleApiMethod.push(
|
|
|
|
|
|
// // 店铺基本信息
|
|
|
// searchApi.getSortList({brand: extra.brandId}),
|
|
|
// ];
|
|
|
// 店铺装修数据
|
|
|
searchApi.getArticleByBrand(value.brand_id, 'udid')
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
// 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
|
|
|
// apiMethod.push(
|
|
|
// // 店铺分类
|
|
|
// searchApi.getSortList({brand: shopBrandIds})
|
|
|
// );
|
|
|
|
|
|
// apiMethod 添加调用相关文章的接口
|
|
|
apiMethod = _.concat(apiMethod, articleApiMethod);
|
|
|
|
|
|
return api.all(apiMethod).then(result => {
|
|
|
|
|
|
let finalResult = {
|
|
|
headerData: Object.assign(result[0].headerData, {header: true}),
|
|
|
pathNav: searchHandler.handlePathNavData(shopInfo, params, 'shop')
|
|
|
};
|
|
|
|
|
|
// 面包屑导航
|
|
|
Object.assign(finalResult, searchHandler.handlePathNavData(shopInfo, params, 'shop'));
|
|
|
|
|
|
// 店铺介绍
|
|
|
|
|
|
// 店铺装修
|
|
|
if (result[1].code === 200) {
|
|
|
Object.assign(finalResult, shopHandler.getShopDecorator(result[1].data, params, shopId));
|
|
|
} else {
|
|
|
return Promise.reject('No ShopDecorator data');
|
|
|
}
|
|
|
|
|
|
// // 获取左侧类目数据
|
|
|
// if (result[1].code === 200) {
|
|
|
// Object.assign(finalResult.shop, {
|
|
|
// leftContent: searchHandler.handleSortData(result[1].data.sort, params),
|
|
|
// pathNav: searchHandler.handlePathNavData(extra, params, 'brand')
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// if (result[1].code === 200) {
|
|
|
|
|
|
// console.log(result[1].data);
|
|
|
// }
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
// if (result[2].code === 200) {
|
|
|
// Object.assign(finalResult.shop, {
|
|
|
// 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))
|
|
|
// });
|
|
|
// }
|
|
|
return finalResult;
|
|
|
});
|
|
|
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取基础模板店铺数据
|
|
|
*/
|
|
|
exports.getBaseShopData = (shopId, uid) => {
|
|
|
return searchApi.getShopInfo(shopId, uid);
|
|
|
}; |
...
|
...
|
|