Blame view

apps/cart/models/count.js 546 Bytes
zhangxiaoru authored
1 2 3 4 5
'use strict';

const api = global.yoho.API;

const cartCount = (uid, shoppingKey) => {
郭成尧 authored
6 7 8
    let params = {
        method: 'app.Shopping.count'
    };
zhangxiaoru authored
9
郭成尧 authored
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    if (!uid && !shoppingKey) {
        return Promise.resolve({});
    }

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

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

    return api.get('', params).then((result) => {
zhangxiaoru authored
27 28 29 30 31
        return result;
    });
};

module.exports = {
zhangxiaoru authored
32 33
    cartCount
};