Showing
3 changed files
with
42 additions
and
31 deletions
@@ -3,46 +3,22 @@ | @@ -3,46 +3,22 @@ | ||
3 | const library = '../../../library'; | 3 | const library = '../../../library'; |
4 | const API = require(`${library}/api`).API; | 4 | const API = require(`${library}/api`).API; |
5 | const sign = require(`${library}/sign`); | 5 | const sign = require(`${library}/sign`); |
6 | -const Promise = require('bluebird'); | ||
7 | -const co = Promise.coroutine; | ||
8 | 6 | ||
9 | const api = new API(); | 7 | const api = new API(); |
10 | 8 | ||
11 | -module.exports.getBannerInfoAsync = function(bid) { | 9 | +module.exports.getBannerInfoAsync = (bid) => { |
12 | return api.get('', sign.apiSign({ | 10 | return api.get('', sign.apiSign({ |
13 | method: 'web.brand.banner', | 11 | method: 'web.brand.banner', |
14 | brand_id: bid | 12 | brand_id: bid |
15 | })); | 13 | })); |
16 | }; | 14 | }; |
17 | 15 | ||
18 | -function getBrandLogoByDomainAsync(domain) { | 16 | +module.exports.getBrandLogoByDomainAsync = (domain) => { |
19 | return api.get('', sign.apiSign({ | 17 | return api.get('', sign.apiSign({ |
20 | domain: domain, | 18 | domain: domain, |
21 | method: 'web.brand.byDomain' | 19 | method: 'web.brand.byDomain' |
22 | })); | 20 | })); |
23 | -} | ||
24 | - | ||
25 | -module.exports.getBrandByDomainAsync = function(domain) { | ||
26 | - return co(function*() { | ||
27 | - let brandInfo = yield getBrandLogoByDomainAsync(domain); | ||
28 | - | ||
29 | - let result = {}; | ||
30 | - | ||
31 | - if (brandInfo.data && brandInfo.code === 200) { | ||
32 | - result.brandId = brandInfo.data.id || ''; | ||
33 | - result.node = brandInfo.data.static_content_code || false; | ||
34 | - result.brandBanner = brandInfo.data.brand_banner || ''; | ||
35 | - result.brandNameEn = brandInfo.data.brand_name_en || ''; | ||
36 | - result.brandNameCn = brandInfo.data.brand_name_cn || ''; | ||
37 | - result.brandAbout = brandInfo.data.brand_intro || ''; | ||
38 | - result.shopTemplateType = brandInfo.data.shop_template_type ? | ||
39 | - parseInt(brandInfo.data.shop_template_type) : ''; | ||
40 | - result.type = brandInfo.data.type ? +brandInfo.data.type : 0; | ||
41 | - result.shopId = brandInfo.data.shop_id || ''; | ||
42 | - | ||
43 | - } | ||
44 | - return result; | ||
45 | - })(); | ||
46 | }; | 21 | }; |
47 | 22 | ||
48 | 23 | ||
24 | + |
apps/product/models/brand-service.js
0 → 100644
1 | +/** | ||
2 | + * Created by TaoHuang on 2016/6/14. | ||
3 | + */ | ||
4 | +'use strict'; | ||
5 | + | ||
6 | +const Promise = require('bluebird'); | ||
7 | +const co = Promise.coroutine; | ||
8 | + | ||
9 | +const api = require('./brand-api'); | ||
10 | + | ||
11 | +module.exports.getBrandByDomainAsync = (domain) => { | ||
12 | + return co(function*() { | ||
13 | + let brandInfo = yield api.getBrandLogoByDomainAsync(domain); | ||
14 | + | ||
15 | + let result = {}; | ||
16 | + | ||
17 | + if (brandInfo.data && brandInfo.code === 200) { | ||
18 | + result.brandId = brandInfo.data.id || ''; | ||
19 | + result.node = brandInfo.data.static_content_code || false; | ||
20 | + result.brandBanner = brandInfo.data.brand_banner || ''; | ||
21 | + result.brandNameEn = brandInfo.data.brand_name_en || ''; | ||
22 | + result.brandNameCn = brandInfo.data.brand_name_cn || ''; | ||
23 | + result.brandAbout = brandInfo.data.brand_intro || ''; | ||
24 | + result.shopTemplateType = brandInfo.data.shop_template_type ? | ||
25 | + parseInt(brandInfo.data.shop_template_type) : ''; | ||
26 | + result.type = brandInfo.data.type ? +brandInfo.data.type : 0; | ||
27 | + result.shopId = brandInfo.data.shop_id || ''; | ||
28 | + | ||
29 | + } | ||
30 | + return result; | ||
31 | + })(); | ||
32 | +}; | ||
33 | + | ||
34 | +module.exports.getBannerInfoAsync = api.getBannerInfoAsync; |
@@ -18,7 +18,8 @@ const detailAPI = require('./detail-main-api'); | @@ -18,7 +18,8 @@ const detailAPI = require('./detail-main-api'); | ||
18 | const commentAPI = require('./detail-comment-api'); | 18 | const commentAPI = require('./detail-comment-api'); |
19 | const consultAPI = require('./detail-consult-api'); | 19 | const consultAPI = require('./detail-consult-api'); |
20 | const hotAreaAPI = require('./detail-hotarea-api'); | 20 | const hotAreaAPI = require('./detail-hotarea-api'); |
21 | -const brandAPI = require('./brand-api'); | 21 | + |
22 | +const brandService = require('./brand-service'); | ||
22 | 23 | ||
23 | const favoriteBrandService = require('./favorite-brand-service'); | 24 | const favoriteBrandService = require('./favorite-brand-service'); |
24 | const favoriteProductService = require('./favorite-product-service'); | 25 | const favoriteProductService = require('./favorite-product-service'); |
@@ -53,7 +54,7 @@ const setMultiResourceByProductBaseInfo = (data) => { | @@ -53,7 +54,7 @@ const setMultiResourceByProductBaseInfo = (data) => { | ||
53 | detailAPI.getProductComfortAsync(productId, isOnlyUrl), | 54 | detailAPI.getProductComfortAsync(productId, isOnlyUrl), |
54 | detailAPI.getProductModelCardAsync(productId, isOnlyUrl), | 55 | detailAPI.getProductModelCardAsync(productId, isOnlyUrl), |
55 | detailAPI.getProductModelTryAsync(skn, isOnlyUrl), | 56 | detailAPI.getProductModelTryAsync(skn, isOnlyUrl), |
56 | - brandAPI.getBannerInfoAsync(brandId, isOnlyUrl) | 57 | + brandService.getBannerInfoAsync(brandId, isOnlyUrl) |
57 | ]); | 58 | ]); |
58 | 59 | ||
59 | multiResourcesUrl['ItemData::getProductBanner'] = result[0]; | 60 | multiResourcesUrl['ItemData::getProductBanner'] = result[0]; |
@@ -279,7 +280,7 @@ const getBrandDataByProductBaseInfo = (data) => { | @@ -279,7 +280,7 @@ const getBrandDataByProductBaseInfo = (data) => { | ||
279 | let result = getMultiDataByResourceName('BrandData::getBannerInfo'); | 280 | let result = getMultiDataByResourceName('BrandData::getBannerInfo'); |
280 | 281 | ||
281 | if (!result) { | 282 | if (!result) { |
282 | - result = yield brandAPI.getBannerInfoAsync(brandId); | 283 | + result = yield brandService.getBannerInfoAsync(brandId); |
283 | } | 284 | } |
284 | 285 | ||
285 | if (data.brand.brandIco) { | 286 | if (data.brand.brandIco) { |
@@ -746,7 +747,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { | @@ -746,7 +747,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { | ||
746 | } | 747 | } |
747 | 748 | ||
748 | if (banner.brandId) { | 749 | if (banner.brandId) { |
749 | - let domainBrand = yield brandAPI.getBrandByDomainAsync(banner.brandDomain); | 750 | + let domainBrand = yield brandService.getBrandByDomainAsync(banner.brandDomain); |
750 | 751 | ||
751 | if (domainBrand.type && domainBrand.shopId) { | 752 | if (domainBrand.type && domainBrand.shopId) { |
752 | switch (parseInt(domainBrand.type)) { | 753 | switch (parseInt(domainBrand.type)) { |
-
Please register or login to post a comment