@pisell/private-materials 6.3.139 → 6.3.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +5 -5
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +7 -7
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +6 -6
  11. package/es/components/scanOrder/components/Cart/index.js +127 -56
  12. package/es/components/scanOrder/components/Cart/index.less +11 -5
  13. package/es/components/scanOrder/components/Check/index.js +85 -80
  14. package/es/components/scanOrder/components/Content/index.js +345 -162
  15. package/es/components/scanOrder/components/Menu/index.d.ts +11 -0
  16. package/es/components/scanOrder/components/Menu/index.js +140 -169
  17. package/es/components/scanOrder/components/Voucher/index.d.ts +8 -0
  18. package/es/components/scanOrder/components/Voucher/index.js +250 -0
  19. package/es/components/scanOrder/context.js +38 -13
  20. package/es/components/scanOrder/hooks.js +4 -1
  21. package/es/components/scanOrder/locales.d.ts +65 -0
  22. package/es/components/scanOrder/locales.js +65 -0
  23. package/es/components/scanOrder/types.d.ts +10 -0
  24. package/es/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
  25. package/es/components/scanOrder/utils/toShoppingCartProducts.js +137 -9
  26. package/es/components/scanOrder/utils/transformProductDetail.js +21 -4
  27. package/es/components/venueBooking/components/Addons/index.js +42 -33
  28. package/es/components/venueBooking/components/Cart/index.js +26 -14
  29. package/lib/components/scanOrder/components/Cart/index.js +79 -24
  30. package/lib/components/scanOrder/components/Cart/index.less +11 -5
  31. package/lib/components/scanOrder/components/Check/index.js +28 -23
  32. package/lib/components/scanOrder/components/Content/index.js +132 -42
  33. package/lib/components/scanOrder/components/Menu/index.d.ts +11 -0
  34. package/lib/components/scanOrder/components/Menu/index.js +23 -36
  35. package/lib/components/scanOrder/components/Voucher/index.d.ts +8 -0
  36. package/lib/components/scanOrder/components/Voucher/index.js +162 -0
  37. package/lib/components/scanOrder/context.js +21 -10
  38. package/lib/components/scanOrder/hooks.js +4 -1
  39. package/lib/components/scanOrder/locales.d.ts +65 -0
  40. package/lib/components/scanOrder/locales.js +65 -0
  41. package/lib/components/scanOrder/types.d.ts +10 -0
  42. package/lib/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
  43. package/lib/components/scanOrder/utils/toShoppingCartProducts.js +88 -6
  44. package/lib/components/scanOrder/utils/transformProductDetail.js +10 -3
  45. package/lib/components/venueBooking/components/Addons/index.js +15 -8
  46. package/lib/components/venueBooking/components/Cart/index.js +8 -2
  47. package/package.json +1 -1
@@ -9,7 +9,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
9
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
11
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
- import React, { useEffect, useMemo, useRef, useState } from 'react';
12
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
13
  import { isMobile, locales } from '@pisell/utils';
14
14
  import { message, Modal } from 'antd';
15
15
  import { Button, PisellModal } from '@pisell/materials';
