...
|
...
|
@@ -263,11 +263,68 @@ const filterCartData = (result, uid) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 增减购物车商品数量
|
|
|
* @function modifyProductNum
|
|
|
* @param { Number } uid 用户ID
|
|
|
* @param { String } sku 商品SKU
|
|
|
* @param { Number } increaseNum 增加的数目
|
|
|
* @param { Number } decreaseNum 减少的数目
|
|
|
* @param { String } shoppingKey 未登录用户唯一识别码
|
|
|
* @return { Array } 接口返回的数据
|
|
|
*/
|
|
|
const modifyProductNum = (options) => {
|
|
|
const increaseNum = options.increaseNum;
|
|
|
const decreaseNum = options.decreaseNum;
|
|
|
const uid = options.uid;
|
|
|
const shoppingKey = options.shoppingKey;
|
|
|
const sku = options.sku;
|
|
|
|
|
|
let params = {
|
|
|
product_sku: options.sku
|
|
|
}
|
|
|
|
|
|
// 增加
|
|
|
if(increaseNum) {
|
|
|
_.merge(params, {
|
|
|
method: 'app.Shopping.increase',
|
|
|
increase_number: parseInt(increaseNum, 10)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 减少
|
|
|
if(decreaseNum) {
|
|
|
_.merge(params, {
|
|
|
method: 'app.Shopping.decrease',
|
|
|
decrease_number: parseInt(decreaseNum, 10)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if(uid) {
|
|
|
_.merge(params, {uid});
|
|
|
}
|
|
|
|
|
|
if(shoppingKey) {
|
|
|
_.merge(params, {
|
|
|
shopping_key: shoppingKey
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if(sku) {
|
|
|
_.merge(params, {
|
|
|
product_sku: sku
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return api.get('', params);
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
|
addToCart,
|
|
|
getCartData,
|
|
|
transferToFavorite,
|
|
|
toggleSelectGoods,
|
|
|
removeGoods,
|
|
|
filterCartData
|
|
|
filterCartData,
|
|
|
modifyProductNum
|
|
|
}; |
...
|
...
|
|