修复清空历史订单时消失又出现问题
This commit is contained in:
@@ -850,6 +850,11 @@ export const useCartsStore = defineStore("carts", () => {
|
||||
|
||||
let $initParams = {} as ApifoxModel;
|
||||
|
||||
|
||||
// 标志位,表示是否正在清空历史订单
|
||||
const isClearingOldOrder = ref(false);
|
||||
|
||||
|
||||
async function init(initParams: ApifoxModel | undefined, $oldOrder: any | undefined) {
|
||||
console.log('cart.init.initParams', initParams);
|
||||
console.log('cart.init.$oldOrder', $oldOrder);
|
||||
@@ -990,8 +995,15 @@ export const useCartsStore = defineStore("carts", () => {
|
||||
concocatSocket({ ...$initParams, table_code: table_code.value });
|
||||
}
|
||||
|
||||
// WebSocket 监听 product_update 消息
|
||||
if (msg.operate_type === "product_update") {
|
||||
init($initParams, oldOrder.value,);
|
||||
if (isClearingOldOrder.value) {
|
||||
console.log("忽略 product_update 消息,因为正在清空历史订单");
|
||||
isClearingOldOrder.value = false; // 重置标志位
|
||||
return;
|
||||
}
|
||||
console.log("处理 product_update 消息");
|
||||
init($initParams, oldOrder.value); // 重新初始化
|
||||
}
|
||||
|
||||
if (msg.type === "bc") {
|
||||
@@ -1036,6 +1048,8 @@ export const useCartsStore = defineStore("carts", () => {
|
||||
newUserDiscount.value = {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return {
|
||||
disconnect,
|
||||
dinnerType,
|
||||
@@ -1097,7 +1111,7 @@ export const useCartsStore = defineStore("carts", () => {
|
||||
getAllGoodsList,
|
||||
vipUser,
|
||||
changeTableInfo,
|
||||
tableInfo,
|
||||
tableInfo, isClearingOldOrder,
|
||||
clearHistory
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user