@@ -78,7 +78,9 @@ function ReadyState() {
78
78
  scanOrderModule = _useScanOrderContext.scanOrderModule,
79
79
  isCacheHydrated = _useScanOrderContext.isCacheHydrated,
80
80
  markGate = _useScanOrderContext.markGate,
81
- isGatePassed = _useScanOrderContext.isGatePassed;
81
+ isGatePassed = _useScanOrderContext.isGatePassed,
82
+ resumeStep = _useScanOrderContext.resumeStep,
83
+ consumeResumeStep = _useScanOrderContext.consumeResumeStep;
82
84
  var _useScanOrderLogin = useScanOrderLogin(),
83
85
  isLogin = _useScanOrderLogin.isLogin,
84
86
  openLoginModal = _useScanOrderLogin.openLoginModal;
@@ -111,20 +113,122 @@ function ReadyState() {
111
113
  _useState8 = _slicedToArray(_useState7, 2),
112
114
  pendingFormPayload = _useState8[0],
113
115
  setPendingFormPayload = _useState8[1];
116
+
117
+ /**
118
+ * 商品列表状态:挂在 ReadyState 而不是 Menu 本地,保证从 check 返回 product 时命中缓存、不重发请求
119
+ * (stepRegistry 切换会让 Menu unmount,本地 useState 会丢;ReadyState 在整段会话内不 unmount)
120
+ * - productListLoadedRef:同步判定是否已有有效结果,避免 setState 异步窗口内重复请求
121
+ * - productListPromiseRef:in-flight promise 去重,让并发调用合并成同一次请求
122
+ */
123
+ var _useState9 = useState([]),
124
+ _useState10 = _slicedToArray(_useState9, 2),
125
+ productList = _useState10[0],
126
+ setProductList = _useState10[1];
127
+ var productListLoadedRef = useRef(false);
128
+ var productListPromiseRef = useRef(null);
129
+ var ensureProductListLoaded = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
130
+ var request;
131
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
132
+ while (1) switch (_context2.prev = _context2.next) {
133
+ case 0:
134
+ if (!productListLoadedRef.current) {
135
+ _context2.next = 2;
136
+ break;
137
+ }
138
+ return _context2.abrupt("return");
139
+ case 2:
140
+ if (!productListPromiseRef.current) {
141
+ _context2.next = 6;
142
+ break;
143
+ }
144
+ _context2.next = 5;
145
+ return productListPromiseRef.current.catch(function () {});
146
+ case 5:
147
+ return _context2.abrupt("return");
148
+ case 6:
149
+ request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
150
+ var res;
151
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
152
+ while (1) switch (_context.prev = _context.next) {
153
+ case 0:
154
+ _context.prev = 0;
155
+ _context.next = 3;
156
+ return runModuleAction('getProductList');
157
+ case 3:
158
+ res = _context.sent;
159
+ if (!Array.isArray(res)) {
160
+ _context.next = 8;
161
+ break;
162
+ }
163
+ productListLoadedRef.current = true;
164
+ setProductList(res);
165
+ return _context.abrupt("return");
166
+ case 8:
167
+ // 非数组错误载荷:沿用原 Menu 内的 Modal.confirm + 跳首页逻辑
168
+ Modal.confirm({
169
+ title: res === null || res === void 0 ? void 0 : res.message,
170
+ okText: String(locales.getText('pisell2.event.confirm') || 'OK'),
171
+ cancelButtonProps: {
172
+ style: {
173
+ display: 'none'
174
+ }
175
+ },
176
+ maskClosable: false,
177
+ onOk: function onOk() {
178
+ location.replace('/');
179
+ }
180
+ });
181
+ _context.next = 14;
182
+ break;
183
+ case 11:
184
+ _context.prev = 11;
185
+ _context.t0 = _context["catch"](0);
186
+ console.warn('[scanOrder] getProductList failed', _context.t0);
187
+ case 14:
188
+ _context.prev = 14;
189
+ productListPromiseRef.current = null;
190
+ return _context.finish(14);
191
+ case 17:
192
+ case "end":
193
+ return _context.stop();
194
+ }
195
+ }, _callee, null, [[0, 11, 14, 17]]);
196
+ }))();
197
+ productListPromiseRef.current = request;
198
+ _context2.next = 10;
199
+ return request;
200
+ case 10:
201
+ case "end":
202
+ return _context2.stop();
203
+ }
204
+ }, _callee2);
205
+ })), [runModuleAction]);
206
+
114
207
  /** checkResourceAvailable 返回 requestEntryPax === 1 时,在协议/表单之后弹人数并写入 scanOrder otherParams */
115
208
  var requestEntryPaxRef = useRef(0);
116
209
  var requestPaxMinRef = useRef(1);
117
210
  var requestPaxMaxRef = useRef(1);
118
211
  var tableFormRecordRef = useRef(null);
212
+ /** 本次会话是否曾实际弹出过入口人数弹窗(商品页返回首页前可二次弹窗) */
213
+ var entryPaxModalWasPresentedRef = useRef(false);
119
214
 
120
- /** 根据当前语言从多语言 name 对象中取值,兜底 original -> en -> 空串 */
215
+ /** 根据当前语言从多语言 name 对象中取值,兜底当前语言 -> original -> 空串 */
121
216
  var getLocalizedName = function getLocalizedName(nameMap) {
122
217
  if (!nameMap) return '';
123
218
  var currentLocale = locales.getLocale();
124
- return nameMap[currentLocale] || nameMap.original || nameMap.en || '';
219
+ var localized = nameMap[currentLocale];
220
+ if (typeof localized === 'string' && localized) return localized;
221
+ var original = nameMap.original;
222
+ if (typeof original === 'string' && original) return original;
223
+ return '';
125
224
  };
126
225
 
