|
@@ -9,6 +9,7 @@
|
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
|
import * as diningApi from '@/api/dining.js';
|
|
import * as diningApi from '@/api/dining.js';
|
|
|
import { useUserStore } from '@/store/user.js';
|
|
import { useUserStore } from '@/store/user.js';
|
|
|
|
|
+import { TOKEN } from '@/settings/enums.js';
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
|
const userStore = useUserStore();
|
|
|
|
|
|
|
@@ -21,27 +22,30 @@ async function doRedirect() {
|
|
|
try {
|
|
try {
|
|
|
const res = await diningApi.GetTableDiningStatus(tableid);
|
|
const res = await diningApi.GetTableDiningStatus(tableid);
|
|
|
const raw = (res && typeof res === 'object') ? res : {};
|
|
const raw = (res && typeof res === 'object') ? res : {};
|
|
|
|
|
+ // 兼容多种返回:{ inDining: true }、{ data: { inDining: true } }、直接返回 true
|
|
|
const inDining =
|
|
const inDining =
|
|
|
|
|
+ res === true ||
|
|
|
|
|
+ res === 'true' ||
|
|
|
raw?.inDining === true ||
|
|
raw?.inDining === true ||
|
|
|
raw?.inDining === 'true' ||
|
|
raw?.inDining === 'true' ||
|
|
|
raw?.data?.inDining === true ||
|
|
raw?.data?.inDining === true ||
|
|
|
raw?.data?.inDining === 'true';
|
|
raw?.data?.inDining === 'true';
|
|
|
|
|
+ const token = userStore.getToken || uni.getStorageSync(TOKEN) || '';
|
|
|
const dinerCount =
|
|
const dinerCount =
|
|
|
raw?.dinerCount ?? raw?.diner ?? raw?.data?.dinerCount ?? raw?.data?.diner ?? uni.getStorageSync('currentDiners') ?? 1;
|
|
raw?.dinerCount ?? raw?.diner ?? raw?.data?.dinerCount ?? raw?.data?.diner ?? uni.getStorageSync('currentDiners') ?? 1;
|
|
|
if (inDining) {
|
|
if (inDining) {
|
|
|
- uni.setStorageSync('currentDiners', dinerCount);
|
|
|
|
|
- if (!userStore.getToken) {
|
|
|
|
|
- uni.reLaunch({
|
|
|
|
|
- url: `/pages/numberOfDiners/index?inDining=1&tableid=${encodeURIComponent(tableid)}&diners=${encodeURIComponent(dinerCount)}`
|
|
|
|
|
- });
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ uni.setStorageSync('currentDiners', dinerCount);
|
|
|
uni.reLaunch({
|
|
uni.reLaunch({
|
|
|
url: `/pages/orderFood/index?tableid=${encodeURIComponent(tableid)}&diners=${encodeURIComponent(dinerCount)}`
|
|
url: `/pages/orderFood/index?tableid=${encodeURIComponent(tableid)}&diners=${encodeURIComponent(dinerCount)}`
|
|
|
});
|
|
});
|
|
|
- return;
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- uni.reLaunch({ url: '/pages/numberOfDiners/index' });
|
|
|
|
|
|
|
+ else{
|
|
|
|
|
+ uni.reLaunch({
|
|
|
|
|
+ url: `/pages/numberOfDiners/index?inDining=1&tableid=${encodeURIComponent(tableid)}&diners=${encodeURIComponent(dinerCount)}`
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
console.warn('查询桌位就餐状态失败,进入选择人数页', err);
|
|
console.warn('查询桌位就餐状态失败,进入选择人数页', err);
|
|
|
uni.reLaunch({ url: '/pages/numberOfDiners/index' });
|
|
uni.reLaunch({ url: '/pages/numberOfDiners/index' });
|