代客下单确认订单更新

This commit is contained in:
2024-10-12 18:14:24 +08:00
parent b32a3a398b
commit c3591f90b1
2 changed files with 27 additions and 8 deletions

View File

@@ -183,7 +183,7 @@
<button class="tag" hover-class="hover-class" <button class="tag" hover-class="hover-class"
@tap="toggleGoodsItemKey(item,index,'isGift')">{{item.isGift?'取消赠送':'赠送'}}</button> @tap="toggleGoodsItemKey(item,index,'isGift')">{{item.isGift?'取消赠送':'赠送'}}</button>
</view> </view>
<view class="u-flex u-m-r-20 u-m-b-20" v-if="eatTypes.active!='takeout'"> <view class="u-flex u-m-r-20 u-m-b-20" >
<button class="tag" hover-class="hover-class" <button class="tag" hover-class="hover-class"
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button> @tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
</view> </view>

View File

@@ -5,12 +5,31 @@ import {
export function getNowCart(records) { export function getNowCart(records) {
const nowCart = records.find(v => v.placeNum == 0) const nowCart = records.find(v => v.placeNum == 0)
const Cart = nowCart ? nowCart.info : [] const Cart = nowCart ? nowCart.info : []
const result = Cart.map(item => { const goodsMap = {}
return { const arr = []
...item, for (let i in Cart) {
isPack: returnBoolean(item.isPack), const item=Cart[i]
isGift: returnBoolean(item.isGift) 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
} }