127
- /** 解析可能是纯字符串或多语言对象的文案,兜底 current locale -> original -> en -> 空串 */
226
+ /**
227
+ * 解析可能是纯字符串或多语言对象的文案
228
+ * - 字符串:原样返回
229
+ * - 多语言对象(如 { en, 'zh-CN', original, ... }):取当前语言,兜底 original
230
+ * - 其它:空串
231
+ */
128
232
  var resolveLocalizedText = function resolveLocalizedText(value) {
129
233
  if (value == null) return '';
130
234
  if (typeof value === 'string') return value;
@@ -132,11 +236,11 @@ function ReadyState() {
132
236
  return getLocalizedName(value);
133
237
  };
134
238
  var normalizeFormPayload = function normalizeFormPayload(formPayload, partyroomBookingPayload) {
135
- var _ref, _ref2, _sourcePayload$id;
239
+ var _ref3, _ref4, _sourcePayload$id;
136
240
  var sourcePayload = formPayload !== null && formPayload !== void 0 ? formPayload : partyroomBookingPayload;
137
241
  if (!sourcePayload) return null;
138
242
  var isPrimitivePayload = typeof sourcePayload === 'number' || typeof sourcePayload === 'string';
139
- var rawId = isPrimitivePayload ? sourcePayload : (_ref = (_ref2 = (_sourcePayload$id = sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.id) !== null && _sourcePayload$id !== void 0 ? _sourcePayload$id : sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.form_id) !== null && _ref2 !== void 0 ? _ref2 : sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.resource_form_id) !== null && _ref !== void 0 ? _ref : sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.partyroom_booking;
243
+ var rawId = isPrimitivePayload ? sourcePayload : (_ref3 = (_ref4 = (_sourcePayload$id = sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.id) !== null && _sourcePayload$id !== void 0 ? _sourcePayload$id : sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.form_id) !== null && _ref4 !== void 0 ? _ref4 : sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.resource_form_id) !== null && _ref3 !== void 0 ? _ref3 : sourcePayload === null || sourcePayload === void 0 ? void 0 : sourcePayload.partyroom_booking;
140
244
  var formId = Number(rawId);
141
245
  if (Number.isNaN(formId) || formId <= 0) return null;
142
246
  var sourceDetail = _typeof(sourcePayload) === 'object' && sourcePayload !== null ? sourcePayload : {};
@@ -148,20 +252,54 @@ function ReadyState() {
148
252
  };
149
253
  };
150
254
  var app = utils === null || utils === void 0 || (_utils$getApp = utils.getApp) === null || _utils$getApp === void 0 ? void 0 : _utils$getApp.call(utils);
255
+
256
+ /** 回站点首页(与商品步返回兜底一致) */
257
+ var navigateToHome = function navigateToHome() {
258
+ var _app$history, _app$history2;
259
+ if (app !== null && app !== void 0 && (_app$history = app.history) !== null && _app$history !== void 0 && _app$history.replace) {
260
+ app.history.replace('/');
261
+ } else if (app !== null && app !== void 0 && (_app$history2 = app.history) !== null && _app$history2 !== void 0 && _app$history2.push) {
262
+ app.history.push('/');
263
+ } else {
264
+ location.replace('/');
265
+ }
266
+ };
267
+
268
+ /** 弹出入口人数弹窗,返回有效人数或取消/关闭时为 null */
269
+ var requestEntryPaxModal = function requestEntryPaxModal() {
270
+ return new Promise(function (resolve) {
271
+ var _tableFormRecordRef$c;
272
+ if (typeof (utils === null || utils === void 0 ? void 0 : utils.action) !== 'function') {
273
+ resolve(null);
274
+ return;
275
+ }
276
+ utils.action({
277
+ type: 'pisell1.handlePaxModal',
278
+ data: {
279
+ tableName: getLocalizedName((_tableFormRecordRef$c = tableFormRecordRef.current) === null || _tableFormRecordRef$c === void 0 ? void 0 : _tableFormRecordRef$c.name),
280
+ requestPaxMin: requestPaxMinRef.current,
281
+ requestPaxMax: requestPaxMaxRef.current
282
+ },
283
+ callback: function callback(result) {
284
+ resolve(extractEntryPaxNumber(result));
285
+ }
286
+ });
287
+ });
288
+ };
289
+
151
290
  // 跳转到订单详情页
152
291
  var handleOrderDetail = function handleOrderDetail(order_id) {
153
- var _app$history, _app$history2;
292
+ var _app$history3, _app$history4;
154
293
  var link = "/order/details?id=".concat(order_id);
155
- if (app !== null && app !== void 0 && (_app$history = app.history) !== null && _app$history !== void 0 && _app$history.replace) {
294
+ if (app !== null && app !== void 0 && (_app$history3 = app.history) !== null && _app$history3 !== void 0 && _app$history3.replace) {
156
295
  app.history.replace(link);
157
- } else if (app !== null && app !== void 0 && (_app$history2 = app.history) !== null && _app$history2 !== void 0 && _app$history2.push) {
296
+ } else if (app !== null && app !== void 0 && (_app$history4 = app.history) !== null && _app$history4 !== void 0 && _app$history4.push) {
158
297
  app.history.push(link);
159
298
  } else {
160
299
  location.replace(link);
161
300
  }
162
301
  };
163
302
  var handleBack = function handleBack() {
164
- var _app$history3, _app$history4;
165
303
  if (currentStep !== 'product') {
166
304
  prevStep();
167
305
  return;
@@ -170,123 +308,144 @@ function ReadyState() {
170
308
  handleOrderDetail(entryContext.order_id);
171
309
  return;
172
310
  }
173
- if (app !== null && app !== void 0 && (_app$history3 = app.history) !== null && _app$history3 !== void 0 && _app$history3.replace) {
174
- app.history.replace('/');
175
- } else if (app !== null && app !== void 0 && (_app$history4 = app.history) !== null && _app$history4 !== void 0 && _app$history4.push) {
176
- app.history.push('/');
177
- } else {
178
- location.replace('/');
311
+ if (entryPaxModalWasPresentedRef.current) {
312
+ void _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
313
+ var pax;
314
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
315
+ while (1) switch (_context3.prev = _context3.next) {
316
+ case 0:
317
+ _context3.next = 2;
318
+ return requestEntryPaxModal();
319
+ case 2:
320
+ pax = _context3.sent;
321
+ if (!(pax == null)) {
322
+ _context3.next = 6;
323
+ break;
324
+ }
325
+ navigateToHome();
326
+ return _context3.abrupt("return");
327
+ case 6:
328
+ _context3.prev = 6;
329
+ _context3.next = 9;
330
+ return runModuleAction('setEntryPaxNumber', pax);
331
+ case 9:
332
+ _context3.next = 11;
333
+ return refreshViewModel();
334
+ case 11:
335
+ _context3.next = 16;
336
+ break;
337
+ case 13:
338
+ _context3.prev = 13;
339
+ _context3.t0 = _context3["catch"](6);
340
+ console.warn('[scanOrder] setEntryPaxNumber on back pax confirm failed', _context3.t0);
341
+ case 16:
342
+ case "end":
343
+ return _context3.stop();
344
+ }
345
+ }, _callee3, null, [[6, 13]]);
346
+ }))();
347
+ return;
179
348
  }
