|
|
@@ -2,8 +2,6 @@
|
|
|
import initConfig from '@/initConfig.js';
|
|
|
// #ifdef MP-WEIXIN
|
|
|
import { SCAN_QR_CACHE } from '@/settings/enums.js';
|
|
|
-import * as diningApi from '@/api/dining.js';
|
|
|
-import { useUserStore } from '@/store/user.js';
|
|
|
// #endif
|
|
|
|
|
|
/** 从 scene 或 query 中解析:二维码 s=店铺id,t=桌号id */
|
|
|
@@ -26,44 +24,6 @@ function parseSceneToStoreTable(sceneStr) {
|
|
|
return { storeId, tableId };
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 查询桌位就餐状态,若 inDining 为 true 则跳转点餐页或选择人数页(未登录时)
|
|
|
- * @param {Object} opts - { fromTabBar: boolean } 来自 TabBar 扫码时,inDining 为 false 需 switchTab 到 numberOfDiners
|
|
|
- */
|
|
|
-async function checkTableDiningStatus(opts = {}) {
|
|
|
- const tableid = uni.getStorageSync('currentTableId') || '';
|
|
|
-
|
|
|
- try {
|
|
|
- const res = await diningApi.GetTableDiningStatus(tableid);
|
|
|
- const raw = (res && typeof res === 'object') ? res : {};
|
|
|
- const inDining =
|
|
|
- raw?.inDining === true ||
|
|
|
- raw?.inDining === 'true' ||
|
|
|
- raw?.data?.inDining === true ||
|
|
|
- raw?.data?.inDining === 'true';
|
|
|
- const dinerCount =
|
|
|
- raw?.dinerCount ?? raw?.diner ?? raw?.data?.dinerCount ?? raw?.data?.diner ?? uni.getStorageSync('currentDiners') ?? 1;
|
|
|
- if (!inDining) {
|
|
|
- if (opts.fromTabBar) uni.switchTab({ url: '/pages/numberOfDiners/index' });
|
|
|
- return;
|
|
|
- }
|
|
|
- uni.setStorageSync('currentDiners', dinerCount);
|
|
|
- const userStore = useUserStore();
|
|
|
- if (!userStore.getToken) {
|
|
|
- uni.reLaunch({
|
|
|
- url: `/pages/numberOfDiners/index?inDining=1&tableid=${encodeURIComponent(tableid)}&diners=${encodeURIComponent(dinerCount)}`
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- uni.reLaunch({
|
|
|
- url: `/pages/orderFood/index?tableid=${encodeURIComponent(tableid)}&diners=${encodeURIComponent(dinerCount)}`
|
|
|
- });
|
|
|
- } catch (err) {
|
|
|
- console.warn('查询桌位就餐状态失败', err);
|
|
|
- if (opts.fromTabBar) uni.switchTab({ url: '/pages/numberOfDiners/index' });
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
export default {
|
|
|
onLaunch: function (e) {
|
|
|
// 只有小程序执行
|
|
|
@@ -86,8 +46,6 @@ export default {
|
|
|
} catch (err) {
|
|
|
console.warn('缓存二维码启动参数失败', err);
|
|
|
}
|
|
|
- // 冷启动时由 pages/launch/index 根据接口结果跳转;TabBar 扫码后由 App 统一调用接口并跳转
|
|
|
- uni.$on('checkTableDiningStatus', () => checkTableDiningStatus({ fromTabBar: true }));
|
|
|
// #endif
|
|
|
},
|
|
|
onShow: function (res) {
|