@pisell/pisellos 0.0.45 → 0.0.47

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.
@@ -1,10 +1,10 @@
1
1
  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); }
2
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
- 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); }
6
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7
+ 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); }
8
8
  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; }
9
9
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -354,28 +354,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
354
354
  key: "storeProduct",
355
355
  value: function () {
356
356
  var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
357
- var activeAccount, _ref3, bundle, options, origin, product_variant_id, product;
357
+ var activeAccount, _ref3, bundle, options, origin, product_variant_id, product, addCartItem;
358
358
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
359
359
  while (1) switch (_context6.prev = _context6.next) {
360
360
  case 0:
361
361
  // 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
362
362
  activeAccount = this.getActiveAccount();
363
- if (activeAccount) {
364
- _context6.next = 3;
365
- break;
366
- }
367
- throw new Error('没有找到当前账户');
368
- case 3:
369
363
  _ref3 = productData || {}, bundle = _ref3.bundle, options = _ref3.options, origin = _ref3.origin, product_variant_id = _ref3.product_variant_id;
370
364
  product = _objectSpread(_objectSpread({}, origin), {}, {
371
365
  product_variant_id: product_variant_id
372
366
  });
373
- this.store.cart.addItem({
374
- account: activeAccount,
367
+ addCartItem = {
375
368
  product: product,
376
369
  bundle: bundle,
377
370
  options: options
378
- });
371
+ };
372
+ if (activeAccount) {
373
+ addCartItem.account = activeAccount;
374
+ }
375
+ this.store.cart.addItem(addCartItem);
379
376
  case 6:
380
377
  case "end":
381
378
  return _context6.stop();
@@ -386,26 +383,31 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
386
383
  return _storeProduct.apply(this, arguments);
387
384
  }
388
385
  return storeProduct;
389
- }() // 添加账户或者 guest
386
+ }() // 添加单个账户或者 guest
390
387
  }, {
391
388
  key: "addAccount",
392
389
  value: function () {
393
- var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(accounts, extra) {
394
- var _this3 = this;
390
+ var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(account, extra) {
391
+ var accountModules, newAccount;
395
392
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
396
393
  while (1) switch (_context7.prev = _context7.next) {
397
394
  case 0:
398
395
  if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
399
- _context7.next = 3;
396
+ _context7.next = 5;
400
397
  break;
401
398
  }
402
- this.store.accountList.addHolderAccounts(accounts, extra.customerId);
403
- return _context7.abrupt("return");
399
+ _context7.next = 3;
400
+ return this.store.accountList.addHolderAccounts([account], extra.customerId);
404
401
  case 3:
405
- accounts.forEach(function (account) {
406
- _this3.store.accountList.addAccount(account);
407
- });
408
- case 4:
402
+ accountModules = _context7.sent;
403
+ return _context7.abrupt("return", accountModules[0].getAccount());
404
+ case 5:
405
+ _context7.next = 7;
406
+ return this.store.accountList.addAccount(account);
407
+ case 7:
408
+ newAccount = _context7.sent;
409
+ return _context7.abrupt("return", newAccount.getAccount());
410
+ case 9:
409
411
  case "end":
410
412
  return _context7.stop();
411
413
  }
@@ -415,24 +417,84 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
415
417
  return _addAccount.apply(this, arguments);
416
418
  }
417
419
  return addAccount;
420
+ }() // 添加账户或者 guest
421
+ }, {
422
+ key: "addAccounts",
423
+ value: function () {
424
+ var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(accounts, extra) {
425
+ var res, _iterator, _step, account, accountModule, accountData;
426
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
427
+ while (1) switch (_context8.prev = _context8.next) {
428
+ case 0:
429
+ if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
430
+ _context8.next = 3;
431
+ break;
432
+ }
433
+ this.store.accountList.addHolderAccounts(accounts, extra.customerId);
434
+ return _context8.abrupt("return");
435
+ case 3:
436
+ res = [];
437
+ _iterator = _createForOfIteratorHelper(accounts);
438
+ _context8.prev = 5;
439
+ _iterator.s();
440
+ case 7:
441
+ if ((_step = _iterator.n()).done) {
442
+ _context8.next = 16;
443
+ break;
444
+ }
445
+ account = _step.value;
446
+ _context8.next = 11;
447
+ return this.store.accountList.addAccount(account);
448
+ case 11:
449
+ accountModule = _context8.sent;
450
+ accountData = accountModule.getAccount();
451
+ if (accountData) {
452
+ res.push(accountData);
453
+ }
454
+ case 14:
455
+ _context8.next = 7;
456
+ break;
457
+ case 16:
458
+ _context8.next = 21;
459
+ break;
460
+ case 18:
461
+ _context8.prev = 18;
462
+ _context8.t0 = _context8["catch"](5);
463
+ _iterator.e(_context8.t0);
464
+ case 21:
465
+ _context8.prev = 21;
466
+ _iterator.f();
467
+ return _context8.finish(21);
468
+ case 24:
469
+ return _context8.abrupt("return", res);
470
+ case 25:
471
+ case "end":
472
+ return _context8.stop();
473
+ }
474
+ }, _callee8, this, [[5, 18, 21, 24]]);
475
+ }));
476
+ function addAccounts(_x9, _x10) {
477
+ return _addAccounts.apply(this, arguments);
478
+ }
479
+ return addAccounts;
418
480
  }() // 获取所有账户
