| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /**
- * 订单「去加餐」:携带桌台主键跳转点餐页,与 pages/orderInfo/index 列表逻辑一致。
- */
- import { go } from '@/utils/utils.js';
- const STORAGE_STORE_ID = 'currentStoreId';
- const STORAGE_TABLE_ID = 'currentTableId';
- /**
- * @param {object} order 订单对象(列表项或详情 orderDetail)
- */
- export function navigateToAddFood(order) {
- let tableid =
- order?.tableId ??
- order?.storeTableId ??
- order?.diningTableId ??
- '';
- let tid = tableid != null && tableid !== '' ? String(tableid).trim() : '';
- // 详情接口可能只回展示桌号、不回主键;与当前点餐桌一致时用本地桌台主键兜底
- if (!tid) {
- const cached = uni.getStorageSync(STORAGE_TABLE_ID);
- if (cached != null && String(cached).trim() !== '') {
- tid = String(cached).trim();
- }
- }
- if (!tid) {
- uni.showToast({ title: '订单缺少桌台信息,无法加餐', icon: 'none' });
- return;
- }
- const diners = order?.dinerCount ?? order?.diners ?? uni.getStorageSync('currentDiners') ?? '';
- const storeId = order?.storeId ?? '';
- if (storeId !== '' && storeId != null) {
- uni.setStorageSync(STORAGE_STORE_ID, String(storeId));
- }
- uni.setStorageSync(STORAGE_TABLE_ID, tid);
- const q = [
- `tableid=${encodeURIComponent(tid)}`,
- `tableId=${encodeURIComponent(tid)}`
- ];
- if (diners !== '' && diners != null) q.push(`diners=${encodeURIComponent(String(diners))}`);
- if (storeId !== '' && storeId != null) q.push(`storeId=${encodeURIComponent(String(storeId))}`);
- go(`/pages/orderFood/index?${q.join('&')}`, 'redirectTo');
- }
|