@pisell/pisellos 0.0.15 → 0.0.17

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 (45) hide show
  1. package/dist/modules/AccountList/index.d.ts +5 -1
  2. package/dist/modules/AccountList/index.js +92 -39
  3. package/dist/modules/AccountList/types.d.ts +1 -0
  4. package/dist/modules/BaseModule.d.ts +6 -0
  5. package/dist/modules/BaseModule.js +41 -0
  6. package/dist/modules/Cart/index.d.ts +8 -0
  7. package/dist/modules/Cart/index.js +45 -6
  8. package/dist/modules/Cart/utils.js +14 -0
  9. package/dist/modules/Date/index.d.ts +5 -0
  10. package/dist/modules/Date/index.js +35 -2
  11. package/dist/modules/Discount/index.d.ts +4 -0
  12. package/dist/modules/Discount/index.js +32 -4
  13. package/dist/modules/Discount/types.d.ts +3 -0
  14. package/dist/modules/Rules/index.js +8 -5
  15. package/dist/modules/Step/index.d.ts +4 -0
  16. package/dist/modules/Step/index.js +29 -1
  17. package/dist/modules/Summary/index.d.ts +4 -0
  18. package/dist/modules/Summary/index.js +28 -2
  19. package/dist/solution/BookingByStep/index.d.ts +13 -2
  20. package/dist/solution/BookingByStep/index.js +194 -117
  21. package/dist/solution/BookingByStep/types.js +0 -3
  22. package/dist/solution/ShopDiscount/index.js +24 -3
  23. package/lib/modules/AccountList/index.d.ts +5 -1
  24. package/lib/modules/AccountList/index.js +34 -1
  25. package/lib/modules/AccountList/types.d.ts +1 -0
  26. package/lib/modules/BaseModule.d.ts +6 -0
  27. package/lib/modules/BaseModule.js +37 -0
  28. package/lib/modules/Cart/index.d.ts +8 -0
  29. package/lib/modules/Cart/index.js +26 -1
  30. package/lib/modules/Cart/utils.js +14 -0
  31. package/lib/modules/Date/index.d.ts +5 -0
  32. package/lib/modules/Date/index.js +21 -0
  33. package/lib/modules/Discount/index.d.ts +4 -0
  34. package/lib/modules/Discount/index.js +19 -0
  35. package/lib/modules/Discount/types.d.ts +3 -0
  36. package/lib/modules/Rules/index.js +10 -5
  37. package/lib/modules/Step/index.d.ts +4 -0
  38. package/lib/modules/Step/index.js +19 -0
  39. package/lib/modules/Summary/index.d.ts +4 -0
  40. package/lib/modules/Summary/index.js +17 -0
  41. package/lib/solution/BookingByStep/index.d.ts +13 -2
  42. package/lib/solution/BookingByStep/index.js +74 -7
  43. package/lib/solution/BookingByStep/types.js +0 -3
  44. package/lib/solution/ShopDiscount/index.js +21 -3
  45. package/package.json +1 -1
@@ -6,9 +6,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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
+ 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; }
9
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; }
10
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- 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; }
12
12
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
13
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -55,8 +55,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
55
55
  key: "initialize",
56
56
  value: function () {
57
57
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
58
- var _this2 = this;
59
- var moduleArr;
58
+ var _this$otherParams,
59
+ _this2 = this;
60
+ var targetCacheData, sessionData, data, moduleArr;
60
61
  return _regeneratorRuntime().wrap(function _callee$(_context) {
61
62
  while (1) switch (_context.prev = _context.next) {
62
63
  case 0:
@@ -74,18 +75,37 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
74
75
  }
75
76
  throw new Error("bookingByStep解决方案需要 request 插件支持");
76
77
  case 9:
77
- moduleArr = ["cart", "summary", "step", "products", "guests", "date", "accountList", "order", "payment"];
78
+ // 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
79
+ // 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
80
+ targetCacheData = {};
81
+ if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.cacheId) {
82
+ sessionData = this.window.sessionStorage.getItem(this.name);
83
+ if (sessionData) {
84
+ data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
85
+ // 如果匹配到了,则把 sessionData 里的数据按模块塞到 store 里去
86
+ targetCacheData = data[this.otherParams.cacheId];
87
+ }
88
+ }
89
+ moduleArr = ["accountList", "cart", "summary", "step", "products", "date", "order", "payment"];
78
90
  moduleArr.forEach(function (step) {
79
91
  var targetModule = createModule(step, _this2.name);
80
92
  if (targetModule) {
93
+ var _this2$otherParams, _this2$otherParams2;
81
94
  _this2.store[step] = targetModule;
82
- _this2.core.registerModule(targetModule);
95
+ _this2.core.registerModule(targetModule, {
96
+ initialState: targetCacheData[targetModule.name],
97
+ otherParams: _objectSpread(_objectSpread({}, _this2.otherParams), {}, {
98
+ fatherModule: _this2.name,
99
+ openCache: (_this2$otherParams = _this2.otherParams) !== null && _this2$otherParams !== void 0 && _this2$otherParams.cacheId ? true : false,
100
+ cacheId: (_this2$otherParams2 = _this2.otherParams) === null || _this2$otherParams2 === void 0 ? void 0 : _this2$otherParams2.cacheId
101
+ })
102
+ });
83
103
  } else {
84
104
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
85
105
  }
86
106
  });
87
107
  this.core.effects.emit(BookingByStepHooks.onInited, {});
88
- case 12:
108
+ case 14:
89
109
  case "end":
90
110
  return _context.stop();
91
111
  }
@@ -163,6 +183,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
163
183
  category_ids: category_ids,
164
184
  ids: product_ids,
165
185
  collection: collection
186
+ }, {
187
+ useCache: true
166
188
  });