349
+ navigateToHome();
180
350
  };
181
351
  var enterProductStep = /*#__PURE__*/function () {
182
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
183
- return _regeneratorRuntime().wrap(function _callee$(_context) {
184
- while (1) switch (_context.prev = _context.next) {
352
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
353
+ var target;
354
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
355
+ while (1) switch (_context4.prev = _context4.next) {
185
356
  case 0:
186
- _context.prev = 0;
187
- _context.next = 3;
357
+ _context4.prev = 0;
358
+ _context4.next = 3;
188
359
  return runModuleAction('applyItemRulePrefill');
189
360
  case 3:
190
- _context.next = 5;
361
+ _context4.next = 5;
191
362
  return refreshViewModel();
192
363
  case 5:
193
- _context.next = 10;
364
+ _context4.next = 10;
194
365
  break;
195
366
  case 7:
196
- _context.prev = 7;
197
- _context.t0 = _context["catch"](0);
198
- console.warn('[scanOrder] applyItemRulePrefill failed', _context.t0);
367
+ _context4.prev = 7;
368
+ _context4.t0 = _context4["catch"](0);
369
+ console.warn('[scanOrder] applyItemRulePrefill failed', _context4.t0);
199
370
  case 10:
200
- _context.prev = 10;
201
- // 步骤缓存命中时,currentStep 可能已恢复到 'check';不把它拉回 'product'
202
- if (currentStep !== 'check') goToStep('product');
203
- return _context.finish(10);
204
- case 13:
371
+ _context4.prev = 10;
372
+ // bootstrap 结束后统一由 resumeStep 决定最终去向:
373
+ // - resumeStep === 'check' → 恢复到结算页(此时 dineInConfig 已加载)
374
+ // - 其它(null / 'product') → 正常进入商品页
375
+ target = resumeStep === 'check' ? 'check' : 'product';
376
+ if (resumeStep) consumeResumeStep();
377
+ goToStep(target);
378
+ return _context4.finish(10);
379
+ case 15:
205
380
  case "end":
206
- return _context.stop();
381
+ return _context4.stop();
207
382
  }
208
- }, _callee, null, [[0, 7, 10, 13]]);
383
+ }, _callee4, null, [[0, 7, 10, 15]]);
209
384
  }));
