|
@@ -259,15 +259,72 @@ const filterCartData = (result, uid) => { |
|
@@ -259,15 +259,72 @@ const filterCartData = (result, uid) => { |
259
|
selectedNum: selectedAdvanceNum + selectedOrdinaryNum,
|
259
|
selectedNum: selectedAdvanceNum + selectedOrdinaryNum,
|
260
|
checkAll: totalNum === (selectedAdvanceNum + selectedOrdinaryNum),
|
260
|
checkAll: totalNum === (selectedAdvanceNum + selectedOrdinaryNum),
|
261
|
totalMoney: totalAdvanceMoney + totalOrdinaryMoney
|
261
|
totalMoney: totalAdvanceMoney + totalOrdinaryMoney
|
262
|
-
|
262
|
+
|
263
|
});
|
263
|
});
|
264
|
};
|
264
|
};
|
265
|
|
265
|
|
|
|
266
|
+/**
|
|
|
267
|
+ * 增减购物车商品数量
|
|
|
268
|
+ * @function modifyProductNum
|
|
|
269
|
+ * @param { Number } uid 用户ID
|
|
|
270
|
+ * @param { String } sku 商品SKU
|
|
|
271
|
+ * @param { Number } increaseNum 增加的数目
|
|
|
272
|
+ * @param { Number } decreaseNum 减少的数目
|
|
|
273
|
+ * @param { String } shoppingKey 未登录用户唯一识别码
|
|
|
274
|
+ * @return { Array } 接口返回的数据
|
|
|
275
|
+ */
|
|
|
276
|
+const modifyProductNum = (options) => {
|
|
|
277
|
+ const increaseNum = options.increaseNum;
|
|
|
278
|
+ const decreaseNum = options.decreaseNum;
|
|
|
279
|
+ const uid = options.uid;
|
|
|
280
|
+ const shoppingKey = options.shoppingKey;
|
|
|
281
|
+ const sku = options.sku;
|
|
|
282
|
+
|
|
|
283
|
+ let params = {
|
|
|
284
|
+ product_sku: options.sku
|
|
|
285
|
+ }
|
|
|
286
|
+
|
|
|
287
|
+ // 增加
|
|
|
288
|
+ if(increaseNum) {
|
|
|
289
|
+ _.merge(params, {
|
|
|
290
|
+ method: 'app.Shopping.increase',
|
|
|
291
|
+ increase_number: parseInt(increaseNum, 10)
|
|
|
292
|
+ });
|
|
|
293
|
+ }
|
|
|
294
|
+
|
|
|
295
|
+ // 减少
|
|
|
296
|
+ if(decreaseNum) {
|
|
|
297
|
+ _.merge(params, {
|
|
|
298
|
+ method: 'app.Shopping.decrease',
|
|
|
299
|
+ decrease_number: parseInt(decreaseNum, 10)
|
|
|
300
|
+ });
|
|
|
301
|
+ }
|
|
|
302
|
+
|
|
|
303
|
+ if(uid) {
|
|
|
304
|
+ _.merge(params, {uid});
|
|
|
305
|
+ }
|
|
|
306
|
+
|
|
|
307
|
+ if(shoppingKey) {
|
|
|
308
|
+ _.merge(params, {
|
|
|
309
|
+ shopping_key: shoppingKey
|
|
|
310
|
+ });
|
|
|
311
|
+ }
|
|
|
312
|
+
|
|
|
313
|
+ if(sku) {
|
|
|
314
|
+ _.merge(params, {
|
|
|
315
|
+ product_sku: sku
|
|
|
316
|
+ });
|
|
|
317
|
+ }
|
|
|
318
|
+
|
|
|
319
|
+ return api.get('', params);
|
|
|
320
|
+}
|
|
|
321
|
+
|
266
|
module.exports = {
|
322
|
module.exports = {
|
267
|
addToCart,
|
323
|
addToCart,
|
268
|
getCartData,
|
324
|
getCartData,
|
269
|
transferToFavorite,
|
325
|
transferToFavorite,
|
270
|
toggleSelectGoods,
|
326
|
toggleSelectGoods,
|
271
|
removeGoods,
|
327
|
removeGoods,
|
272
|
- filterCartData
|
328
|
+ filterCartData,
|
|
|
329
|
+ modifyProductNum
|
273
|
}; |
330
|
}; |