spread.js
1.08 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
/**
* 我的消息model
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/8/29
*/
'use strict';
const _ = require('lodash');
const setPager = require(`${global.utils}/pager`).setPager;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getIndexData(uid, page) {
return Promise.all([
this.get({data: {
method: 'app.invitecode.my',
uid: uid
}}),
this.get({data: {
method: 'app.invitecode.detail',
uid: uid,
page: page || 1
}})
]).then(result => {
let resData = _.get(result, '[0].data', {});
let resList = result[1];
if (resList.code === 200) {
let list = _.get(resList, 'data.data', []);
if (!_.isEmpty(list)) {
resData.list = list;
}
Object.assign(resData, setPager(_.get(resList, 'data.total', 1), {page: page}));
}
return resData;
});
}
};