opt.js
1.75 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
/**
* 逛操作models
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 2016/09/07
*/
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
/**
* [逛资讯点赞/取消赞]
* @param {[int]} udid [唯一客户端标识]
* @param {[int]} id [唯一资讯的ID]
* @param {[string]} opt [操作(ok:表示确定,cancel:表示取消)]
* @return {[array]}
*/
const praiseArticle = (udid, id, opt) => {
let param = {
article_id: id,
udid: udid
};
if (opt === 'cancel') {
return serviceAPI.get('guang/api/v2/praise/cancel', param);
} else {
return serviceAPI.get('guang/api/v2/praise/setPraise', param);
}
};
/**
* [逛资讯收藏/取消收藏 (APP里调用)]
* @param {[int]} uid [用户id]
* @param {[int]} id [唯一资讯的ID]
* @param {[string]} opt [操作(ok:表示确定,cancel:表示取消)]
* @return {[array]}
*/
const collectArticle = (uid, id, opt) => {
let param = {
article_id: id,
uid: uid
};
if (opt === 'cancel') {
return serviceAPI.get('guang/api/v1/favorite/cancelFavorite', param);
} else {
return serviceAPI.get('guang/api/v1/favorite/setFavorite', param);
}
};
// 品牌收藏
const favoriteBrand = (uid, id, opt) => {
let param;
if (opt === 'ok') {
param = {
id: id,
uid: uid,
type: 'brand'
};
} else {
param = {
fav_id: id,
uid: uid,
type: 'brand'
};
}
if (opt === 'ok') {
return api.get('app.favorite.add', param);
} else {
return api.get('app.favorite.cancel', param);
}
};
module.exports = {
praiseArticle,
collectArticle,
favoriteBrand
};