167
189
  case 3:
168
190
  productsData = _context2.sent;
@@ -307,50 +329,45 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
307
329
  return _setDateRange.apply(this, arguments);
308
330
  }
309
331
  return setDateRange;
310
- }() // 获取日期模块里选中的日期
332
+ }()
311
333
  }, {
312
- key: "getRangeDate",
334
+ key: "clearDateRange",
335
+ value: function clearDateRange() {
336
+ this.store.date.clearDateRange();
337
+ }
338
+
339
+ // 获取日期模块里选中的日期
340
+ }, {
341
+ key: "getDateRange",
313
342
  value: function () {
314
- var _getRangeDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
343
+ var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
315
344
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
316
345
  while (1) switch (_context7.prev = _context7.next) {
317
346
  case 0:
318
- return _context7.abrupt("return", "2024-01-01");
347
+ return _context7.abrupt("return", this.store.date.getDateRange());
319
348
  case 1:
320
349
  case "end":
321
350
  return _context7.stop();
322
351
  }
323
- }, _callee7);
352
+ }, _callee7, this);
324
353
  }));
325
- function getRangeDate() {
326
- return _getRangeDate.apply(this, arguments);
354
+ function getDateRange() {
355
+ return _getDateRange.apply(this, arguments);
327
356
  }
328
- return getRangeDate;
357
+ return getDateRange;
329
358
  }()
330
359
  }, {
331
360
  key: "getCart",
332
- value: function () {
333
- var _getCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
334
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
335
- while (1) switch (_context8.prev = _context8.next) {
336
- case 0:
337
- return _context8.abrupt("return", this.store.cart.getItems());
338
- case 1:
339
- case "end":
340
- return _context8.stop();
341
- }
342
- }, _callee8, this);
343
- }));
344
- function getCart() {
345
- return _getCart.apply(this, arguments);
346
- }
347
- return getCart;
348
- }() // 获取商品/服务的可用日期
361
+ value: function getCart() {
362
+ return this.store.cart.getItems();
363
+ }
364
+
365
+ // 获取商品/服务的可用日期
349
366
  }, {
350
367
  key: "getAvailableDate",
351
368
  value: function () {
352
- var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
353
- var _this$otherParams, _this$otherParams2;
369
+ var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
370
+ var _this$otherParams2, _this$otherParams3;
354
371
  var params,
355
372
  products,
356
373
  startDate,
@@ -363,29 +380,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
363
380
  rules,
364
381
  resourcesMap,
365
382
  res,
366
- _args9 = arguments;
367
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
368
- while (1) switch (_context9.prev = _context9.next) {
383
+ _args8 = arguments;
384
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
385
+ while (1) switch (_context8.prev = _context8.next) {
369
386
  case 0:
370
- params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
387
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
371
388
  // 开始日期如果小于今天,直接以今天当做开始日期
372
389
  products = params.products, startDate = params.startDate, endDate = params.endDate;
373
390
  tempProducts = products || this.store.cart.getItems().map(function (p) {
374
391
  return p._productOrigin;
375
392
  });
376
- tempStartDate = startDate || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams = _this$otherParams.dateRange) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams[0]);
377
- tempEndDate = endDate || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 || (_this$otherParams2 = _this$otherParams2.dateRange) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2[1]);
393
+ tempStartDate = startDate || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 || (_this$otherParams2 = _this$otherParams2.dateRange) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2[0]);
394
+ tempEndDate = endDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[1]);
378
395
  if (tempProducts.length) {
379
- _context9.next = 7;
396
+ _context8.next = 7;
380
397
  break;
381
398
  }