210
385
  return function enterProductStep() {
211
- return _ref3.apply(this, arguments);
386
+ return _ref6.apply(this, arguments);
212
387
  };
213
388
  }();
214
389
 
215
390
  /** 需要时先走人数弹窗与 setOtherParams(entryPaxNumber),再进入商品步 */
216
391
  var runEntryPaxGateThenEnterProduct = /*#__PURE__*/function () {
217
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
392
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
218
393
  var pax;
219
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
220
- while (1) switch (_context2.prev = _context2.next) {
394
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
395
+ while (1) switch (_context5.prev = _context5.next) {
221
396
  case 0:
222
397
  if (!(requestEntryPaxRef.current !== 1)) {
223
- _context2.next = 4;
398
+ _context5.next = 4;
224
399
  break;
225
400
  }
226
- _context2.next = 3;
401
+ _context5.next = 3;
227
402
  return enterProductStep();
228
403
  case 3:
229
- return _context2.abrupt("return");
404
+ return _context5.abrupt("return");
230
405
  case 4:
231
406
  if (!isGatePassed('paxEntered')) {
232
- _context2.next = 8;
407
+ _context5.next = 8;
233
408
  break;
234
409
  }
235
- _context2.next = 7;
410
+ _context5.next = 7;
236
411
  return enterProductStep();
237
412
  case 7:
238
- return _context2.abrupt("return");
413
+ return _context5.abrupt("return");
239
414
  case 8:
240
- _context2.next = 10;
241
- return new Promise(function (resolve) {
242
- var _tableFormRecordRef$c;
243
- if (typeof (utils === null || utils === void 0 ? void 0 : utils.action) !== 'function') {
244
- resolve(null);
245
- return;
246
- }
247
- utils.action({
248
- type: 'pisell1.handlePaxModal',
249
- data: {
250
- tableName: getLocalizedName((_tableFormRecordRef$c = tableFormRecordRef.current) === null || _tableFormRecordRef$c === void 0 ? void 0 : _tableFormRecordRef$c.name),
251
- requestPaxMin: requestPaxMinRef.current,
252
- requestPaxMax: requestPaxMaxRef.current
253
- },
254
- callback: function callback(result) {
255
- resolve(extractEntryPaxNumber(result));
256
- }
257
- });
258
- });
259
- case 10:
260
- pax = _context2.sent;
415
+ entryPaxModalWasPresentedRef.current = true;
416
+ _context5.next = 11;
417
+ return requestEntryPaxModal();
418
+ case 11:
419
+ pax = _context5.sent;
261
420
  if (!(pax == null)) {
262
- _context2.next = 14;
421
+ _context5.next = 15;
263
422
  break;
264
423
  }
265
- location.replace('/');
266
- return _context2.abrupt("return");
267
- case 14:
268
- _context2.prev = 14;
269
- _context2.next = 17;
424
+ navigateToHome();
425
+ return _context5.abrupt("return");
426
+ case 15:
427
+ _context5.prev = 15;
428
+ _context5.next = 18;
270
429
  return runModuleAction('setEntryPaxNumber', pax);
271
- case 17:
430
+ case 18:
272
431
  markGate('paxEntered');
273
- _context2.next = 23;
432
+ _context5.next = 24;
274
433
  break;
275
- case 20:
276
- _context2.prev = 20;
277
- _context2.t0 = _context2["catch"](14);
278
- console.warn('[scanOrder] setOtherParams failed', _context2.t0);
279
- case 23:
280
- _context2.next = 25;
434
+ case 21:
435
+ _context5.prev = 21;
436
+ _context5.t0 = _context5["catch"](15);
437
+ console.warn('[scanOrder] setOtherParams failed', _context5.t0);
438
+ case 24:
439
+ _context5.next = 26;
281
440
  return enterProductStep();
282
- case 25:
441
+ case 26:
283
442
  case "end":
284
- return _context2.stop();
443
+ return _context5.stop();
285
444
  }
286
- }, _callee2, null, [[14, 20]]);
445
+ }, _callee5, null, [[15, 21]]);
287
446
  }));
288
447
  return function runEntryPaxGateThenEnterProduct() {
289
- return _ref4.apply(this, arguments);
448
+ return _ref7.apply(this, arguments);
290
449
  };
291
450
  }();
