suggest.js
1.51 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
/**
* 个人中心意见反馈
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/01
*/
'use strict';
const logger = global.yoho.logger;
const serviceAPI = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const suggestData = (uid, udid, page, limit) => {
return serviceAPI.get('suggest/api/v1/suggest/getList', {
udid: udid,
page: page,
limit: limit
}).then((result) => {
if (result && result.code === 200 && result.data) {
_.forEach(result.data.list, function(data) {
Object.assign(data, {
good: data.is_reliable === 1,
bad: data.is_reliable === 2,
none: data.is_reliable === 0
});
});
return camelCase(result.data.list);
} else {
logger.error('fav goods code no 200');
}
});
};
const upAndDown = (uid, udid, reliable, suggestId) => {
return serviceAPI.get('suggest/api/v1/suggest/is_reliable', {
uid: uid,
udid: udid,
is_reliable: reliable,
suggest_id: suggestId
});
};
// 提交
const saveSuggest = (uid, content, image, suggestType) => {
let per = {
uid: uid,
content: content,
suggest_type: suggestType
};
if (image !== null) {
per.image = image;
}
return serviceAPI.get('suggest/api/v1/suggest/saveSuggest', per);
};
module.exports = {
suggestData,
upAndDown,
saveSuggest
};