419
481
  }, {
420
482
  key: "getAccounts",
421
483
  value: function () {
422
- var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
484
+ var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
423
485
  var accounts;
424
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
425
- while (1) switch (_context8.prev = _context8.next) {
486
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
487
+ while (1) switch (_context9.prev = _context9.next) {
426
488
  case 0:
427
489
  accounts = this.store.accountList.getAccounts();
428
- return _context8.abrupt("return", accounts.map(function (account) {
490
+ return _context9.abrupt("return", accounts.map(function (account) {
429
491
  return account.getAccount();
430
492
  }));
431
493
  case 2:
432
494
  case "end":
433
- return _context8.stop();
495
+ return _context9.stop();
434
496
  }
435
- }, _callee8, this);
497
+ }, _callee9, this);
436
498
  }));
437
499
  function getAccounts() {
438
500
  return _getAccounts.apply(this, arguments);
@@ -473,18 +535,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
473
535
  }, {
474
536
  key: "fetchHolderAccountsAsync",
475
537
  value: (function () {
476
- var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
477
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
478
- while (1) switch (_context9.prev = _context9.next) {
538
+ var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
539
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
540
+ while (1) switch (_context10.prev = _context10.next) {
479
541
  case 0:
480
- return _context9.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
542
+ return _context10.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
481
543
  case 1:
482
544
  case "end":
483
- return _context9.stop();
545
+ return _context10.stop();
484
546
  }
485
- }, _callee9, this);
547
+ }, _callee10, this);
486
548
  }));
487
- function fetchHolderAccountsAsync(_x9) {
549
+ function fetchHolderAccountsAsync(_x11) {
488
550
  return _fetchHolderAccountsAsync.apply(this, arguments);
489
551
  }
490
552
  return fetchHolderAccountsAsync;
@@ -493,18 +555,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
493
555
  }, {
494
556
  key: "setDateRange",
495
557
  value: function () {
496
- var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(dateRange) {
497
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
498
- while (1) switch (_context10.prev = _context10.next) {
558
+ var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(dateRange) {
559
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
560
+ while (1) switch (_context11.prev = _context11.next) {
499
561
  case 0:
500
562
  this.store.date.setDateRange(dateRange);
501
563
  case 1:
502
564
  case "end":
503
- return _context10.stop();
565
+ return _context11.stop();
504
566
  }
505
- }, _callee10, this);
567
+ }, _callee11, this);
506
568
  }));
507
- function setDateRange(_x10) {
569
+ function setDateRange(_x12) {
508
570
  return _setDateRange.apply(this, arguments);
509
571
  }
510
572
  return setDateRange;
@@ -519,16 +581,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
519
581
  }, {
520
582
  key: "getDateRange",
521
583
  value: function () {
522
- var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
523
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
524
- while (1) switch (_context11.prev = _context11.next) {
584
+ var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
585
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
586
+ while (1) switch (_context12.prev = _context12.next) {
525
587
  case 0:
526
- return _context11.abrupt("return", this.store.date.getDateRange());
588
+ return _context12.abrupt("return", this.store.date.getDateRange());
527
589
  case 1:
528
590
  case "end":
529
- return _context11.stop();
591
+ return _context12.stop();
530
592
  }
531
- }, _callee11, this);
593
+ }, _callee12, this);
532
594
  }));
