FavoriteData.js 1.5 KB
'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, limit)=>{
    limit=limit||500;
    let options = {
        method: 'web.favorite.product',
        uid: uid,
        limit: limit
    };
    return api.get('', options);
};

const redutionCount=(uid)=>{
    let options={
        method:'web.redution.count',
        uid:uid
    };
    return api.get('',options);
}

module.exports = {
    getUidProductFav,
    getFavoriteProductList,
    favoriteArticleData,
    redutionCount
};