favorite-api.js
1.73 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
'use strict';
const api = global.yoho.API;
const service = global.yoho.ServiceAPI;
const URL_PRODUCT_FAVORITE = 'shops/service/v1/favorite/';
const URL_ARTICLE_FAVORITE = '/guang/api/v1/favorite/';
const URL_ARTICLE_FAVORITE_BRAND = '/guang/service/v2/favorite/toggleBrand';
// apiS.get(self::URL_ARTICLE_FAVORITE. 'getUserFavArticleList',{})
/**
* 根据uid和商品的id查询是否被用户收藏
* @param int $uid
* @param int $productId
* @param boolean $isOnlyUrl 是否指返回链接
* @return boolean 收藏 true 未收藏 false
*/
const getUidProductFav = (uid, productId, isOnlyUrl)=> {
isOnlyUrl = (isOnlyUrl === undefined) ? false : isOnlyUrl;
let options = {
method: 'web.favorite.isFavorite',
id: productId,
uid: uid,
type: 'product'
};
return api.get('', options);
};
const favoriteArticleData = (uid, udid, page, limit)=> {
let options = {
uid: uid,
udid: udid,
page: page,
limit: limit
};
return service.get(URL_ARTICLE_FAVORITE + 'getUserFavArticleList', options);
};
const getFavoriteProductList = (uid, page, limit)=> {
let options = {
method: 'web.favorite.product',
uid: uid,
page: 0,
limit: limit || 10
};
return api.get('', options);
};
const redutionCount = (uid)=> {
return api.get('', {
method: 'web.redution.count',
uid: uid
});
};
const favoriteBrandData = (uid, page, limit) => {
return api.get('', {
method: 'app.favorite.brand',
uid: uid,
page: page || 1,
limit: limit || 10
});
};
module.exports = {
getUidProductFav,
getFavoriteProductList,
favoriteArticleData,
favoriteBrandData,
redutionCount
};