import { returnBoolean } from '@/commons/utils/format.js'; // 返回购物车未下单的数据 export function getNowCart(records) { const nowCart = records.find(v => v.placeNum == 0) const Cart = nowCart ? nowCart.info : [] 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 arr[index].packFee = arr[index].packFee * 1 + item.packFee } else { arr.push({ ...item, isPack: returnBoolean(item.isPack), isGift: returnBoolean(item.isGift) }) goodsMap[key] = arr.length - 1; } } // const result = Cart.map(item => { // return { // ...item, // isPack: returnBoolean(item.isPack), // isGift: returnBoolean(item.isGift) // } // }) return arr }