brand-api.js
1.48 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
40
41
42
43
44
45
46
47
48
49
'use strict';
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, isUrl) {
isUrl;
return api.get('', sign.apiSign({
method: 'web.brand.banner',
brand_id: bid
}));
};
function 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;
})();
};