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