suggest.js
1.9 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
/**
* 个人中心意见反馈
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/01
*/
'use strict';
const logger = global.yoho.logger;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
suggestData(uid, udid, page, limit) {
return this.get({
url: 'suggest/api/v1/suggest/getList',
data: {
udid: udid,
page: page,
limit: limit
},
api: global.yoho.ServiceAPI
}).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');
}
});
}
upAndDown(uid, udid, reliable, suggestId) {
return this.get({
url: 'suggest/api/v1/suggest/is_reliable',
data: {
uid: uid,
udid: udid,
is_reliable: reliable,
suggest_id: suggestId
},
api: global.yoho.ServiceAPI
});
}
// 提交
saveSuggest(uid, content, image, suggestType) {
let per = {
uid: uid,
content: content,
suggest_type: suggestType
};
if (image !== null) {
per.image = image;
}
return this.get({
url: 'suggest/api/v1/suggest/saveSuggest',
data: per,
api: global.yoho.ServiceAPI
});
}
};