292
451
  var closePolicyAndBack = function closePolicyAndBack() {
@@ -348,16 +507,16 @@ function ReadyState() {
348
507
  };
349
508
  useEffect(function () {
350
509
  var checkResourceAvailable = /*#__PURE__*/function () {
351
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
352
- var hasOrderId, _yield$runModuleActio, mode, order_id, errorTips, policy, form, partyroom_booking, requestEntryPax, requestPaxMin, requestPaxMax, table_form_record, normalizedFormPayload, isAdditionalOrder, normalizedPolicyPayload, tips, content;
353
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
354
- while (1) switch (_context3.prev = _context3.next) {
510
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
511
+ var hasOrderId, _yield$runModuleActio, mode, order_id, errorTips, policy, form, partyroom_booking, requestEntryPax, requestPaxMin, requestPaxMax, table_form_record, normalizedFormPayload, isAdditionalOrder, normalizedPolicyPayload, tips, _scanOrderModule$setU, content;
512
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
513
+ while (1) switch (_context6.prev = _context6.next) {
355
514
  case 0:
356
515
  hasOrderId = !!(entryContext !== null && entryContext !== void 0 && entryContext.order_id);
357
- _context3.next = 3;
516
+ _context6.next = 3;
358
517
  return runModuleAction('checkResourceAvailable', entryContext === null || entryContext === void 0 ? void 0 : entryContext.resource_id, hasOrderId);
359
518
  case 3:
360
- _yield$runModuleActio = _context3.sent;
519
+ _yield$runModuleActio = _context6.sent;
361
520
  mode = _yield$runModuleActio.mode;
362
521
  order_id = _yield$runModuleActio.order_id;
363
522
  errorTips = _yield$runModuleActio.errorTips;
@@ -378,14 +537,14 @@ function ReadyState() {
378
537
  setEntryMode(isAdditionalOrder ? 'additional_order' : 'default');
379
538
  // 资源空闲:按需依次弹 协议 -> 表单 -> 人数,最后进入商品选择
380
539
  if (!(mode === 'idle')) {
381
- _context3.next = 35;
540
+ _context6.next = 35;
382
541
  break;
383
542
  }
384
543
  normalizedPolicyPayload = _typeof(policy) === 'object' && policy !== null ? policy : {
385
544
  id: policy
386
545
  }; // 步骤缓存:同一 resourceId 会话内已确认过协议则跳过
387
546
  if (!(normalizedPolicyPayload !== null && normalizedPolicyPayload !== void 0 && normalizedPolicyPayload.id && !isGatePassed('policyAccepted'))) {
388
- _context3.next = 28;
547
+ _context6.next = 28;
389
548
  break;
390
549
  }
391
550
  setPendingFormPayload(normalizedFormPayload);
@@ -393,79 +552,96 @@ function ReadyState() {
393
552
  open: true,
394
553
  content: normalizedPolicyPayload
395
554
  });
396
- return _context3.abrupt("return");
555
+ return _context6.abrupt("return");
397
556
  case 28:
398
557
  if (!(normalizedFormPayload && !isGatePassed('formSubmitted'))) {
399
- _context3.next = 31;
558
+ _context6.next = 31;
400
559
  break;
401
560
  }
402
561
  openFormModal(normalizedFormPayload);
403
- return _context3.abrupt("return");
562
+ return _context6.abrupt("return");
404
563
  case 31:
405
- _context3.next = 33;
564
+ _context6.next = 33;
406
565
  return runEntryPaxGateThenEnterProduct();
407
566
  case 33:
408
- _context3.next = 54;
567
+ _context6.next = 48;
409
568
  break;
410
569
  case 35:
411
570
  if (!isAdditionalOrder) {
412
- _context3.next = 44;
571
+ _context6.next = 40;
413
572
  break;
414
573
  }
415
- if (!hasOrderId) {
416
- _context3.next = 41;
417
- break;
418
- }
419
- _context3.next = 39;
574
+ _context6.next = 38;
420
575
  return enterProductStep();
421
- case 39:
422
- _context3.next = 42;
423
- break;
424
- case 41:
425
- handleOrderDetail(order_id);
426
- case 42:
427
- _context3.next = 54;
576
+ case 38:
577
+ _context6.next = 48;
428
578
  break;
429
- case 44:
579
+ case 40:
430
580
  if (!(mode === 'submit_disabled')) {
431
- _context3.next = 51;
581
+ _context6.next = 47;
432
582
  break;
433
583
  }
434
584
  // 禁止下单模式:允许进入商品选择,但下一步按钮需被禁用,点击提示 errorTips
435
585
  tips = resolveLocalizedText(errorTips) || String(locales.getText('pisell2.scan.order.submit.disabled.default') || '');
436
586
  setSubmitDisabledTips(tips);
437
- _context3.next = 49;
587
+ _context6.next = 45;
438
588
  return enterProductStep();
439
- case 49:
440
- _context3.next = 54;
589
+ case 45:
590
+ _context6.next = 48;
441
591
  break;
442
- case 51:
443
- // 其他情况,视为不在营业或者异常,返回异常提示
444
- content = resolveLocalizedText(errorTips);
445
- if (!content) {
446
- if (mode === 'resource_busy') {
447
- content = String(locales.getText('pisell2.scan.order.resource.status.exception') || '');
592
+ case 47:
593
+ if (mode === 'resource_busy') {
594
+ // 如果资源是占用,则跳转到订单详情页
595
+ // 需要检测当前是否已经登录,如果未登录则先登录再跳转
596
+ // 若用户直接关闭登录弹窗(非登录成功),由于当前还卡在 initialize 步骤,
597
+ // 没有合法后续状态,统一兜底回首页避免卡死。
598
+ if (!isLogin) {
599
+ // 登录回流意图:登录成功后 hydrate 阶段消费 pendingStep,避免卡在 init
600
+ scanOrderModule === null || scanOrderModule === void 0 || (_scanOrderModule$setU = scanOrderModule.setUIState) === null || _scanOrderModule$setU === void 0 || _scanOrderModule$setU.call(scanOrderModule, 'pendingStep', currentStep);
601
+ openLoginModal({
602
+ callback: function callback(status) {
603
+ var _scanOrderModule$dele2;
604
+ if (status === 'success') {
605
+ var _scanOrderModule$dele;
606
+ scanOrderModule === null || scanOrderModule === void 0 || (_scanOrderModule$dele = scanOrderModule.deleteUIState) === null || _scanOrderModule$dele === void 0 || _scanOrderModule$dele.call(scanOrderModule, 'pendingStep');
607
+ handleOrderDetail(order_id);
608
+ return;
609
+ }
610
+ scanOrderModule === null || scanOrderModule === void 0 || (_scanOrderModule$dele2 = scanOrderModule.deleteUIState) === null || _scanOrderModule$dele2 === void 0 || _scanOrderModule$dele2.call(scanOrderModule, 'pendingStep');
611
+ location.replace('/');
612
+ }
613
+ });
448
614
  } else {
449
- content = String(locales.getText('pisell2.scan.order.store.status.exception') || '');
615
+ handleOrderDetail(order_id);
450
616
  }
451
- }
452
- Modal.info({
453
- title: locales.getText('pisell2.scan.order.step.error'),
454
- content: String(content || '').trim(),
455
- okText: String(locales.getText('pisell2.event.confirm') || 'OK'),
456
- maskClosable: false,
457
- onOk: function onOk() {
458
- location.replace('/');
617
+ } else {
618
+ // 其他情况,视为不在营业或者异常,返回异常提示
619
+ content = resolveLocalizedText(errorTips);
620
+ if (!content) {
621
+ if (mode === 'resource_block') {
622
+ content = String(locales.getText('pisell2.scan.order.resource.status.exception') || '');
623
+ } else {
624
+ content = String(locales.getText('pisell2.scan.order.store.status.exception') || '');
625
+ }
459
626
  }
460
- });
461
- case 54:
627
+ Modal.info({
628
+ title: locales.getText('pisell2.scan.order.step.error'),
629
+ content: resolveLocalizedText(content).trim(),
630
+ okText: String(locales.getText('pisell2.event.confirm') || 'OK'),
631
+ maskClosable: false,
632
+ onOk: function onOk() {
633
+ location.replace('/');
634
+ }
635
+ });
636
+ }
637
+ case 48:
462
638
  case "end":
463
- return _context3.stop();
639
+ return _context6.stop();
464
640
  }
465
- }, _callee3);
641
+ }, _callee6);
466
642
  }));
