count.js 716 Bytes
'use strict';

class cartCountModel extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    cartCount(uid, shoppingKey) {
        let params = {
            method: 'app.Shopping.count'
        };

        if (!uid && !shoppingKey) {
            return Promise.resolve({});
        }

        if (uid) {
            Object.assign(params, {
                uid: uid
            });
        }

        if (shoppingKey) {
            Object.assign(params, {
                shopping_key: shoppingKey
            });
        }

        return this.get({
            data: params
        }).then((result) => {
            return result;
        });
    }
}

module.exports = cartCountModel;