382
- return _context9.abrupt("return", []);
399
+ return _context8.abrupt("return", []);
383
400
  case 7:
384
401
  // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
385
402
  _ref3 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref3.resourceIds, rules = _ref3.rules, resourcesMap = _ref3.resourcesMap;
386
403
  console.log("resourceIds", tempProducts);
387
404
  this.otherParams.currentResourcesMap = resourcesMap;
388
- _context9.next = 12;
405
+ _context8.next = 12;
389
406
  return this.store.date.getMonthDates({
390
407
  query: {
391
408
  start_date: tempStartDate,
@@ -395,13 +412,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
395
412
  rules: rules
396
413
  });
397
414
  case 12:
398
- res = _context9.sent;
399
- return _context9.abrupt("return", res);
415
+ res = _context8.sent;
416
+ return _context8.abrupt("return", res);
400
417
  case 14:
401
418
  case "end":
402
- return _context9.stop();
419
+ return _context8.stop();
403
420
  }
404
- }, _callee9, this);
421
+ }, _callee8, this);
405
422
  }));
406
423
  function getAvailableDate() {
407
424
  return _getAvailableDate.apply(this, arguments);
@@ -414,22 +431,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
414
431
  }, {
415
432
  key: "getSummary",
416
433
  value: (function () {
417
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
434
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
418
435
  var cartItems, summary;
419
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
420
- while (1) switch (_context10.prev = _context10.next) {
436
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
437
+ while (1) switch (_context9.prev = _context9.next) {
421
438
  case 0:
422
439
  cartItems = this.store.cart.getItems();
423
- _context10.next = 3;
440
+ _context9.next = 3;
424
441
  return this.store.summary.getSummary(cartItems);
425
442
  case 3:
426
- summary = _context10.sent;
427
- return _context10.abrupt("return", summary);
443
+ summary = _context9.sent;
444
+ return _context9.abrupt("return", summary);
428
445
  case 5:
429
446
  case "end":
430
- return _context10.stop();
447
+ return _context9.stop();
431
448
  }
432
- }, _callee10, this);
449
+ }, _callee9, this);
433
450
  }));
434
451
  function getSummary() {
435
452
  return _getSummary.apply(this, arguments);
@@ -440,16 +457,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
440
457
  }, {
441
458
  key: "getProducts",
442
459
  value: function () {
443
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
444
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
445
- while (1) switch (_context11.prev = _context11.next) {
460
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
461
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
462
+ while (1) switch (_context10.prev = _context10.next) {
446
463
  case 0:
447
- return _context11.abrupt("return", this.store.products.getProducts());
464
+ return _context10.abrupt("return", this.store.products.getProducts());
448
465
  case 1:
449
466
  case "end":
450
- return _context11.stop();
467
+ return _context10.stop();
451
468
  }
452
- }, _callee11, this);
469
+ }, _callee10, this);
453
470
  }));
454
471
  function getProducts() {
455
472
  return _getProducts.apply(this, arguments);
@@ -459,15 +476,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
459
476
  }, {
460
477
  key: "setLoginAccount",
461
478
  value: function () {
462
- var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(accountId, accountInfo) {
479
+ var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(accountId, accountInfo) {
463
480
  var _this4 = this;
464
481
  var account, cartItems;
465
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
466
- while (1) switch (_context12.prev = _context12.next) {
482
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
483
+ while (1) switch (_context11.prev = _context11.next) {
467
484
  case 0:
468
485
  account = this.store.accountList.getAccount(accountId);
469
486
  if (!account) {
470
- _context12.next = 7;
487
+ _context11.next = 7;
471
488
  break;
472
489
  }
473
490
  account.setAccountInfo(accountInfo);
@@ -481,15 +498,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
481
498
  });
482
499
  }
483
500
  });
484
- _context12.next = 8;
501
+ _context11.next = 8;
485
502
  break;
486
503
  case 7:
487
504
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
488
505
  case 8:
489
506
  case "end":
490
- return _context12.stop();
507
+ return _context11.stop();
491
508
  }
492
- }, _callee12, this);
509
+ }, _callee11, this);
493
510
  }));
