tide-command.js
1.39 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
const _ = require('lodash');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 文字说明
invitionText(uid) {
return this.get({
data: {
method: 'app.invitecode.my',
uid: uid
},
api: global.yoho.API,
param: {code: 200}
}).then((result) => {
if (result && result.code === 200 && result.data) {
return result.data;
} else {
return {};
}
});
}
// 资源位图
resources(contentCode) {
return this.get({
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode
},
api: global.yoho.ServiceAPI,
param: {code: 200}
}).then((result) => {
if (result && result.data) {
return result.data[0];
}
});
}
invitionData(uid, contentCode) {
return Promise.all([this.invitionText(uid), this.resources(contentCode)]).then((result) => {
let finaData = {};
finaData = Object.assign(finaData, result[0]);
finaData.imgSrc = _.get(result[1], 'data[0].src', '');
finaData.resourcesUrl = _.get(result[1], 'data[0].url', '');
return finaData;
});
}
};