brand-service.js
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Created by TaoHuang on 2016/6/14.
*/
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const api = require('./brand-api');
const _ = require('lodash');
const getBrandByDomainAsync = domain => {
return co(function*() {
let brandInfo = yield api.getBrandLogoByDomainAsync(domain);
if (!brandInfo.data || brandInfo.code !== 200) {
return {};
}
let result = {};
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 = {
getBrandByDomainAsync,
getBannerInfoAsync: api.getBannerInfoAsync
};