|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<!-- 点餐页 -->
|
|
|
<view class="content">
|
|
|
- <view class="top-info">桌号:{{ tableId || '—' }} 就餐人数:{{ currentDiners }}人</view>
|
|
|
+ <view class="top-info">桌号:{{ displayTableNumber }} 就餐人数:{{ currentDiners }}人</view>
|
|
|
<!-- 搜索 -->
|
|
|
<input type="text" placeholder="请输入菜品名称" class="search-input" />
|
|
|
|
|
|
@@ -54,8 +54,17 @@ import { go } from "@/utils/utils.js";
|
|
|
import { DiningOrderFood, GetStoreCategories, GetStoreCuisines, getOrderSseConfig, GetOrderCart, PostOrderCartAdd, PostOrderCartUpdate, PostOrderCartClear } from "@/api/dining.js";
|
|
|
import { createSSEConnection } from "@/utils/sse.js";
|
|
|
|
|
|
-const tableId = ref(''); // 桌号,来自上一页 url 参数 tableid
|
|
|
+const tableId = ref(''); // 桌号ID,来自上一页 url 参数 tableid,用于接口入参
|
|
|
+const tableNumber = ref(''); // 桌号展示,来自 dining/page-info 接口返回的 tableNumber
|
|
|
+const tableNumberFetched = ref(false); // 是否已请求过桌号(避免未返回前用 tableId 展示导致闪一下 43)
|
|
|
const currentDiners = ref(uni.getStorageSync('currentDiners') || '');
|
|
|
+
|
|
|
+// 桌号展示:优先用接口返回的 tableNumber,未请求完前不显示 tableId,避免闪 43 再变 2
|
|
|
+const displayTableNumber = computed(() => {
|
|
|
+ if (tableNumber.value) return tableNumber.value;
|
|
|
+ if (tableNumberFetched.value && tableId.value) return tableId.value;
|
|
|
+ return '—';
|
|
|
+});
|
|
|
let sseRequestTask = null; // 订单 SSE 连接(封装后兼容小程序),页面卸载时需 abort()
|
|
|
const currentCategoryIndex = ref(0);
|
|
|
const couponModalOpen = ref(false);
|
|
|
@@ -504,11 +513,13 @@ const handleOrderClick = () => {
|
|
|
totalAmount: displayTotalAmount.value,
|
|
|
totalQuantity: displayTotalQuantity.value,
|
|
|
tableId: tableId.value,
|
|
|
+ tableNumber: tableNumber.value,
|
|
|
diners: currentDiners.value
|
|
|
};
|
|
|
uni.setStorageSync('placeOrderCart', JSON.stringify(cartPayload));
|
|
|
const query = [];
|
|
|
if (tableId.value) query.push(`tableId=${encodeURIComponent(tableId.value)}`);
|
|
|
+ if (tableNumber.value) query.push(`tableNumber=${encodeURIComponent(tableNumber.value)}`);
|
|
|
if (currentDiners.value) query.push(`diners=${encodeURIComponent(currentDiners.value)}`);
|
|
|
go(query.length ? `/pages/placeOrder/index?${query.join('&')}` : '/pages/placeOrder/index');
|
|
|
};
|
|
|
@@ -569,8 +580,12 @@ onLoad(async (options) => {
|
|
|
});
|
|
|
console.log('点餐页接口返回:', res);
|
|
|
|
|
|
+ const data = res?.data ?? res ?? {};
|
|
|
+ tableNumber.value = data?.tableNumber ?? data?.tableNo ?? '';
|
|
|
+ tableNumberFetched.value = true;
|
|
|
+
|
|
|
// 成功后调接口获取菜品种类(storeId 取自点餐页接口返回,若无则需从别处获取)
|
|
|
- const storeId = res?.storeId ?? res?.data?.storeId ?? '';
|
|
|
+ const storeId = res?.storeId ?? data?.storeId ?? '';
|
|
|
if (storeId) uni.setStorageSync('currentStoreId', storeId);
|
|
|
if (storeId) {
|
|
|
try {
|
|
|
@@ -600,7 +615,10 @@ onLoad(async (options) => {
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.error('点餐页接口失败:', e);
|
|
|
+ tableNumberFetched.value = true;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ tableNumberFetched.value = true;
|
|
|
}
|
|
|
});
|
|
|
|