brand.js 793 Bytes
/**
 * 品牌操作Models
 * @author: chenfeng<feng.chen@yoho.cn>
 * @date: 2016/09/07
 */
'use strict';
const api = global.yoho.API;

/**
 * [收藏品牌或者商品]
 * @param  {[int]}  uid     [用户ID]
 * @param  {[int]}  id      [品牌ID]
 * @param  {Boolean} isBrand [是品牌还是商品]
 * @param  {string} opt [操作(ok:表示确定,cancel:表示取消)]
 * @return {[array]}
 */
const favoriteBrand = (uid, id, isBrand, opt) => {
    let param = {
        uid: uid,
        type: isBrand ? 'brand' : 'product'
    };

    if (opt === 'ok') {
        param.id = id;
        param.method = 'app.favorite.add';
    } else {
        param.fav_id = id;
        param.method = 'app.favorite.cancel';
    }
    return api.post('', param);
};


module.exports = {
    favoriteBrand
};