channel.js
1.52 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
50
51
52
53
'use strict';
const service = global.yoho.ServiceAPI;
const api = global.yoho.API;
const processResources = require(`${global.utils}/beautify/resources`);
const processProductList = require(`${global.utils}/beautify/product`);
let channel = {
getResourcesData(params) {
if (!params.contentCode) {
return Promise.resolve([]);
}
return service.get('operations/api/v5/resource/get', {
content_code: params.contentCode
}, {
cache: true,
code: 200
}).then(result => {
return result.data ? processResources(result.data) : [];
});
},
getSidebarData() {
return service.get('operations/api/v6/category/getCategory', {
parent_id: 1155
}, {
cache: true,
code: 200
}).then(global.yoho.camelCase);
},
getGoodsData(params) {
if (!params.productSkn || !params.productSkn.length) {
return Promise.resolve([]);
}
return api.get('', {
method: 'h5.product.batch',
productSkn: params.productSkn
}, {
cache: true,
code: 200
}).then(result => {
return result && result.data ? processProductList(result.data.product_list) : [];
});
},
getChannelData() {
return api.get('', {
method: 'app.blk.getAllChannels'
}, {
cache: true,
code: 200
}).then(global.yoho.camelCase);
}
};
module.exports = channel;