plusstar.js
2.65 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
/**
* 获取潮流优选tab
* @return {[array]}
*/
const getAllChannels = (params) => {
params = params || {};
return api.get('', Object.assign({
method: 'app.blk.getAllChannels'
}, params)).then(result => {
let data = {channel: []};
if (result.code !== 200) {
return data;
}
_.forEach(result.data, (res, index) => {
data.channel.push({
id: res.channel_id,
mame: res.channel_name,
code: res.content_code,
focus: index === 0 ? true : false
});
});
return data;
});
};
/**
* 获取资源位数据
* @param {[string]} content_code
* @return {[array]}
*/
const getResources = (params) => {
params = params || {};
return serviceAPI.get(
'operations/api/v5/resource/get',
Object.assign(params)
).then(result => {
let data = {};
let list = {};
if (result.code !== 200) {
return data2;
}
_.forEach(result.data, (res, index) => {
list = {};
switch (res.template_name) {
case 'focus':
list = {
data: res.data
};
if (res.focus_type == 1) {
data.focus1 = list;
} else {
data.focus2 = list;
}
break;
case 'title_image':
if (typeof data[res.template_name] === 'undefined') {
data[res.template_name] = [];
}
list = {
title: res.data.title,
moreUrl: res.data.more_url,
moreName: res.data.more_name,
image: res.data.image
};
data.title_image.push(list);
break;
case 'titleFloor':
list = {
title: res.data.title.more_name,
more_url: res.data.more_url,
more_name: res.data.more_name,
data: res.data.image
};
data[res.template_name].push(list);
break;
case 'recommend_content_five':
break;
case 'goods':
break;
}
});
// console.log(data, '=data===');
return data2;
});
};
module.exports = {
getAllChannels,
getResources
};