guang-new.js
2.25 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
'use strict';
const _ = require('lodash');
class newGuang extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
_indexRes(params) {
let options = {
url: '/operations/api/v5/resource/get',
data: {
content_code: '44153d54effebaf803a2deee06b3ea5a',
gender: params.gender
},
api: global.yoho.ServiceAPI
};
return this.get(options).then(result => {
return result;
});
}
list(params) {
let options = {
url: '/guang/api/v1/article/getHomePageList',
data: {
page: params.page || 1,
limit: params.limit || 2
},
api: global.yoho.ServiceAPI
};
return this.get(options).then(result => {
let resu = {
list: []
};
if (_.get(result, 'data.guangList')) {
resu.list = result.data.guangList;
}
return resu;
});
}
index(params) {
return Promise.all([
this._indexRes(params)
]).then((result) => {
let resu = {
floorRes: {},
gender: encodeURIComponent(params.gender)
};
if (_.get(result, '[0].data')) {
_.forEach(result[0].data, (val) => {
if (val.template_name === 'focus') {
resu.floorRes.focus = _.get(val, 'data');
}
if (val.template_name === '3:4ImageListFloor') {
resu.floorRes.type = _.get(val, 'data.list');
}
if (val.template_name === 'GuangRqFloor') {
resu.floorRes.renQi = _.get(val, 'data.list');
}
if (val.template_name === 'GuangDpFloor') {
resu.floorRes.daPei = _.get(val, 'data.list');
}
if (val.template_name === 'GuangHhFloor') {
resu.floorRes.haoHuo = _.get(val, 'data.list');
}
});
}
return resu;
});
}
}
module.exports = newGuang;