fix: 代客下单增加转台功能,修复临时菜价格展示问题,增加就餐类型切换为打包时,加菜默认为打包

This commit is contained in:
2025-03-13 18:31:36 +08:00
parent dc5dc45893
commit a3f8c8c012
11 changed files with 268 additions and 52 deletions

View File

@@ -1,6 +1,6 @@
import qs from "qs";
import { useUserStoreHook } from "@/store";
import { ElMessage, ElMessageBox } from "element-plus";
const user = useUserStoreHook()
export interface ApifoxModel {
@@ -20,7 +20,7 @@ export interface ApifoxModel {
type: string;
[property: string]: any;
}
export type msgType = 'add' | 'reduce' | 'remove' | 'edit' | 'init' | 'cleanup' | 'del' | 'rottable'
export type msgType = 'add' | 'reduce' | 'remove' | 'edit' | 'init' | 'cleanup' | 'del' | 'rottable' | 'batch'
class WebSocketManager {
private client: WebSocket | null = null;
private connected: boolean = false;
@@ -80,6 +80,7 @@ class WebSocketManager {
};
this.client.onerror = (error) => {
clearTimeout(this.timer)
this.connected = false;
console.error("WebSocket 发生错误:", error);
// ElNotification({
// title: "提示",
@@ -112,7 +113,7 @@ class WebSocketManager {
// 订阅主题
public subscribeToTopic(initParams: ApifoxModel, onMessage: (message: any) => void) {
console.log(`正在订阅主题: `);
console.log(`正在订阅主题: `, initParams);
this.initParams = { ...this.initParams, ...initParams }
if (this.client && this.connected) {
this.disconnect();
@@ -121,7 +122,13 @@ class WebSocketManager {
this.onMessage = onMessage;
}
public sendMessage(message: any) {
if (this.client) {
if (!this.client || !this.connected) {
ElMessage.error('发送失败,已重新连接,请重新操作')
this.disconnect()
this.setupWebSocket();
return
}
if (this.client && this.connected) {
const msg = JSON.stringify({
...this.initParams,
...message,
@@ -130,6 +137,7 @@ class WebSocketManager {
this.client.send(msg);
} catch (error) {
console.log('error')
ElMessage.error('发送失败')
this.disconnect()
this.setupWebSocket();
@@ -146,6 +154,7 @@ class WebSocketManager {
console.log("断开 WebSocket 连接");
this.client.close();
this.client = null;
this.connected = false;
}
}
}