Blame view

apps/guang/models/opt.js 2.47 KB
陈峰 authored
1 2 3 4 5
/**
 * 逛操作models
 * @author: chenfeng<feng.chen@yoho.cn>
 * @date: 2016/09/07
 */
6 7
'use strict';
zhangxiaoru authored
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    /**
     * [逛资讯点赞/取消赞]
     * @param  {[int]} udid [唯一客户端标识]
     * @param  {[int]} id   [唯一资讯的ID]
     * @param  {[string]} opt  [操作(ok:表示确定,cancel:表示取消)]
     * @return {[array]}
     */
    praiseArticle(udid, id, opt) {
        let param = {
            article_id: id,
            udid: udid
        };
陈峰 authored
25
zhangxiaoru authored
26
        if (opt === 'cancel') {
zhangxiaoru authored
27 28 29 30 31
            return this.get({
                url: 'guang/api/v2/praise/cancel',
                data: param,
                api: global.yoho.ServiceAPI
            });
zhangxiaoru authored
32
        } else {
zhangxiaoru authored
33 34 35 36 37
            return this.get({
                url: 'guang/api/v2/praise/setPraise',
                data: param,
                api: global.yoho.ServiceAPI
            });
zhangxiaoru authored
38
        }
39 40
    }
zhangxiaoru authored
41 42 43 44 45 46 47 48 49 50 51 52
    /**
     * [逛资讯收藏/取消收藏 (APP里调用)]
     * @param  {[int]} uid [用户id]
     * @param  {[int]} id   [唯一资讯的ID]
     * @param  {[string]} opt  [操作(ok:表示确定,cancel:表示取消)]
     * @return {[array]}
     */
    collectArticle(uid, id, opt) {
        let param = {
            article_id: id,
            uid: uid
        };
陈峰 authored
53
zhangxiaoru authored
54
        if (opt === 'cancel') {
zhangxiaoru authored
55 56 57 58 59
            return this.get({
                url: 'guang/api/v1/favorite/cancelFavorite',
                data: param,
                api: global.yoho.ServiceAPI
            });
zhangxiaoru authored
60
        } else {
zhangxiaoru authored
61 62 63 64 65
            return this.get({
                url: 'guang/api/v1/favorite/setFavorite',
                data: param,
                api: global.yoho.ServiceAPI
            });
zhangxiaoru authored
66
        }
67 68
    }
zhangxiaoru authored
69
    // 品牌收藏
zhangxiaoru authored
70
zhangxiaoru authored
71 72
    favoriteBrand(uid, id, opt) {
        let param;
zhangxiaoru authored
73
zhangxiaoru authored
74 75 76 77 78 79 80 81 82 83 84 85 86
        if (opt === 'ok') {
            param = {
                id: id,
                uid: uid,
                type: 'brand'
            };
        } else {
            param = {
                fav_id: id,
                uid: uid,
                type: 'brand'
            };
        }
zhangxiaoru authored
87
zhangxiaoru authored
88
zhangxiaoru authored
89
        if (opt === 'ok') {
zhangxiaoru authored
90 91 92 93 94
            return this.get({
                url: 'app.favorite.add',
                data: param,
                api: global.yoho.API
            });
zhangxiaoru authored
95
        } else {
zhangxiaoru authored
96 97 98 99 100
            return this.get({
                url: 'app.favorite.cancel',
                data: param,
                api: global.yoho.API
            });
zhangxiaoru authored
101
        }
zhangxiaoru authored
102 103
    }
};