...
|
...
|
@@ -5,14 +5,12 @@ |
|
|
* Time: 13:51
|
|
|
*/
|
|
|
'use strict';
|
|
|
const path = require('path');
|
|
|
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const brandApi = require('./brand-api');
|
|
|
const logger = global.yoho.logger;
|
|
|
const _ = require('lodash');
|
|
|
const processProductList = require(path.join(global.utils, '/beautify/product')).processProductList;
|
|
|
const camelCase = global.yoho.camelCase;
|
|
|
|
|
|
/**
|
|
|
* 处理品牌一览品牌列表数据
|
...
|
...
|
@@ -53,94 +51,6 @@ const handleBrandList = origin => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品牌店铺数据
|
|
|
* @param params
|
|
|
* @returns {*|Promise.<TResult>}
|
|
|
*/
|
|
|
const getBrandData = params => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
return api.all([
|
|
|
brandApi.getBrandInfoByDomain({domain: params.domain})
|
|
|
]).then(result => {
|
|
|
|
|
|
if (result[0].code === 200) {
|
|
|
|
|
|
/* 品牌有店铺 */
|
|
|
if (result[0].data.shop_id) {
|
|
|
return api.all([
|
|
|
brandApi.getShopInfoData({
|
|
|
shopId: result[0].data.shop_id,
|
|
|
uid: params.uid
|
|
|
})
|
|
|
]).then(subResult => {
|
|
|
if (subResult[0].code === 200) {
|
|
|
|
|
|
/* TODO 判断是否是使用 BLK 模板,不使用 BLK 模板的就直接返回 */
|
|
|
if (subResult[0].data.shop_template_type === '2') {
|
|
|
Object.assign(finalResult, {
|
|
|
|
|
|
/* TODO 背景图取资源位,接口未开发 */
|
|
|
brandBg: 'http://7xwj52.com1.z0.glb.clouddn.com/brandbg.jpg',
|
|
|
|
|
|
/* TODO 是否显示店铺 LOGO,接口未开发 */
|
|
|
showBrandLogo: false,
|
|
|
brandLogo: subResult[0].data.shop_logo,
|
|
|
brandName: subResult[0].data.shop_name,
|
|
|
brandIntro: subResult[0].data.shop_intro
|
|
|
});
|
|
|
return finalResult;
|
|
|
} else {
|
|
|
logger.info('no BLK template');
|
|
|
}
|
|
|
} else {
|
|
|
logger.error('getShopInfoData api code no 200');
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
logger.info('brand has no shop');
|
|
|
}
|
|
|
} else {
|
|
|
logger.error('getBrandOriginData api code no 200');
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品牌店铺商品数据
|
|
|
* @param params
|
|
|
* @returns {*|Promise.<TResult>}
|
|
|
*/
|
|
|
const getBrandShopGoodsData = params => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
return api.all([brandApi.getBrandShopGoodsOriginData(params)]).then(result => {
|
|
|
if (result[0].code === 200) {
|
|
|
Object.assign(finalResult, {
|
|
|
data: {
|
|
|
productList: processProductList(result[0].data.productList)
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
logger.error('getBrandShopGoodsOriginData api code no 200');
|
|
|
}
|
|
|
|
|
|
return camelCase(finalResult);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 收藏店铺
|
|
|
* @param params
|
|
|
* @returns {*|Promise.<TResult>}
|
|
|
*/
|
|
|
const collectShopData = params => {
|
|
|
return api.all([brandApi.collectShopOriginData(params)]).then(result => {
|
|
|
return result[0];
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品牌列表页数据
|
|
|
* @param params
|
|
|
*/
|
...
|
...
|
@@ -234,24 +144,7 @@ const getCateListData = params => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取品类资源位数据
|
|
|
* @param params
|
|
|
* @returns {*|Promise.<TResult>}
|
|
|
*/
|
|
|
const getCateResource = params => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
return brandApi.getCateResource(params).then(result => {
|
|
|
return finalResult;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getBrandData,
|
|
|
getBrandShopGoodsData,
|
|
|
getBrandListData,
|
|
|
getCateListData,
|
|
|
getCateResource,
|
|
|
collectShopData
|
|
|
getCateListData
|
|
|
}; |
...
|
...
|
|