Authored by htoooth

refactor

... ... @@ -3,46 +3,22 @@
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const Promise = require('bluebird');
const co = Promise.coroutine;
const api = new API();
module.exports.getBannerInfoAsync = function(bid) {
module.exports.getBannerInfoAsync = (bid) => {
return api.get('', sign.apiSign({
method: 'web.brand.banner',
brand_id: bid
}));
};
function getBrandLogoByDomainAsync(domain) {
module.exports.getBrandLogoByDomainAsync = (domain) => {
return api.get('', sign.apiSign({
domain: domain,
method: 'web.brand.byDomain'
}));
}
module.exports.getBrandByDomainAsync = function(domain) {
return co(function*() {
let brandInfo = yield getBrandLogoByDomainAsync(domain);
let result = {};
if (brandInfo.data && brandInfo.code === 200) {
result.brandId = brandInfo.data.id || '';
result.node = brandInfo.data.static_content_code || false;
result.brandBanner = brandInfo.data.brand_banner || '';
result.brandNameEn = brandInfo.data.brand_name_en || '';
result.brandNameCn = brandInfo.data.brand_name_cn || '';
result.brandAbout = brandInfo.data.brand_intro || '';
result.shopTemplateType = brandInfo.data.shop_template_type ?
parseInt(brandInfo.data.shop_template_type) : '';
result.type = brandInfo.data.type ? +brandInfo.data.type : 0;
result.shopId = brandInfo.data.shop_id || '';
}
return result;
})();
};
... ...
/**
* Created by TaoHuang on 2016/6/14.
*/
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const api = require('./brand-api');
module.exports.getBrandByDomainAsync = (domain) => {
return co(function*() {
let brandInfo = yield api.getBrandLogoByDomainAsync(domain);
let result = {};
if (brandInfo.data && brandInfo.code === 200) {
result.brandId = brandInfo.data.id || '';
result.node = brandInfo.data.static_content_code || false;
result.brandBanner = brandInfo.data.brand_banner || '';
result.brandNameEn = brandInfo.data.brand_name_en || '';
result.brandNameCn = brandInfo.data.brand_name_cn || '';
result.brandAbout = brandInfo.data.brand_intro || '';
result.shopTemplateType = brandInfo.data.shop_template_type ?
parseInt(brandInfo.data.shop_template_type) : '';
result.type = brandInfo.data.type ? +brandInfo.data.type : 0;
result.shopId = brandInfo.data.shop_id || '';
}
return result;
})();
};
module.exports.getBannerInfoAsync = api.getBannerInfoAsync;
... ...
... ... @@ -18,7 +18,8 @@ const detailAPI = require('./detail-main-api');
const commentAPI = require('./detail-comment-api');
const consultAPI = require('./detail-consult-api');
const hotAreaAPI = require('./detail-hotarea-api');
const brandAPI = require('./brand-api');
const brandService = require('./brand-service');
const favoriteBrandService = require('./favorite-brand-service');
const favoriteProductService = require('./favorite-product-service');
... ... @@ -53,7 +54,7 @@ const setMultiResourceByProductBaseInfo = (data) => {
detailAPI.getProductComfortAsync(productId, isOnlyUrl),
detailAPI.getProductModelCardAsync(productId, isOnlyUrl),
detailAPI.getProductModelTryAsync(skn, isOnlyUrl),
brandAPI.getBannerInfoAsync(brandId, isOnlyUrl)
brandService.getBannerInfoAsync(brandId, isOnlyUrl)
]);
multiResourcesUrl['ItemData::getProductBanner'] = result[0];
... ... @@ -279,7 +280,7 @@ const getBrandDataByProductBaseInfo = (data) => {
let result = getMultiDataByResourceName('BrandData::getBannerInfo');
if (!result) {
result = yield brandAPI.getBannerInfoAsync(brandId);
result = yield brandService.getBannerInfoAsync(brandId);
}
if (data.brand.brandIco) {
... ... @@ -746,7 +747,7 @@ const detailDataPkg = (origin, uid, vipLevel) => {
}
if (banner.brandId) {
let domainBrand = yield brandAPI.getBrandByDomainAsync(banner.brandDomain);
let domainBrand = yield brandService.getBrandByDomainAsync(banner.brandDomain);
if (domainBrand.type && domainBrand.shopId) {
switch (parseInt(domainBrand.type)) {
... ...