修复库存回显问题,修复多次加菜弹窗问题

This commit is contained in:
2026-04-13 18:12:46 +08:00
parent 2db9f6811a
commit dbe74f6486
8 changed files with 92 additions and 81 deletions

View File

@@ -407,9 +407,9 @@
initCart();
}
const allHistoryOrder=ref([])
const allHistoryOrder = ref([])
/**
* 获取订单详情
*/
@@ -432,7 +432,7 @@
console.log("data.historyOrder===", data.historyOrder);
allHistoryOrder.value = data.historyOrder.map((item) => {
allHistoryOrder.value = data.historyOrder.map((item) => {
return [...item.info];
}).flat();
@@ -838,29 +838,34 @@
//更新
let cartItem = cars[goodsInCarIndex];
let number = isAdd ? cartItem.number + 1 : +cartItem.number - 1;
if(isAdd){
if (number == 2 ) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'购物车已有该商品,请确认是否重复',
'菜名名称:《' + $goods.name + '》'
);
if (!isConfirm) {
return
}
}
if(allHistoryOrder.value.find(v=>v.productId==$goods.id)){
if (isAdd) {
if (allHistoryOrder.value.find(v => v.productId == $goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜名称:《' + $goods.name + '》'
'菜名称:《' + $goods.name + '》'
);
if (!isConfirm) {
return
}
}else{
if (number == 2) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'购物车已有该商品,请确认是否重复',
'菜品名称:《' + $goods.name + '》'
);
if (!isConfirm) {
return
}
}
}
}
if (!isAdd) {
if (number === 0 || number < suitNum) {
//移除
@@ -889,7 +894,7 @@
data.isGoodsAdd = false;
setSearchGoods(searchGoodsIndex, number);
} else {
// 不影响之前的代码 称重suit单独处理
if ($goods.type == "weight" && showCurrentInput) {
suitNum = showCurrentInput;
@@ -901,11 +906,11 @@
return;
}
}
if(allHistoryOrder.value.find(v=>v.productId==$goods.id)){
if (allHistoryOrder.value.find(v => v.productId == $goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜名称:《' + $goods.name + '》'
'菜名称:《' + $goods.name + '》'
);
if (!isConfirm) {
return
@@ -1144,28 +1149,27 @@
let cartId = carGoods.id;
let suitNum = goods.skuList[0].suitNum || 1;
let newNumber = carGoods.number * 1 + suitNum;
if (newNumber == 2&&carGoods.number<newNumber) {
if (allHistoryOrder.value.find(v => v.productId == goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'请确认当前菜品是否已上菜?',
'菜名名称' + goods.name + ''
'该商品已下单过,请确认是否重复',
'菜品名称:《' + goods.name + '》'
);
if (!isConfirm) {
return
}
if(allHistoryOrder.value.find(v=>v.productId==goods.id)){
}else{
if (newNumber == 2 && carGoods.number < newNumber) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜名称:《' + goods.name + '》'
'购物车已有该商品,请确认是否重复?',
'菜名称:《' + goods.name + '》'
);
if (!isConfirm) {
return
}
}
}
editCart({
id: cartId,
@@ -1181,12 +1185,12 @@
);
data.isGoodsAdd = false;
} else {
if(allHistoryOrder.value.find(v=>v.productId==goods.id)){
if (allHistoryOrder.value.find(v => v.productId == goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜名称:《' + goods.name + '》'
'菜名称:《' + goods.name + '》'
);
if (!isConfirm) {
return