From c3591f90b1fe66d376e6227897991b0ff1b24627 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Sat, 12 Oct 2024 18:14:24 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=E7=A1=AE?=
=?UTF-8?q?=E8=AE=A4=E8=AE=A2=E5=8D=95=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../confirm-order/confirm-order.vue | 2 +-
pagesCreateOrder/util.js | 33 +++++++++++++++----
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/pagesCreateOrder/confirm-order/confirm-order.vue b/pagesCreateOrder/confirm-order/confirm-order.vue
index cf36655..ed2bd6b 100644
--- a/pagesCreateOrder/confirm-order/confirm-order.vue
+++ b/pagesCreateOrder/confirm-order/confirm-order.vue
@@ -183,7 +183,7 @@
-
+
diff --git a/pagesCreateOrder/util.js b/pagesCreateOrder/util.js
index cf8c381..92e5471 100644
--- a/pagesCreateOrder/util.js
+++ b/pagesCreateOrder/util.js
@@ -5,12 +5,31 @@ import {
export function getNowCart(records) {
const nowCart = records.find(v => v.placeNum == 0)
const Cart = nowCart ? nowCart.info : []
- const result = Cart.map(item => {
- return {
- ...item,
- isPack: returnBoolean(item.isPack),
- isGift: returnBoolean(item.isGift)
+ const goodsMap = {}
+ const arr = []
+ for (let i in Cart) {
+ const item=Cart[i]
+ const key = item.productId + '_' + item.skuId
+ if (goodsMap.hasOwnProperty(key)) {
+ const index = goodsMap[key]
+ arr[index].number = arr[index].number * 1 + item.number
+ arr[index].totalNumber = arr[index].totalNumber * 1 + item.totalNumber
+ arr[index].totalAmount = arr[index].totalAmount * 1 + item.totalAmount
+ } else {
+ arr.push({
+ ...item,
+ isPack: returnBoolean(item.isPack),
+ isGift: returnBoolean(item.isGift)
+ })
+ goodsMap[key] = arr.length - 1;
}
- })
- return result
+ }
+ // const result = Cart.map(item => {
+ // return {
+ // ...item,
+ // isPack: returnBoolean(item.isPack),
+ // isGift: returnBoolean(item.isGift)
+ // }
+ // })
+ return arr
}
\ No newline at end of file