favorite-product-api.js
864 Bytes
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
/**
* Created by TaoHuang on 2016/6/13.
*/
'use strict';
const api = global.yoho.API;
const favApi = global.yoho.FavAPI;
const _ = require('lodash');
const favoriteApi = require('./favorite-api');
const isFavoriteAsync = (uid, pid) => {
let onNewApi = false;
if (onNewApi) {
return favApi.get('', {
method: 'app.favorite.isFavoriteNew',
id: pid,
uid: uid,
type: 'product'
});
} else {
return api.get('', {
method: 'app.favorite.isFavorite',
id: pid,
uid: uid,
type: 'product'
});
}
};
const createAsync = _.partial(favoriteApi.addFavAsync, _, _, 'product');
const deleteAsync = _.partial(favoriteApi.cancelFavAsync, _, _, 'product');
module.exports = {
isFavoriteAsync,
createAsync,
deleteAsync
};