代码更新

This commit is contained in:
GaoHao
2025-02-26 19:46:20 +08:00
parent 7519ffced3
commit b4a0393d2d
413 changed files with 7483 additions and 60762 deletions

View File

@@ -1,39 +1,27 @@
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 = {}
export function getNowCart(carItem,goodsList) {
// console.log("carItem===",carItem)
// console.log("goodsList===",goodsList)
// const nowCart = records.find(v => v.placeNum == 0)
const arr = []
for (let i in Cart) {
const item=Cart[i]
const productId=item.productId
const skuId=item.skuId
const isLinShiCai=!productId&&!skuId?true:false
const key =isLinShiCai?item.name: (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;
}
if( carItem.is_temporary != 1 ){
goodsList.map(goodsItem => {
if(carItem.product_id == goodsItem.id){
carItem.lowPrice = goodsItem.lowPrice
carItem.lowMemberPrice = goodsItem.lowMemberPrice
carItem.name = goodsItem.name
carItem.coverImg = goodsItem.coverImg
carItem.packFee = goodsItem.packFee
}
})
carItem.number = parseFloat(carItem.number)
} else {
// 临时菜
carItem.number = parseFloat(carItem.number)
carItem.name = carItem.product_name
carItem.lowPrice = carItem.discount_sale_amount
}
// const result = Cart.map(item => {
// return {
// ...item,
// isPack: returnBoolean(item.isPack),
// isGift: returnBoolean(item.isGift)
// }
// })
return arr
return carItem
}