533
595
  function getDateRange() {
534
596
  return _getDateRange.apply(this, arguments);
@@ -545,8 +607,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
545
607
  }, {
546
608
  key: "getAvailableDate",
547
609
  value: function () {
548
- var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
549
- var _this4 = this,
610
+ var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
611
+ var _this3 = this,
550
612
  _this$otherParams3,
551
613
  _this$otherParams4;
552
614
  var params,
@@ -562,11 +624,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
562
624
  rules,
563
625
  resourcesMap,
564
626
  res,
565
- _args12 = arguments;
566
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
567
- while (1) switch (_context12.prev = _context12.next) {
627
+ _args13 = arguments;
628
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
629
+ while (1) switch (_context13.prev = _context13.next) {
568
630
  case 0:
569
- params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
631
+ params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
570
632
  // 开始日期如果小于今天,直接以今天当做开始日期
571
633
  products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
572
634
  if (dayjs(startDate).isBefore(dayjs()) && (dayjs(endDate).isAfter(dayjs()) || dayjs(endDate).isSame(dayjs()))) {
@@ -578,7 +640,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
578
640
  if (tempProducts.length) {
579
641
  tempProducts.forEach(function (p) {
580
642
  if (p !== null && p !== void 0 && p['schedule.ids']) {
581
- var scheduleData = _this4.getScheduleDataByIds(p['schedule.ids']);
643
+ var scheduleData = _this3.getScheduleDataByIds(p['schedule.ids']);
582
644
  p['_schedule'] = scheduleData;
583
645
  }
584
646
  });
@@ -592,16 +654,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
592
654
  tempStartDate = startDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[0]);
593
655
  tempEndDate = endDate || ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 || (_this$otherParams4 = _this$otherParams4.dateRange) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4[1]);
594
656
  if (tempProducts.length) {
595
- _context12.next = 10;
657
+ _context13.next = 10;
596
658
  break;
597
659
  }
598
- return _context12.abrupt("return", []);
660
+ return _context13.abrupt("return", []);
599
661
  case 10:
600
662
  // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
601
663
  _ref4 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref4.resourceIds, rules = _ref4.rules, resourcesMap = _ref4.resourcesMap;
602
664
  this.otherParams.currentResourcesMap = resourcesMap;
603
- _context12.next = 14;
665
+ _context13.next = 14;
604
666
  return this.store.date.getResourceDates({
667
+ url: params.url,
605
668
  query: {
606
669
  start_date: tempStartDate,
607
670
  end_date: tempEndDate,
@@ -611,13 +674,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
611
674
  type: type
612
675
  });
613
676
  case 14:
614
- res = _context12.sent;
615
- return _context12.abrupt("return", res);
677
+ res = _context13.sent;
678
+ return _context13.abrupt("return", res);
616
679
  case 16:
617
680
  case "end":
618
- return _context12.stop();
681
+ return _context13.stop();
619
682
  }
620
- }, _callee12, this);
683
+ }, _callee13, this);
621
684
  }));
622
685
  function getAvailableDate() {
623
686
  return _getAvailableDate.apply(this, arguments);
@@ -630,22 +693,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
630
693
  }, {
631
694
  key: "getSummary",
632
695
  value: (function () {
633
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
696
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
634
697
  var cartItems, summary;
635
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
636
- while (1) switch (_context13.prev = _context13.next) {
698
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
699
+ while (1) switch (_context14.prev = _context14.next) {
637
700
  case 0:
638
701
  cartItems = this.store.cart.getItems();
639
- _context13.next = 3;
702
+ _context14.next = 3;
640
703
  return this.store.summary.getSummary(cartItems);
641
704
  case 3:
642
- summary = _context13.sent;
643
- return _context13.abrupt("return", summary);
705
+ summary = _context14.sent;
706
+ return _context14.abrupt("return", summary);
644
707
  case 5:
645
708
  case "end":
646
- return _context13.stop();
709
+ return _context14.stop();
647
710
  }
648
- }, _callee13, this);
711
+ }, _callee14, this);
649
712
  }));
650
713
  function getSummary() {
651
714
  return _getSummary.apply(this, arguments);
@@ -659,18 +722,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
659
722
  }, {
660
723
  key: "getProtocol",
661
724
  value: (function () {
662
- var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(protocolId) {
663
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
664
- while (1) switch (_context14.prev = _context14.next) {
725
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(protocolId) {
726
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
727
+ while (1) switch (_context15.prev = _context15.next) {
665
728
  case 0:
666
- return _context14.abrupt("return", this.store.summary.getProtocol(protocolId));
729
+ return _context15.abrupt("return", this.store.summary.getProtocol(protocolId));
667
730
  case 1:
668
731
  case "end":
669
- return _context14.stop();
732
+ return _context15.stop();
670
733
  }
671
- }, _callee14, this);
734
+ }, _callee15, this);
672
735
  }));