494
511
  function setLoginAccount(_x7, _x8) {
495
512
  return _setLoginAccount.apply(this, arguments);
@@ -499,14 +516,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
499
516
  }, {
500
517
  key: "generateCartData",
501
518
  value: function () {
502
- var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
503
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
504
- while (1) switch (_context13.prev = _context13.next) {
519
+ var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
520
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
521
+ while (1) switch (_context12.prev = _context12.next) {
505
522
  case 0:
506
523
  case "end":
507
- return _context13.stop();
524
+ return _context12.stop();
508
525
  }
509
- }, _callee13);
526
+ }, _callee12);
510
527
  }));
511
528
  function generateCartData() {
512
529
  return _generateCartData.apply(this, arguments);
@@ -516,10 +533,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
516
533
  }, {
517
534
  key: "submitOrder",
518
535
  value: function () {
519
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
536
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
520
537
  var cartItems;
521
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
522
- while (1) switch (_context14.prev = _context14.next) {
538
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
539
+ while (1) switch (_context13.prev = _context13.next) {
523
540
  case 0:
524
541
  cartItems = this.store.cart.getItems(); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
525
542
  cartItems.forEach(function (item) {
@@ -531,16 +548,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
531
548
  return _objectSpread({}, newResourcesItem);
532
549
  });
533
550
  });
534
- return _context14.abrupt("return", this.store.order.commitOrder({
551
+ return _context13.abrupt("return", this.store.order.commitOrder({
535
552
  query: {
536
553
  cartItems: cartItems
537
554
  }
538
555
  }));
539
556
  case 3:
540
557
  case "end":
541
- return _context14.stop();
558
+ return _context13.stop();
542
559
  }
543
- }, _callee14, this);
560
+ }, _callee13, this);
544
561
  }));
545
562
  function submitOrder() {
546
563
  return _submitOrder.apply(this, arguments);
@@ -550,14 +567,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
550
567
  }, {
551
568
  key: "pay",
552
569
  value: function () {
553
- var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
554
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
555
- while (1) switch (_context15.prev = _context15.next) {
570
+ var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
571
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
572
+ while (1) switch (_context14.prev = _context14.next) {
556
573
  case 0:
557
574
  case "end":
558
- return _context15.stop();
575
+ return _context14.stop();
559
576
  }
560
- }, _callee15);
577
+ }, _callee14);
561
578
  }));
562
579
  function pay() {
563
580
  return _pay.apply(this, arguments);
@@ -567,14 +584,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
567
584
  }, {
568
585
  key: "getPayInfo",
569
586
  value: function () {
570
- var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
571
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
572
- while (1) switch (_context16.prev = _context16.next) {
587
+ var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
588
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
589
+ while (1) switch (_context15.prev = _context15.next) {
573
590
  case 0:
574
591
  case "end":
575
- return _context16.stop();
592
+ return _context15.stop();
576
593
  }
577
- }, _callee16);
594
+ }, _callee15);
578
595
  }));
579
596
  function getPayInfo() {
580
597
  return _getPayInfo.apply(this, arguments);
@@ -584,15 +601,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
584
601
  }, {
585
602
  key: "setOtherParams",
586
603
  value: function () {
587
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
604
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
588
605
  var _ref4,
589
606
  _ref4$cover,
590
607
  cover,
591
- _args17 = arguments;
592
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
593
- while (1) switch (_context17.prev = _context17.next) {
608
+ _args16 = arguments;
609
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
610
+ while (1) switch (_context16.prev = _context16.next) {
594
611
  case 0:
595
- _ref4 = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
612
+ _ref4 = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
596
613
  if (cover) {
597
614
  this.otherParams = params;
598
615
  } else {
@@ -600,9 +617,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
600
617
  }
601
618
  case 2:
602
619
  case "end":
603
- return _context17.stop();
620
+ return _context16.stop();
604
621
  }
605
- }, _callee17, this);
622
+ }, _callee16, this);
606
623
  }));
607
624
  function setOtherParams(_x9) {
608
625
  return _setOtherParams.apply(this, arguments);
@@ -612,16 +629,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
612
629
  }, {
613
630
  key: "getOtherParams",
614
631
  value: function () {
615
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
616
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
617
- while (1) switch (_context18.prev = _context18.next) {
632
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
633
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
634
+ while (1) switch (_context17.prev = _context17.next) {
618
635
  case 0:
619
- return _context18.abrupt("return", this.otherParams);
636
+ return _context17.abrupt("return", this.otherParams);
620
637
  case 1:
621
638
  case "end":
622
- return _context18.stop();
639
+ return _context17.stop();
623
640
  }
624
- }, _callee18, this);
641
+ }, _callee17, this);
625
642
  }));
