This commit is contained in:
duan
2025-09-29 10:42:48 +08:00
parent 89db955ec1
commit 096f591123
80 changed files with 8735 additions and 3286 deletions

View File

@@ -2,35 +2,77 @@ 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,user) {
// 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 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;
}
if( carItem.is_temporary != 1 ){
carItem.isGrounding = false;
goodsList.map(goodsItem => {
if(carItem.product_id == goodsItem.id){
goodsItem.skuList.map(item=>{
if(carItem.product_id == item.productId){
carItem.lowPrice = item.salePrice
carItem.lowMemberPrice = item.memberPrice
carItem.specInfo = item.specInfo
if( uni.getStorageSync('shopInfo').isMemberPrice && user && user.id && user.isVip ){
carItem.salePrice = item.memberPrice
} else {
carItem.salePrice = item.salePrice
}
}
})
carItem.name = goodsItem.name
carItem.coverImg = goodsItem.coverImg
carItem.packFee = goodsItem.packFee
carItem.type = goodsItem.type
carItem.isGrounding = true;
}
carItem.number = parseFloat(carItem.number)
})
} else {
// 临时菜
console.log(carItem,'salePrice1111111111')
carItem.number = parseFloat(carItem.number)
carItem.name = carItem.product_name
carItem.lowPrice = carItem.discount_sale_amount
carItem.discount_sale_amount = 0
}
// const result = Cart.map(item => {
// return {
// ...item,
// isPack: returnBoolean(item.isPack),
// isGift: returnBoolean(item.isGift)
// }
// })
return arr
}
return carItem
}
// 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
// }