673
- function getProtocol(_x11) {
736
+ function getProtocol(_x13) {
674
737
  return _getProtocol.apply(this, arguments);
675
738
  }
676
739
  return getProtocol;
@@ -679,16 +742,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
679
742
  }, {
680
743
  key: "getProducts",
681
744
  value: function () {
682
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
683
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
684
- while (1) switch (_context15.prev = _context15.next) {
745
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
746
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
747
+ while (1) switch (_context16.prev = _context16.next) {
685
748
  case 0:
686
- return _context15.abrupt("return", this.store.products.getProducts());
749
+ return _context16.abrupt("return", this.store.products.getProducts());
687
750
  case 1:
688
751
  case "end":
689
- return _context15.stop();
752
+ return _context16.stop();
690
753
  }
691
- }, _callee15, this);
754
+ }, _callee16, this);
692
755
  }));
693
756
  function getProducts() {
694
757
  return _getProducts.apply(this, arguments);
@@ -698,15 +761,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
698
761
  }, {
699
762
  key: "setLoginAccount",
700
763
  value: function () {
701
- var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(accountId, accountInfo) {
702
- var _this5 = this;
764
+ var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(accountId, accountInfo) {
765
+ var _this4 = this;
703
766
  var account, stateAccountId, cartItems;
704
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
705
- while (1) switch (_context16.prev = _context16.next) {
767
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
768
+ while (1) switch (_context17.prev = _context17.next) {
706
769
  case 0:
707
770
  account = this.store.accountList.getAccount(accountId);
708
771
  if (!account) {
709
- _context16.next = 9;
772
+ _context17.next = 9;
710
773
  break;
711
774
  }
712
775
  stateAccountId = account.getId();
@@ -715,24 +778,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
715
778
  cartItems = this.store.cart.getItems();
716
779
  cartItems.forEach(function (item) {
717
780
  if (item.holder_id === accountId) {
718
- _this5.store.cart.updateItem({
781
+ _this4.store.cart.updateItem({
719
782
  _id: item._id,
720
783
  account: accountInfo
721
784
  });
722
785
  }
723
786
  });
724
787
  this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
725
- _context16.next = 10;
788
+ _context17.next = 10;
726
789
  break;
727
790
  case 9:
728
791
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
729
792
  case 10:
730
793
  case "end":
731
- return _context16.stop();
794
+ return _context17.stop();
732
795
  }
733
- }, _callee16, this);
796
+ }, _callee17, this);
734
797
  }));
735
- function setLoginAccount(_x12, _x13) {
798
+ function setLoginAccount(_x14, _x15) {
736
799
  return _setLoginAccount.apply(this, arguments);
737
800
  }
738
801
  return setLoginAccount;
@@ -740,14 +803,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
740
803
  }, {
741
804
  key: "generateCartData",
742
805
  value: function () {
743
- var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
744
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
745
- while (1) switch (_context17.prev = _context17.next) {
806
+ var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
807
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
808
+ while (1) switch (_context18.prev = _context18.next) {
746
809
  case 0:
747
810
  case "end":
748
- return _context17.stop();
811
+ return _context18.stop();
749
812
  }
750
- }, _callee17);
813
+ }, _callee18);
751
814
  }));
752
815
  function generateCartData() {
753
816
  return _generateCartData.apply(this, arguments);
@@ -757,23 +820,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
757
820
  }, {
758
821
  key: "getFreeProduct",
759
822
  value: function () {
760
- var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(id) {
823
+ var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(id) {
761
824
  var res;
762
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
763
- while (1) switch (_context18.prev = _context18.next) {
825
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
826
+ while (1) switch (_context19.prev = _context19.next) {
764
827
  case 0:
765
- _context18.next = 2;
828
+ _context19.next = 2;
766
829
  return this.request.post("/pay/order/free-pay/".concat(id));
767
830
  case 2:
768
- res = _context18.sent;
769
- return _context18.abrupt("return", res);
831
+ res = _context19.sent;
832
+ return _context19.abrupt("return", res);
770
833
  case 4:
771
834
  case "end":
772
- return _context18.stop();
835
+ return _context19.stop();
773
836
  }
774
- }, _callee18, this);
837
+ }, _callee19, this);
775
838
  }));
776
- function getFreeProduct(_x14) {
839
+ function getFreeProduct(_x16) {
777
840
  return _getFreeProduct.apply(this, arguments);
778
841
  }
779
842
  return getFreeProduct;
@@ -796,10 +859,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
796
859
  }, {
797
860
  key: "submitOrder",
798
861
  value: function () {
799
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
862
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
800
863
  var cartItems, newCartItems;
801
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
802
- while (1) switch (_context19.prev = _context19.next) {
864
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
865
+ while (1) switch (_context20.prev = _context20.next) {
803
866
  case 0:
804
867
  cartItems = this.store.cart.getItems();
805
868
  newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
@@ -812,16 +875,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
812
875
  return _objectSpread({}, newResourcesItem);
813
876
  });
814
877
  });