626
643
  function getOtherParams() {
627
644
  return _getOtherParams.apply(this, arguments);
@@ -631,7 +648,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
631
648
  }, {
632
649
  key: "updateCart",
633
650
  value: function updateCart(params) {
651
+ var _this5 = this;
634
652
  this.store.cart.updateItem(params);
653
+ var targetCartItem = this.store.cart.getItem(params._id);
654
+ if (!targetCartItem) {
655
+ throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
656
+ }
657
+ // 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,则要把选择了相同资源的 product._origin.resources 给去除
658
+ var cartItems = this.store.cart.getItems();
659
+ cartItems.forEach(function (item) {
660
+ if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
661
+ var _item$_origin$resourc;
662
+ var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
663
+ return !targetCartItem._origin.resources.some(function (targetRes) {
664
+ return targetRes.id === m.id;
665
+ });
666
+ });
667
+ _this5.store.cart.updateItem({
668
+ _id: item._id,
669
+ resources: resources
670
+ });
671
+ }
672
+ });
635
673
  }
636
674
 
637
675
  // 删除购物车里某个商品
@@ -661,10 +699,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
661
699
  }, {
662
700
  key: "batchUpdateCart",
663
701
  value: function batchUpdateCart(paramsList) {
664
- var _this5 = this;
702
+ var _this6 = this;
665
703
  var cartItems = [];
666
704
  paramsList.forEach(function (params) {
667
- var cartItem = _this5.store.cart.formatCartItem(params);
705
+ var cartItem = _this6.store.cart.formatCartItem(params);
668
706
  cartItems.push(cartItem);
669
707
  });
670
708
  this.store.cart.batchSetItems(cartItems);
@@ -720,6 +758,39 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
720
758
  return arr;
721
759
  }
722
760
 
761
+ // 给单个购物车里的商品获取资源列表
762
+ }, {
763
+ key: "getResourcesListByCartItem",
764
+ value: function getResourcesListByCartItem(id) {
765
+ var cartItems = this.store.cart.getItems();
766
+ var dateRange = this.store.date.getDateRange();
767
+ var resources = [];
768
+ dateRange.forEach(function (n) {
769
+ if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
770
+ });
771
+ var resourcesMap = getResourcesMap(resources);
772
+ var arr = [];
773
+ var targetCartItem = cartItems.find(function (n) {
774
+ return n._id === id;
775
+ });
776
+ if (!targetCartItem) {
777
+ throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
778
+ }
779
+ var productResources = getResourcesByProduct(resourcesMap, targetCartItem, cartItems);
780
+ if (productResources) {
781
+ return {
782
+ id: targetCartItem.id,
783
+ // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
784
+ _id: targetCartItem._id,
785
+ // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
786
+ product: targetCartItem._productOrigin,
787
+ resources: productResources,
788
+ holder_id: targetCartItem.holder_id,
789
+ holder_name: targetCartItem.holder_title
790
+ };
791
+ }
792
+ }
793
+
723
794
  // 通过资源列表和指定的资源 id,获取指定资源的时间切片
724
795
  }, {
725
796
  key: "getResourceTimeSlot",
@@ -914,7 +985,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
914
985
  }, {
915
986
  key: "autoSelectAllProductResources",
916
987
  value: function autoSelectAllProductResources(resources_code, timeSlots) {
917
- var _this6 = this;
988
+ var _this7 = this;
918
989
  var dateRange = this.store.date.getDateRange();
919
990
  var resources = [];
920
991
  dateRange.forEach(function (n) {
@@ -924,27 +995,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
924
995
  // 一个账号一个账号处理
925
996
  var errorList = [];
926
997
  this.store.accountList.getAccounts().forEach(function (account) {
927
- var cartItems = _this6.store.cart.getCartByAccount(account.getId());
998
+ var cartItems = _this7.store.cart.getCartByAccount(account.getId());
928
999
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
929
- var allCartItems = _this6.store.cart.getItems();
1000
+ var allCartItems = _this7.store.cart.getItems();
930
1001
  cartItems.forEach(function (item) {
931
1002
  if (timeSlots) {
932
1003
  // 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
933
- var res = _this6.autoSelectAccountResources({
1004
+ var res = _this7.autoSelectAccountResources({
934
1005
  holder_id: item.holder_id,
935
1006
  resources_code: resources_code,
936
1007
  timeSlots: timeSlots
937
1008
  });
938
1009
  if (res !== null && res !== void 0 && res.selectedResource) {
939
- console.log(_this6.store.cart.getItems());
940
- _this6.store.cart.updateItem({
1010
+ console.log(_this7.store.cart.getItems());
1011
+ _this7.store.cart.updateItem({
941
1012
  _id: item._id,
942
1013
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
943
1014
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
944
1015
  return existingRes.form_id !== res.selectedResource.form_id;
945
1016
  })), [res.selectedResource])
946
1017
  });
947
- console.log(_this6.store.cart.getItems());
1018
+ console.log(_this7.store.cart.getItems());
948
1019
  } else {
949
1020
  // 如果没有可用的技师了,推到错误列表里让 UI 去提示
950
1021
  errorList.push(item._id);
@@ -958,7 +1029,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
958
1029
  return n.code === resources_code;
959
1030
  })) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
960
1031
  if (targetRenderList && targetRenderList.length > 0) {
961
- _this6.store.cart.updateItem({
1032
+ _this7.store.cart.updateItem({
962
1033
  _id: item._id,
963
1034
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
964
1035
  return existingRes.resourceType !== targetRenderList[0].resourceType;
@@ -979,20 +1050,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
979
1050
  }, {
980
1051
  key: "getTimeSlotByAllResources",
981
1052
  value: function getTimeSlotByAllResources(resources_code) {
982
- var _this7 = this;
1053
+ var _this8 = this;
983
1054
  var dateRange = this.store.date.getDateRange();
984
1055
  // 取出购物车中所有一已选择的第一步资源
985
1056
  var resources = [];
986
1057
  var cartItems = this.store.cart.getItems();
987
1058
  var resourceIds = [];
988
1059
  cartItems.forEach(function (item) {
989
- var _item$_productOrigin2, _item$_origin$resourc;
1060
+ var _item$_productOrigin2, _item$_origin$resourc2;
990
1061
  (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.product_resource) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.resources) === null || _item$_productOrigin2 === void 0 || _item$_productOrigin2.forEach(function (n) {
991
1062
  if (n.code === resources_code) {
992
1063
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
993
1064
  }
994
1065
  });
995
- (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 || _item$_origin$resourc.forEach(function (n) {
1066
+ (_item$_origin$resourc2 = item._origin.resources) === null || _item$_origin$resourc2 === void 0 || _item$_origin$resourc2.forEach(function (n) {
996
1067
  resourceIds.push(n.relation_id);
997
1068
  });
998
1069
  });
@@ -1001,7 +1072,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1001
1072
  // duration = 不同账号的最长时间
1002
1073
  this.store.accountList.getAccounts().forEach(function (account) {
1003
1074
  var accountDuration = 0;
1004
- var cartItems = _this7.store.cart.getCartByAccount(account.getId());
1075
+ var cartItems = _this8.store.cart.getCartByAccount(account.getId());
1005
1076
  cartItems.forEach(function (item) {
1006
1077
  var _item$_productOrigin$, _item$_productOrigin3;
1007
1078
  accountDuration += (_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0;
@@ -1049,7 +1120,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1049
1120
  }, {
1050
1121
  key: "submitTimeSlot",
1051
1122
  value: function submitTimeSlot(timeSlots) {
1052
- var _this8 = this;
1123
+ var _this9 = this;
1053
1124
  var cartItems = this.store.cart.getItems();
1054
1125
  cartItems.forEach(function (item) {
1055
1126
  var newResources = cloneDeep(item._origin.resources);
@@ -1059,12 +1130,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1059
1130
  n.endTime = dayjs(n.startTime).add((_item$_productOrigin$2 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref8 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref8 !== void 0 ? _ref8 : "minutes").format("YYYY-MM-DD HH:mm");
1060
1131
  delete n.times;
1061
1132
  });
1062
- _this8.store.cart.updateItem({
1133
+ _this9.store.cart.updateItem({
1063
1134
  _id: item._id,
1064
1135
  resources: newResources
1065
1136
  });
1066
1137
  });
1067
1138
  }
1139
+ }, {
1140
+ key: "clearCache",
1141
+ value: function clearCache() {}
1142
+ }, {
1143
+ key: "clearCacheByModule",
1144
+ value: function clearCacheByModule(module) {}
1068
1145
  }]);
1069
1146
  return BookingByStepImpl;
1070
1147
  }(BaseModule);