Blame view

apps/guang/models/brand.js 967 Bytes
陈峰 authored
1 2 3 4 5
/**
 * 品牌操作Models
 * @author: chenfeng<feng.chen@yoho.cn>
 * @date: 2016/09/07
 */
6 7
'use strict';
陈峰 authored
8
zhangxiaoru authored
9 10 11
module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
陈峰 authored
12
    }
13
zhangxiaoru authored
14 15 16 17 18 19 20 21 22 23 24 25 26
    /**
     * [收藏品牌或者商品]
     * @param  {[int]}  uid     [用户ID]
     * @param  {[int]}  id      [品牌ID]
     * @param  {Boolean} isBrand [是品牌还是商品]
     * @param  {string} opt [操作(ok:表示确定,cancel:表示取消)]
     * @return {[array]}
     */
    favoriteBrand(uid, id, opt, isBrand) {
        let param = {
            uid: uid,
            type: isBrand ? 'brand' : 'product'
        };
27
zhangxiaoru authored
28 29 30 31 32 33 34
        if (opt === 'ok') {
            param.id = id;
            param.method = 'app.favorite.add';
        } else {
            param.fav_id = id;
            param.method = 'app.favorite.cancel';
        }
zhangxiaoru authored
35 36 37 38
        return this.post({
            data: param,
            api: global.yoho.API
        });
zhangxiaoru authored
39
    }
40
};