index.js
2.33 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
'use strict';
const api = global.yoho.API;
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const helpers = global.yoho.helpers;
/**
* 处理用户个人详情数据
*
* @param int uid 用户ID
* @return Object 处理之后的个人详情数据
*/
const _getUserProfileData = (uid) => {
return co(function*() {
// 调用接口获取个人详情
const data = {};
return data;
// return api.get('operations/api/v5/resource/get', {
// uid: uid
// }, {
// cache: true,
// code: 200
// });
})();
};
/**
* 处理个人中心页面优惠券,收藏的商品等的数目数据
*
* @param int uid 用户ID
* @return Object 处理之后的个人中心页面收藏的商品等的数目数据
*/
const _getInfoNumData = (uid) => {
return co(function*() {
const data = {
wait_pay_num: 1,
wait_cargo_num: 2,
send_cargo_num: 3,
address_num: 4,
product_favorite_total: 5,
brand_favorite_total: 6,
yoho_coin_num: 7
};
return data;
})();
};
exports.getUserHomeData = (uid) => {
return Promise.all([_getUserProfileData(uid), _getInfoNumData(uid)]);
};
const helpListDataProc = (helpData) => {
const formatData = [];
helpData = helpData || [];
_.forEach(helpData, (item) => {
formatData.push({
name: item.caption,
code: item.code,
url: helpers.urlFormat('/home/helpDetail', {
code: item.code,
caption: item.caption,
})
});
});
return formatData;
};
/**
* 帮助中心列表页
*
* @param data
*
*/
exports.getHelpInfo = (data) => {
var defaultParam = {
method: 'app.help.li'
},
infoData = Object.assign(defaultParam, data);
return api.get('', infoData).then(result => {
return helpListDataProc(result.data);
});
};
/**
* 帮助中心详情页
*
* @param data
*/
exports.getHelpDetail = (data) => {
var defaultParam = {
method: 'app.help.detail',
return_type: 'html'
},
detailData = Object.assign(defaultParam, data);
return api.get('', detailData).then(result => {
return result;
});
};