Authored by htoooth

add favorite product

... ... @@ -68,7 +68,7 @@ const setMultiResourceByProductBaseInfo = (data) => {
if (uid) {
multiResourcesUrl['FavoriteData::getUidProductFav'] =
yield favoriteProductService.getUidProductFavAsync(uid, productId, isOnlyUrl);
yield favoriteProductService.isFavoriteAsync(uid, productId, isOnlyUrl);
}
})();
};
... ... @@ -94,7 +94,7 @@ const getProductFavoriteData = (uid, pid, bid) => {
let productData = getMultiDataByResourceName('FavoriteData::getUidProductFav');
if (!productData) {
productData = yield favoriteProductService.getUidProductFavAsync(uid, pid);
productData = yield favoriteProductService.isFavoriteAsync(uid, pid);
}
result.product = productData.code === 200 && productData.data ? true : false;
}
... ...
... ... @@ -4,12 +4,11 @@
const library = '../../../library';
const API = require(`${library}/api`).API;
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const sign = require(`${library}/sign`);
const api = new API();
module.exports.getUidProductFavAsync = function (uid, pid) {
module.exports.isFavoriteAsync = function (uid, pid) {
return api.get('', sign.apiSign({
method: 'app.favorite.isFavorite',
id: pid,
... ... @@ -17,3 +16,21 @@ module.exports.getUidProductFavAsync = function (uid, pid) {
type: 'product'
}));
};
module.exports.createAsync = function (uid, pid) {
return api.get('', sign.apiSign({
method: 'app.favorite.add',
id: pid,
uid: uid,
type: 'product'
}));
};
module.exports.deleteAsync = function (uid, pid) {
return api.get('', sign.apiSign({
method: 'app.favorite.cancel',
fav_id: pid,
uid: uid,
type: 'product'
}));
};
... ...
... ... @@ -6,4 +6,8 @@
const favoriteProductAPI = require('./favorite-product-api');
module.exports.getUidProductFavAsync = favoriteProductAPI.getUidProductFavAsync;
module.exports.isFavoriteAsync = favoriteProductAPI.isFavoriteAsync;
module.exports.createAsync = favoriteProductAPI.createAsync;
module.exports.deleteAsync = favoriteProductAPI.deleteAsync;
... ...