815
- return _context19.abrupt("return", this.store.order.submitOrder({
878
+ return _context20.abrupt("return", this.store.order.submitOrder({
816
879
  query: {
817
880
  cartItems: newCartItems
818
881
  }
819
882
  }));
820
883
  case 4:
821
884
  case "end":
822
- return _context19.stop();
885
+ return _context20.stop();
823
886
  }
824
- }, _callee19, this);
887
+ }, _callee20, this);
825
888
  }));
826
889
  function submitOrder() {
827
890
  return _submitOrder.apply(this, arguments);
@@ -831,14 +894,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
831
894
  }, {
832
895
  key: "pay",
833
896
  value: function () {
834
- var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
835
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
836
- while (1) switch (_context20.prev = _context20.next) {
897
+ var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
898
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
899
+ while (1) switch (_context21.prev = _context21.next) {
837
900
  case 0:
838
901
  case "end":
839
- return _context20.stop();
902
+ return _context21.stop();
840
903
  }
841
- }, _callee20);
904
+ }, _callee21);
842
905
  }));
843
906
  function pay() {
844
907
  return _pay.apply(this, arguments);
@@ -848,14 +911,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
848
911
  }, {
849
912
  key: "getPayInfo",
850
913
  value: function () {
851
- var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
852
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
853
- while (1) switch (_context21.prev = _context21.next) {
914
+ var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
915
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
916
+ while (1) switch (_context22.prev = _context22.next) {
854
917
  case 0:
855
918
  case "end":
856
- return _context21.stop();
919
+ return _context22.stop();
857
920
  }
858
- }, _callee21);
921
+ }, _callee22);
859
922
  }));
860
923
  function getPayInfo() {
861
924
  return _getPayInfo.apply(this, arguments);
@@ -865,15 +928,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
865
928
  }, {
866
929
  key: "setOtherParams",
867
930
  value: function () {
868
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
931
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
869
932
  var _ref5,
870
933
  _ref5$cover,
871
934
  cover,
872
- _args22 = arguments;
873
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
874
- while (1) switch (_context22.prev = _context22.next) {
935
+ _args23 = arguments;
936
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
937
+ while (1) switch (_context23.prev = _context23.next) {
875
938
  case 0:
876
- _ref5 = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
939
+ _ref5 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
877
940
  if (cover) {
878
941
  this.otherParams = params;
879
942
  } else {
@@ -881,11 +944,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
881
944
  }
882
945
  case 2:
883
946
  case "end":
884
- return _context22.stop();
947
+ return _context23.stop();
885
948
  }
886
- }, _callee22, this);
949
+ }, _callee23, this);
887
950
  }));
888
- function setOtherParams(_x15) {
951
+ function setOtherParams(_x17) {
889
952
  return _setOtherParams.apply(this, arguments);
890
953
  }
891
954
  return setOtherParams;
@@ -893,16 +956,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
893
956
  }, {
894
957
  key: "getOtherParams",
895
958
  value: function () {
896
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
897
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
898
- while (1) switch (_context23.prev = _context23.next) {
959
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
960
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
961
+ while (1) switch (_context24.prev = _context24.next) {
899
962
  case 0:
900
- return _context23.abrupt("return", this.otherParams);
963
+ return _context24.abrupt("return", this.otherParams);
901
964
  case 1:
902
965
  case "end":
903
- return _context23.stop();
966
+ return _context24.stop();
904
967
  }
905
- }, _callee23, this);
968
+ }, _callee24, this);
906
969
  }));
907
970
  function getOtherParams() {
908
971
  return _getOtherParams.apply(this, arguments);
@@ -912,7 +975,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
912
975
  }, {
913
976
  key: "updateCart",
914
977
  value: function updateCart(params) {
915
- var _this6 = this;
978
+ var _this5 = this;
916
979
  var targetCartItem = this.store.cart.getItem(params._id);
917
980
  if (!targetCartItem) {
918
981
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
@@ -942,7 +1005,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
942
1005
  return false;
943
1006
  });
944
1007
  });
