Showing
2 changed files
with
7 additions
and
18 deletions
@@ -7,6 +7,10 @@ | @@ -7,6 +7,10 @@ | ||
7 | const api = global.yoho.API; | 7 | const api = global.yoho.API; |
8 | const favApi = global.yoho.FavAPI; | 8 | const favApi = global.yoho.FavAPI; |
9 | 9 | ||
10 | +const _ = require('lodash'); | ||
11 | + | ||
12 | +const favoriteApi = require('./favorite-api'); | ||
13 | + | ||
10 | const isFavoriteAsync = (uid, pid) => { | 14 | const isFavoriteAsync = (uid, pid) => { |
11 | let onNewApi = false; | 15 | let onNewApi = false; |
12 | 16 | ||
@@ -27,23 +31,8 @@ const isFavoriteAsync = (uid, pid) => { | @@ -27,23 +31,8 @@ const isFavoriteAsync = (uid, pid) => { | ||
27 | } | 31 | } |
28 | }; | 32 | }; |
29 | 33 | ||
30 | -const createAsync = (uid, pid) => { | ||
31 | - return api.get('', { | ||
32 | - method: 'app.favorite.add', | ||
33 | - id: pid, | ||
34 | - uid: uid, | ||
35 | - type: 'product' | ||
36 | - }); | ||
37 | -}; | ||
38 | - | ||
39 | -const deleteAsync = (uid, pid) => { | ||
40 | - return api.get('', { | ||
41 | - method: 'app.favorite.cancel', | ||
42 | - fav_id: pid, | ||
43 | - uid: uid, | ||
44 | - type: 'product' | ||
45 | - }); | ||
46 | -}; | 34 | +const createAsync = _.partial(favoriteApi.addFavAsync, _, _, 'product'); |
35 | +const deleteAsync = _.partial(favoriteApi.cancelFavAsync, _, _, 'product'); | ||
47 | 36 | ||
48 | module.exports = { | 37 | module.exports = { |
49 | isFavoriteAsync, | 38 | isFavoriteAsync, |
-
Please register or login to post a comment