favorite.js 1.59 KB
/**
 * 我的收藏查询
 * @author: jiangfeng<jeff.jiang@yoho.cn>
 * @date: 16/7/19
 */
'use strict';


const _ = require('lodash');
const API = global.yoho.API;
const ServiceAPI = global.yoho.ServiceAPI;

const favorite = {

    /**
     * 查询收藏的商品
     * @param param
     * @returns {*}
     */
    getFavoriteProduct(param) {
        let p = {
            method: 'web.favorite.product'
        };

        return API.get('', _.assign(p, param));
    },

    /**
     * 查询收藏的店铺、品牌
     * @param param
     * @returns {*}
     */
    getFavoriteBrand(param) {
        let p = {
            method: 'app.favorite.brand'
        };

        return API.get('', _.assign(p, param));
    },

    /**
     * 查询收藏的资讯
     * @param param
     * @returns {*}
     */
    getFavoriteEditoreial(param) {
        return ServiceAPI.get('guang/api/*/favorite/getUserFavArticleList', param);
    },

    /**
     * 取消收藏 商品、店铺
     * @param uid
     * @param ids
     * @param type
     * @returns {*|type[]}
     */
    cancelFavorite(uid, ids, type) {
        let p = {
            method: 'web.favorite.cancel',
            uid: uid,
            favIds: ids,
            type: type
        };

        return API.post('', p);
    },

    /**
     * 取消收藏资讯
     * @param uid
     * @param ids
     * @returns {*}
     */
    cancelEditorialFavorite(uid, ids) {
        return ServiceAPI.get('guang/api/*/favorite/cancelFavorite', {
            article_id: ids,
            uid: uid,
            app_type: 1
        });
    }
};

module.exports = favorite;