945
- _this6.store.cart.updateItem({
1008
+ _this5.store.cart.updateItem({
946
1009
  _id: item._id,
947
1010
  resources: resources
948
1011
  });
@@ -977,10 +1040,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
977
1040
  }, {
978
1041
  key: "batchUpdateCart",
979
1042
  value: function batchUpdateCart(paramsList) {
980
- var _this7 = this;
1043
+ var _this6 = this;
981
1044
  var cartItems = [];
982
1045
  paramsList.forEach(function (params) {
983
- var cartItem = _this7.store.cart.formatCartItem(params);
1046
+ var cartItem = _this6.store.cart.formatCartItem(params);
984
1047
  cartItems.push(cartItem);
985
1048
  });
986
1049
  this.store.cart.batchSetItems(cartItems);
@@ -1018,8 +1081,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1018
1081
  dateRange.forEach(function (n) {
1019
1082
  if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1020
1083
  });
1021
- } else {
1022
- // 如果没有 dateRange,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1084
+ }
1085
+ // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1086
+ if (!resources.length) {
1023
1087
  var dateList = this.store.date.getDateList();
1024
1088
  dateList.forEach(function (n) {
1025
1089
  if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
@@ -1160,11 +1224,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1160
1224
  // .format("HH:mm");
1161
1225
  // 根据 start_time 和 end_time 去匹配资源
1162
1226
  var targetResource = null;
1163
- var _iterator = _createForOfIteratorHelper(resources),
1164
- _step;
1227
+ var _iterator2 = _createForOfIteratorHelper(resources),
1228
+ _step2;
1165
1229
  try {
1166
1230
  var _loop = function _loop() {
1167
- var n = _step.value;
1231
+ var n = _step2.value;
1168
1232
  var canUseTime = n.times.find(function (item) {
1169
1233
  var res = getIsUsableByTimeItem({
1170
1234
  timeSlice: timeSlots,
@@ -1179,13 +1243,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1179
1243
  return 1; // break
1180
1244
  }
1181
1245
  };
1182
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1246
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1183
1247
  if (_loop()) break;
1184
1248
  }
1185
1249
  } catch (err) {
1186
- _iterator.e(err);
1250
+ _iterator2.e(err);
1187
1251
  } finally {
1188
- _iterator.f();
1252
+ _iterator2.f();
1189
1253
  }
1190
1254
  return {
1191
1255
  selectedResource: targetResource
@@ -1263,11 +1327,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1263
1327
  // .format("HH:mm");
1264
1328
  // 根据 start_time 和 end_time 去匹配资源
1265
1329
  var targetResource = null;
1266
- var _iterator2 = _createForOfIteratorHelper(resources),
1267
- _step2;
1330
+ var _iterator3 = _createForOfIteratorHelper(resources),
1331
+ _step3;
1268
1332
  try {
1269
1333
  var _loop2 = function _loop2() {
1270
- var n = _step2.value;
1334
+ var n = _step3.value;
1271
1335
  var recordCount = countMap[n.id] || 0;
1272
1336
  var canUseTime = n.times.find(function (item) {
1273
1337
  var res = getIsUsableByTimeItem({
@@ -1283,13 +1347,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1283
1347
  return 1; // break
1284
1348
  }
1285
1349
  };
1286
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1350
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1287
1351
  if (_loop2()) break;
1288
1352
  }
1289
1353
  } catch (err) {
1290
- _iterator2.e(err);
1354
+ _iterator3.e(err);
1291
1355
  } finally {
1292
- _iterator2.f();
1356
+ _iterator3.f();
1293
1357
  }
1294
1358
  return {
1295
1359
  selectedResource: targetResource
@@ -1322,7 +1386,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1322
1386
  }, {
1323
1387
  key: "autoSelectAllProductResources",
1324
1388
  value: function autoSelectAllProductResources(resources_code, timeSlots) {
1325
- var _this8 = this;
1389
+ var _this7 = this;
1326
1390
  var dateRange = this.store.date.getDateRange();
1327
1391
  var resources = [];
1328
1392
  dateRange.forEach(function (n) {
@@ -1333,7 +1397,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1333
1397
  var errorList = [];
1334
1398
  var selectResourcesMap = {};
1335
1399
  this.store.accountList.getAccounts().forEach(function (account) {
1336
- var cartItems = _this8.store.cart.getCartByAccount(account.getId());
1400
+ var cartItems = _this7.store.cart.getCartByAccount(account.getId());
1337
1401
  var recordTimeSlots = cloneDeep(timeSlots);
1338
1402
  // timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
1339
1403
  // 假设 timeSlots.start_time 是15:40 duration 是 30min
@@ -1361,7 +1425,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1361
1425
  };
1362
1426
  }
1363
1427
  // 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
1364
- var res = _this8.autoSelectAccountResources({
1428
+ var res = _this7.autoSelectAccountResources({
1365
1429
  holder_id: item.holder_id,
1366
1430
  resources_code: resources_code,
1367
1431
  timeSlots: recordTimeSlots,
@@ -1380,7 +1444,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1380
1444
  }
1381
1445
  res.selectedResource.capacity = currentCapacity;
1382
1446
  checkSubResourcesCapacity(res.selectedResource);
1383
- _this8.store.cart.updateItem({
1447
+ _this7.store.cart.updateItem({
1384
1448
  _id: item._id,
1385
1449
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
1386
1450
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
@@ -1394,7 +1458,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1394
1458
  } else {
1395
1459
  var _item$_productOrigin7, _productResources$fin;
1396
1460
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1397
- var allCartItems = _this8.store.cart.getItems();
1461
+ var allCartItems = _this7.store.cart.getItems();
1398
1462
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1399
1463
  if (!item.holder_id) return;
1400
1464
  var selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
@@ -1415,7 +1479,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1415
1479
  targetResource.capacity = currentCapacity;
1416
1480
  // 在这里处理 children 的数据
1417
1481
  checkSubResourcesCapacity(targetResource);
1418
- _this8.store.cart.updateItem({
1482
+ _this7.store.cart.updateItem({
1419
1483
  _id: item._id,
1420
1484
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
1421
1485
  return existingRes.resourceType !== targetRenderList[0].resourceType;
@@ -1437,7 +1501,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1437
1501
  }, {
1438
1502
  key: "getTimeSlotByAllResources",
1439
1503
  value: function getTimeSlotByAllResources(resources_code) {
1440
- var _this9 = this;
1504
+ var _this8 = this;
1441
1505
  var dateRange = this.store.date.getDateRange();
1442
1506
  // 取出购物车中所有一已选择的第一步资源
1443
1507
  var resources = [];
@@ -1462,7 +1526,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1462
1526
  // duration = 不同账号的最长时间
1463
1527
  this.store.accountList.getAccounts().forEach(function (account) {
1464
1528
  var accountDuration = 0;
1465
- var cartItems = _this9.store.cart.getCartByAccount(account.getId());
1529
+ var cartItems = _this8.store.cart.getCartByAccount(account.getId());
1466
1530
  cartItems.forEach(function (item) {
1467
1531
  var _item$_productOrigin$3, _item$_productOrigin9;
1468
1532
  accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
@@ -1485,7 +1549,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1485
1549
  }, {
1486
1550
  key: "submitTimeSlot",
1487
1551
  value: function submitTimeSlot(timeSlots) {
1488
- var _this10 = this;
1552
+ var _this9 = this;
1489
1553
  // 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
1490
1554
  var cartItems = this.store.cart.getItems();
1491
1555
 
@@ -1510,7 +1574,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1510
1574
  resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
1511
1575
  delete resource.times;
1512
1576
  });
1513
- _this10.store.cart.updateItem({
1577
+ _this9.store.cart.updateItem({
1514
1578
  _id: item._id,
1515
1579
  resources: newResources
1516
1580
  });
@@ -1554,15 +1618,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1554
1618
  }, {
1555
1619
  key: "openProductDetail",
1556
1620
  value: function () {
1557
- var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(productId) {
1621
+ var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
1558
1622
  var targetProduct, targetProductData, newScheduleArr;
1559
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1560
- while (1) switch (_context24.prev = _context24.next) {
1623
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1624
+ while (1) switch (_context25.prev = _context25.next) {
1561
1625
  case 0:
1562
- _context24.next = 2;
1626
+ _context25.next = 2;
1563
1627
  return this.store.products.getProduct(productId);
1564
1628
  case 2:
1565
- targetProduct = _context24.sent;
1629
+ targetProduct = _context25.sent;
1566
1630
  if (targetProduct) {
1567
1631
  targetProductData = targetProduct.getData();
1568
1632
  this.store.currentProduct = targetProduct;
@@ -1571,11 +1635,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1571
1635
  }
1572
1636
  case 4:
1573
1637
  case "end":
1574
- return _context24.stop();
1638
+ return _context25.stop();
1575
1639
  }
1576
- }, _callee24, this);
1640
+ }, _callee25, this);
1577
1641
  }));
1578
- function openProductDetail(_x16) {
1642
+ function openProductDetail(_x18) {
1579
1643
  return _openProductDetail.apply(this, arguments);
1580
1644
  }
1581
1645
  return openProductDetail;
@@ -1590,8 +1654,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1590
1654
  }, {
1591
1655
  key: "getTimeslotBySchedule",
1592
1656
  value: function getTimeslotBySchedule(_ref12) {
1657
+ var _this$store$currentPr2;
1593
1658
  var date = _ref12.date,
1594
- scheduleIds = _ref12.scheduleIds;
1659
+ scheduleIds = _ref12.scheduleIds,
1660
+ resources = _ref12.resources;
1595
1661
  var targetProduct = this.store.currentProduct;
1596
1662
  var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
1597
1663
  var targetSchedules = [];
@@ -1605,28 +1671,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1605
1671
  var targetResourceDate = resourcesDates.find(function (n) {
1606
1672
  return n.date === date;
1607
1673
  });
1674
+ var cartItems = this.store.cart.getItems();
1675
+ var resourcesMap = getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []);
1676
+ var selectedResources = getOthersSelectedResources(cartItems, '', resourcesMap);
1677
+ var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$currentPr2 = this.store.currentProduct) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.getData()) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.product_resource) === null || _this$store$currentPr2 === void 0 ? void 0 : _this$store$currentPr2.resources) || [], selectedResources, 1);
1608
1678
  var minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, date);
1609
1679
  var scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime);
1610
- console.log('scheduleTimeSlots:', scheduleTimeSlots, targetResourceDate);
1680
+ console.log('scheduleTimeSlots:', scheduleTimeSlots, productResources);
1681
+ // 当前所有待选择资源的集合,先提出来,提升性能
1682
+ var allProductResources = productResources.flatMap(function (n) {
1683
+ return n.renderList;
1684
+ });
1685
+ // 计算每个日程切片下日程可用的资源的容量总和
1611
1686
  var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
1612
- var _targetResourceDate$r;
1613
- console.log(item);
1614
1687
  var count = 0;
1615
- targetResourceDate === null || targetResourceDate === void 0 || (_targetResourceDate$r = targetResourceDate.resource) === null || _targetResourceDate$r === void 0 || _targetResourceDate$r.forEach(function (n) {
1616
- var res = getIsUsableByTimeItem({
1617
- timeSlice: {
1618
- start_time: item.start,
1619
- end_time: item.end,
1620
- start_at: dayjs(item.start),
1621
- end_at: dayjs(item.end)
1622
- },
1623
- time: item,
1624
- resource: n,
1625
- currentCount: 1
1688
+ // 遍历所有资源
1689
+ allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
1690
+ // 遍历所有资源的上工时间片
1691
+ m.times.forEach(function (childTiem) {
1692
+ // 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
1693
+ var res = getIsUsableByTimeItem({
1694
+ timeSlice: {
1695
+ start_time: item.start,
1696
+ end_time: item.end,
1697
+ start_at: dayjs(item.start),
1698
+ end_at: dayjs(item.end)
1699
+ },
1700
+ time: childTiem,
1701
+ resource: m,
1702
+ currentCount: 1
1703
+ });
1704
+ // 如果资源可用,且是独占资源,remainingCapacity 始终为 1
1705
+ if (res.usable) {
1706
+ count += (res === null || res === void 0 ? void 0 : res.remainingCapacity) || 0;
1707
+ }
1626
1708
  });
1627
- if (res.usable) {
1628
- count += 1;
1629
- }
1630
1709
  });
1631
1710
  var startDayJs = dayjs(item.start);
1632
1711
  var endDayJs = dayjs(item.end);
@@ -1683,29 +1762,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1683
1762
  }, {
1684
1763
  key: "getProductTypeById",
1685
1764
  value: function () {
1686
- var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(id) {
1765
+ var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
1687
1766
  var product;
1688
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1689
- while (1) switch (_context25.prev = _context25.next) {
1767
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1768
+ while (1) switch (_context26.prev = _context26.next) {
1690
1769
  case 0:
1691
- _context25.next = 2;
1770
+ _context26.next = 2;
1692
1771
  return this.store.products.getProduct(id);
1693
1772
  case 2:
1694
- product = _context25.sent;
1773
+ product = _context26.sent;
1695
1774
  if (!product) {
1696
- _context25.next = 5;
1775
+ _context26.next = 5;
1697
1776
  break;
1698
1777
  }
1699
- return _context25.abrupt("return", product.getProductType());
1778
+ return _context26.abrupt("return", product.getProductType());
1700
1779
  case 5:
1701
- return _context25.abrupt("return", 'normal');
1780
+ return _context26.abrupt("return", 'normal');
1702
1781
  case 6:
1703
1782
  case "end":
1704
- return _context25.stop();
1783
+ return _context26.stop();
1705
1784
  }
1706
- }, _callee25, this);
1785
+ }, _callee26, this);
1707
1786
  }));
1708
- function getProductTypeById(_x17) {
1787
+ function getProductTypeById(_x19) {
1709
1788
  return _getProductTypeById.apply(this, arguments);
1710
1789
  }
1711
1790
  return getProductTypeById;