Browse Source

调试用餐

sunshibo 1 month ago
parent
commit
4553663c36
2 changed files with 26 additions and 3 deletions
  1. 7 0
      api/dining.js
  2. 19 3
      pages/numberOfDiners/index.vue

+ 7 - 0
api/dining.js

@@ -45,6 +45,13 @@ export const uploadFileToSever = uploadFileToServerImpl; // 兼容拼写错误
 // 点餐页数据(入参 dinerCount 就餐人数、tableId 桌号)
 export const DiningOrderFood = (params) => api.get({ url: '/store/dining/page-info', params });
 
+// 查询桌位是否已选就餐人数(GET /dining/table-dining-status?tableId=xxx)
+export const GetTableDiningStatus = (tableId) =>
+  api.get({
+    url: '/store/dining/table-dining-status',
+    params: { tableId: tableId != null && tableId !== '' ? String(tableId) : '' }
+  });
+
 // 门店详情(GET /store/info/detail/{storeId},入参 storeId)
 export const GetStoreDetail = (storeId) =>
   api.get({ url: `/store/info/detail/${encodeURIComponent(storeId)}` });

+ 19 - 3
pages/numberOfDiners/index.vue

@@ -26,6 +26,7 @@ import { ref } from "vue";
 import { go } from "@/utils/utils.js";
 import { useUserStore } from "@/store/user.js";
 import LoginModal from "@/pages/components/LoginModal.vue";
+import * as diningApi from "@/api/dining.js";
 
 const userStore = useUserStore();
 const diners = ref(12);
@@ -73,9 +74,24 @@ uni.reLaunch({
 });
 }
 
-onLoad((e) => {
-  // let currentDiners = uni.getStorageSync('currentDiners');
-  // if (currentDiners) currentDiners.value = currentDiners;
+onLoad(async (e) => {
+  const tableid = uni.getStorageSync('currentTableId') || '';
+  if (!tableid) return;
+  try {
+    const res = await diningApi.GetTableDiningStatus(tableid);
+    const raw = (res && typeof res === 'object') ? res : {};
+    const inDining = raw?.inDining === true;
+    const dinerCount = raw?.dinerCount ?? raw?.diner ?? uni.getStorageSync('currentDiners') ?? 1;
+    if (inDining) {
+      uni.setStorageSync('currentDiners', dinerCount);
+      uni.reLaunch({
+        url: `/pages/orderFood/index?tableid=${encodeURIComponent(tableid)}&diners=${encodeURIComponent(dinerCount)}`
+      });
+      return;
+    }
+  } catch (err) {
+    console.warn('查询桌位就餐状态失败,按正常流程', err);
+  }
 });
 </script>