467
643
  return function checkResourceAvailable() {
468
- return _ref5.apply(this, arguments);
644
+ return _ref8.apply(this, arguments);
469
645
  };
470
646
  }();
471
647
  // 等 ScanOrderProvider 的步骤缓存 hydrate 完成再跑,确保 gate 标记已就位
@@ -494,7 +670,9 @@ function ReadyState() {
494
670
  product: /*#__PURE__*/React.createElement(Menu, {
495
671
  onCheckout: function onCheckout() {
496
672
  return goToStep('check');
497
- }
673
+ },
674
+ productList: productList,
675
+ onEnsureProductList: ensureProductListLoaded
498
676
  }),
499
677
  check: /*#__PURE__*/React.createElement(Check, null),
500
678
  error: /*#__PURE__*/React.createElement(ErrorState, {
@@ -564,22 +742,22 @@ function ReadyState() {
564
742
 
565
743
  // 跳转到订单确认页
566
744
  var gotoCheckOrder = /*#__PURE__*/function () {
567
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
745
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
568
746
  var _otherParams$dineInCo;
569
- var firstFailure, failedProductIds, failureTips, otherParams, dineInConfig, isPauseOrder, _dineInConfig$availab;
570
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
571
- while (1) switch (_context4.prev = _context4.next) {
747
+ var firstFailure, failedProductIds, failureTips, otherParams, dineInConfig, isPauseOrder, _dineInConfig$availab, _scanOrderModule$setU2;
748
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
749
+ while (1) switch (_context7.prev = _context7.next) {
572
750
  case 0:
573
751
  if (!submitDisabledTips) {
574
- _context4.next = 3;
752
+ _context7.next = 3;
575
753
  break;
576
754
  }
577
755
  message.warning(submitDisabledTips, 2);
578
- return _context4.abrupt("return");
756
+ return _context7.abrupt("return");
579
757
  case 3:
580
758
  firstFailure = Array.isArray(cartValidation === null || cartValidation === void 0 ? void 0 : cartValidation.failures) ? cartValidation.failures[0] : null;
581
759
  if (!((cartValidation === null || cartValidation === void 0 ? void 0 : cartValidation.passed) === false)) {
582
- _context4.next = 10;
760
+ _context7.next = 10;
583
761
  break;
584
762
  }
585
763
  failedProductIds = getFirstFailedProductIds();
@@ -588,17 +766,17 @@ function ReadyState() {
588
766
  }
589
767
  failureTips = String((firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '').trim();
590
768
  message.warning(failureTips, 2);
591
- return _context4.abrupt("return");
769
+ return _context7.abrupt("return");
592
770
  case 10:
593
- _context4.next = 12;
771
+ _context7.next = 12;
594
772
  return runModuleAction('getOtherParams');
595
773
  case 12:
596
- otherParams = _context4.sent;
774
+ otherParams = _context7.sent;
597
775
  console.log('otherParams >>>>> ', otherParams);
598
776
  dineInConfig = (_otherParams$dineInCo = otherParams === null || otherParams === void 0 ? void 0 : otherParams.dineInConfig) !== null && _otherParams$dineInCo !== void 0 ? _otherParams$dineInCo : {};
599
777
  isPauseOrder = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused']; // 如果暂停接单直接弹提示,点完确定回首页
600
778
  if (!isPauseOrder) {
601
- _context4.next = 19;
779
+ _context7.next = 19;
602
780
  break;
603
781
  }
604
782
  Modal.info({
@@ -609,28 +787,33 @@ function ReadyState() {
609
787
  location.replace('/');
610
788
  }
611
789
  });
612
- return _context4.abrupt("return");
790
+ return _context7.abrupt("return");
613
791
  case 19:
614
- // 需要先确认当前是否登录,如果没有则需要登录
615
- if (!isLogin) {
616
- openLoginModal({
617
- callback: function callback(status) {
618
- if (status === 'success') {
619
- goToStep('check');
620
- }
621
- }
622
- });
623
- } else {
624
- goToStep('check');
792
+ if (isLogin) {
793
+ _context7.next = 23;
794
+ break;
625
795
  }
626
- case 20:
796
+ // 登录前落盘跳转意图:弹窗 callback 能触发时由本函数消费,
797
+ // 整页跳转回流时由 Provider 的 hydrate 消费(参见 venueBooking 同名实现)
798
+ scanOrderModule === null || scanOrderModule === void 0 || (_scanOrderModule$setU2 = scanOrderModule.setUIState) === null || _scanOrderModule$setU2 === void 0 || _scanOrderModule$setU2.call(scanOrderModule, 'pendingStep', 'check');
799
+ openLoginModal({
800
+ callback: function callback(status) {
801
+ var _scanOrderModule$dele3;
802
+ scanOrderModule === null || scanOrderModule === void 0 || (_scanOrderModule$dele3 = scanOrderModule.deleteUIState) === null || _scanOrderModule$dele3 === void 0 || _scanOrderModule$dele3.call(scanOrderModule, 'pendingStep');
803
+ if (status === 'success') goToStep('check');
804
+ }
805
+ });
806
+ return _context7.abrupt("return");
807
+ case 23:
808
+ goToStep('check');
809
+ case 24:
627
810
  case "end":
628
- return _context4.stop();
811
+ return _context7.stop();
629
812
  }
630
- }, _callee4);
813
+ }, _callee7);
631
814
  }));
632
815
  return function gotoCheckOrder() {
633
- return _ref6.apply(this, arguments);
816
+ return _ref9.apply(this, arguments);
634
817
  };
635
818
  }();
636
819
  var isMobileView = isMobile();