@pisell/pisellos 0.0.44 → 0.0.46
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.
- package/dist/modules/Account/index.d.ts +2 -6
- package/dist/modules/Account/index.js +21 -103
- package/dist/modules/Account/types.d.ts +12 -1
- package/dist/modules/AccountList/index.d.ts +20 -1
- package/dist/modules/AccountList/index.js +243 -75
- package/dist/modules/AccountList/types.d.ts +33 -1
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/AccountList/utils.d.ts +9 -0
- package/dist/modules/AccountList/utils.js +25 -0
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +1 -1
- package/dist/modules/Cart/index.d.ts +5 -5
- package/dist/modules/Cart/index.js +33 -19
- package/dist/modules/Cart/types.d.ts +21 -7
- package/dist/modules/Cart/utils.d.ts +29 -5
- package/dist/modules/Cart/utils.js +72 -26
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -55
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +74 -23
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +10 -5
- package/dist/modules/Order/index.js +32 -16
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Product/index.d.ts +4 -1
- package/dist/modules/Product/index.js +22 -0
- package/dist/modules/Product/types.d.ts +7 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +4 -4
- package/dist/modules/Rules/index.js +11 -11
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/index.d.ts +8 -3
- package/dist/modules/Schedule/index.js +45 -5
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +8 -8
- package/dist/modules/Schedule/utils.d.ts +9 -3
- package/dist/modules/Schedule/utils.js +77 -48
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +5 -5
- package/dist/modules/Summary/index.js +7 -7
- package/dist/modules/Summary/types.d.ts +2 -2
- package/dist/modules/Summary/utils.d.ts +4 -4
- package/dist/modules/Summary/utils.js +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/request.d.ts +3 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +71 -16
- package/dist/solution/BookingByStep/index.js +643 -227
- package/dist/solution/BookingByStep/types.d.ts +2 -2
- package/dist/solution/BookingByStep/types.js +9 -9
- package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/products.js +3 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +6 -5
- package/dist/solution/BookingByStep/utils/resources.js +37 -19
- package/dist/solution/ShopDiscount/index.d.ts +4 -4
- package/dist/solution/ShopDiscount/index.js +16 -16
- package/dist/solution/ShopDiscount/types.d.ts +2 -2
- package/dist/solution/ShopDiscount/utils.js +1 -1
- package/lib/core/index.js +7 -2
- package/lib/modules/Account/index.d.ts +2 -6
- package/lib/modules/Account/index.js +15 -30
- package/lib/modules/Account/types.d.ts +12 -1
- package/lib/modules/AccountList/index.d.ts +20 -1
- package/lib/modules/AccountList/index.js +122 -13
- package/lib/modules/AccountList/types.d.ts +33 -1
- package/lib/modules/AccountList/utils.d.ts +9 -0
- package/lib/modules/AccountList/utils.js +39 -0
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +14 -3
- package/lib/modules/Cart/index.d.ts +5 -5
- package/lib/modules/Cart/index.js +28 -6
- package/lib/modules/Cart/types.d.ts +21 -7
- package/lib/modules/Cart/utils.d.ts +29 -5
- package/lib/modules/Cart/utils.js +47 -3
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +6 -6
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +37 -6
- package/lib/modules/Discount/index.d.ts +4 -4
- package/lib/modules/Discount/index.js +9 -2
- package/lib/modules/Guests/index.js +4 -1
- package/lib/modules/Order/index.d.ts +10 -5
- package/lib/modules/Order/index.js +11 -1
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +4 -1
- package/lib/modules/Product/index.js +16 -0
- package/lib/modules/Product/types.d.ts +7 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +4 -4
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.d.ts +8 -3
- package/lib/modules/Schedule/index.js +33 -2
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +8 -8
- package/lib/modules/Schedule/utils.d.ts +9 -3
- package/lib/modules/Schedule/utils.js +32 -4
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +5 -5
- package/lib/modules/Summary/types.d.ts +2 -2
- package/lib/modules/Summary/utils.d.ts +4 -4
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/request.d.ts +3 -3
- package/lib/plugins/request.js +48 -11
- package/lib/plugins/shopStore.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +71 -16
- package/lib/solution/BookingByStep/index.js +396 -48
- package/lib/solution/BookingByStep/types.d.ts +2 -2
- package/lib/solution/BookingByStep/types.js +36 -9
- package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/products.js +3 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +6 -5
- package/lib/solution/BookingByStep/utils/resources.js +128 -58
- package/lib/solution/BuyTickets/index.js +34 -20
- package/lib/solution/ShopDiscount/index.d.ts +4 -4
- package/lib/solution/ShopDiscount/index.js +10 -2
- package/lib/solution/ShopDiscount/types.d.ts +2 -2
- package/package.json +4 -2
|
@@ -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; }
|
|
@@ -28,9 +28,11 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import { BookingByStepHooks, createModule } from "./types";
|
|
29
29
|
import { getAvailableProductResources } from "./utils/products";
|
|
30
30
|
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, formatDefaultCapacitys, getSumCapacity, checkSubResourcesCapacity } from "./utils/resources";
|
|
31
|
-
import dayjs from
|
|
31
|
+
import dayjs from 'dayjs';
|
|
32
32
|
import { getResourcesMap } from "../../modules/Resource/utils";
|
|
33
|
-
import { cloneDeep } from
|
|
33
|
+
import { cloneDeep } from 'lodash-es';
|
|
34
|
+
import { calcCalendarDataByScheduleResult, calcMinTimeMaxTimeBySchedules, getAllSortedDateRanges } from "../../modules/Schedule/utils";
|
|
35
|
+
import { disableAllDates, disableDatesBeforeOneDay, generateMonthDates } from "../../modules/Date/utils";
|
|
34
36
|
export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
35
37
|
_inherits(BookingByStepImpl, _BaseModule);
|
|
36
38
|
var _super = _createSuper(BookingByStepImpl);
|
|
@@ -41,8 +43,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
41
43
|
args[_key] = arguments[_key];
|
|
42
44
|
}
|
|
43
45
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName",
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion",
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'bookingByStep');
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
46
48
|
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
47
49
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
48
50
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
@@ -50,32 +52,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
50
52
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
51
53
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
52
54
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "otherData", {});
|
|
53
56
|
return _this;
|
|
54
57
|
}
|
|
55
58
|
_createClass(BookingByStepImpl, [{
|
|
56
59
|
key: "initialize",
|
|
57
|
-
value:
|
|
60
|
+
value: // 提供给 UI 层的临时数据存储,会进缓存
|
|
61
|
+
function () {
|
|
58
62
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
59
63
|
var _this$otherParams,
|
|
60
64
|
_this$otherParams2,
|
|
61
65
|
_this2 = this;
|
|
62
|
-
var targetCacheData, sessionData, data, moduleArr;
|
|
66
|
+
var targetCacheData, sessionData, _data$this$otherParam, data, moduleArr;
|
|
63
67
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
64
68
|
while (1) switch (_context.prev = _context.next) {
|
|
65
69
|
case 0:
|
|
66
70
|
this.core = core;
|
|
67
71
|
this.store = options.store || {};
|
|
68
72
|
this.otherParams = options.otherParams || {};
|
|
69
|
-
console.log(
|
|
73
|
+
console.log('[BookingByStep] 初始化完成');
|
|
70
74
|
// 获取依赖的插件
|
|
71
|
-
this.request = core.getPlugin(
|
|
72
|
-
this.window = core.getPlugin(
|
|
73
|
-
this.shopStore = core.getPlugin(
|
|
75
|
+
this.request = core.getPlugin('request');
|
|
76
|
+
this.window = core.getPlugin('window');
|
|
77
|
+
this.shopStore = core.getPlugin('shopStore');
|
|
74
78
|
if (this.request) {
|
|
75
79
|
_context.next = 9;
|
|
76
80
|
break;
|
|
77
81
|
}
|
|
78
|
-
throw new Error(
|
|
82
|
+
throw new Error('bookingByStep解决方案需要 request 插件支持');
|
|
79
83
|
case 9:
|
|
80
84
|
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
81
85
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
@@ -87,9 +91,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
87
91
|
data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
88
92
|
// 如果匹配到了,则把 sessionData 里的数据按模块塞到 store 里去
|
|
89
93
|
targetCacheData = data[this.otherParams.cacheId];
|
|
94
|
+
this.otherData = ((_data$this$otherParam = data[this.otherParams.cacheId]) === null || _data$this$otherParam === void 0 || (_data$this$otherParam = _data$this$otherParam[this.name]) === null || _data$this$otherParam === void 0 ? void 0 : _data$this$otherParam['otherData']) || {};
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
|
-
moduleArr = [
|
|
97
|
+
moduleArr = ['accountList', 'cart', 'schedule', 'summary', 'step', 'products', 'date', 'order', 'payment'];
|
|
93
98
|
moduleArr.forEach(function (step) {
|
|
94
99
|
var targetModule = createModule(step, _this2.name);
|
|
95
100
|
if (targetModule) {
|
|
@@ -161,6 +166,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
161
166
|
return this.store.step.getStepList();
|
|
162
167
|
}
|
|
163
168
|
|
|
169
|
+
/**
|
|
170
|
+
* 添加step
|
|
171
|
+
*/
|
|
172
|
+
}, {
|
|
173
|
+
key: "addStep",
|
|
174
|
+
value: function addStep(step, key) {
|
|
175
|
+
this.store.step.addStep(step, key);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 删除step
|
|
180
|
+
*/
|
|
181
|
+
}, {
|
|
182
|
+
key: "removeStep",
|
|
183
|
+
value: function removeStep(key) {
|
|
184
|
+
this.store.step.removeStep(key);
|
|
185
|
+
}
|
|
164
186
|
// 获取购物车里 temp.xxx的方法
|
|
165
187
|
// async getStoreCart(key?: string) {
|
|
166
188
|
// return this.store.cart.getTemp(key);
|
|
@@ -180,9 +202,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
180
202
|
return this.request.post("/product/query", {
|
|
181
203
|
open_quotation: 1,
|
|
182
204
|
open_bundle: 1,
|
|
183
|
-
extension_type: [
|
|
184
|
-
with: [
|
|
185
|
-
status:
|
|
205
|
+
extension_type: ['product_appointment', 'appointment_ticket', 'session_product', 'session_ticket'],
|
|
206
|
+
with: ['category', 'collection', 'resourceRelation'],
|
|
207
|
+
status: 'published',
|
|
186
208
|
num: 500,
|
|
187
209
|
skip: 1,
|
|
188
210
|
category_ids: category_ids,
|
|
@@ -210,37 +232,55 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
210
232
|
}()
|
|
211
233
|
}, {
|
|
212
234
|
key: "loadProductByScheduleDate",
|
|
213
|
-
value: function
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
235
|
+
value: function () {
|
|
236
|
+
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(date) {
|
|
237
|
+
var scheduleList, scheduleIds;
|
|
238
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
239
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
242
|
+
scheduleIds = scheduleList.filter(function (n) {
|
|
243
|
+
return n.date === date;
|
|
244
|
+
}).flatMap(function (n) {
|
|
245
|
+
return n.schedule_id;
|
|
246
|
+
}); // 换了日期就清空购物车,不能购物车里的商品不在同一天
|
|
247
|
+
this.store.cart.clear();
|
|
248
|
+
_context3.next = 5;
|
|
249
|
+
return this.loadProducts({
|
|
250
|
+
schedule_ids: scheduleIds
|
|
251
|
+
});
|
|
252
|
+
case 5:
|
|
253
|
+
return _context3.abrupt("return", _context3.sent);
|
|
254
|
+
case 6:
|
|
255
|
+
case "end":
|
|
256
|
+
return _context3.stop();
|
|
257
|
+
}
|
|
258
|
+
}, _callee3, this);
|
|
259
|
+
}));
|
|
260
|
+
function loadProductByScheduleDate(_x4) {
|
|
261
|
+
return _loadProductByScheduleDate.apply(this, arguments);
|
|
262
|
+
}
|
|
263
|
+
return loadProductByScheduleDate;
|
|
264
|
+
}() // 加载当前店铺下所有 schedule
|
|
226
265
|
}, {
|
|
227
266
|
key: "loadAllSchedule",
|
|
228
267
|
value: function () {
|
|
229
|
-
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
268
|
+
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
269
|
+
var _scheduleList$data;
|
|
230
270
|
var scheduleList;
|
|
231
|
-
return _regeneratorRuntime().wrap(function
|
|
232
|
-
while (1) switch (
|
|
271
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
272
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
233
273
|
case 0:
|
|
234
|
-
|
|
274
|
+
_context4.next = 2;
|
|
235
275
|
return this.request.get("/schedule");
|
|
236
276
|
case 2:
|
|
237
|
-
scheduleList =
|
|
238
|
-
this.store.schedule.setScheduleList(scheduleList.data);
|
|
277
|
+
scheduleList = _context4.sent;
|
|
278
|
+
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
239
279
|
case 4:
|
|
240
280
|
case "end":
|
|
241
|
-
return
|
|
281
|
+
return _context4.stop();
|
|
242
282
|
}
|
|
243
|
-
},
|
|
283
|
+
}, _callee4, this);
|
|
244
284
|
}));
|
|
245
285
|
function loadAllSchedule() {
|
|
246
286
|
return _loadAllSchedule.apply(this, arguments);
|
|
@@ -248,110 +288,213 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
248
288
|
return loadAllSchedule;
|
|
249
289
|
}() // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
250
290
|
}, {
|
|
251
|
-
key: "
|
|
291
|
+
key: "loadScheduleAvailableDate",
|
|
252
292
|
value: function () {
|
|
253
|
-
var
|
|
254
|
-
var
|
|
255
|
-
|
|
256
|
-
|
|
293
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref2) {
|
|
294
|
+
var _res$data$date_list;
|
|
295
|
+
var startDate, endDate, custom_page_id, dates, res;
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
297
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
257
298
|
case 0:
|
|
258
299
|
startDate = _ref2.startDate, endDate = _ref2.endDate, custom_page_id = _ref2.custom_page_id;
|
|
259
|
-
|
|
300
|
+
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
301
|
+
if (dayjs(startDate).isBefore(dayjs())) {
|
|
302
|
+
startDate = dayjs().format('YYYY-MM-DD');
|
|
303
|
+
}
|
|
304
|
+
// 1.生成当前月份的所有日期,默认都不可用
|
|
305
|
+
dates = generateMonthDates(startDate, endDate);
|
|
306
|
+
dates = disableAllDates(dates);
|
|
307
|
+
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
308
|
+
if (!dayjs(endDate).isBefore(dayjs())) {
|
|
309
|
+
_context5.next = 6;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
return _context5.abrupt("return", dates);
|
|
313
|
+
case 6:
|
|
314
|
+
_context5.next = 8;
|
|
260
315
|
return this.request.get("/schedule/product/availability", {
|
|
261
316
|
start_date: startDate,
|
|
262
317
|
end_date: endDate,
|
|
263
318
|
custom_page_id: custom_page_id
|
|
264
319
|
});
|
|
265
|
-
case
|
|
266
|
-
res =
|
|
267
|
-
this.store.schedule.
|
|
268
|
-
|
|
320
|
+
case 8:
|
|
321
|
+
res = _context5.sent;
|
|
322
|
+
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
323
|
+
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
324
|
+
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs()))) {
|
|
325
|
+
_context5.next = 12;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
return _context5.abrupt("return", dates);
|
|
329
|
+
case 12:
|
|
330
|
+
res.data.date_list.forEach(function (n) {
|
|
331
|
+
if (n.schedule_id && n.schedule_id.length) {
|
|
332
|
+
var index = dates.findIndex(function (m) {
|
|
333
|
+
return m.date === n.date;
|
|
334
|
+
});
|
|
335
|
+
if (index !== -1) {
|
|
336
|
+
dates[index].status = 'available';
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
dates = disableDatesBeforeOneDay(dates);
|
|
341
|
+
return _context5.abrupt("return", dates);
|
|
342
|
+
case 15:
|
|
269
343
|
case "end":
|
|
270
|
-
return
|
|
344
|
+
return _context5.stop();
|
|
271
345
|
}
|
|
272
|
-
},
|
|
346
|
+
}, _callee5, this);
|
|
273
347
|
}));
|
|
274
|
-
function
|
|
275
|
-
return
|
|
348
|
+
function loadScheduleAvailableDate(_x5) {
|
|
349
|
+
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
276
350
|
}
|
|
277
|
-
return
|
|
351
|
+
return loadScheduleAvailableDate;
|
|
278
352
|
}()
|
|
279
353
|
}, {
|
|
280
354
|
key: "storeProduct",
|
|
281
355
|
value: function () {
|
|
282
|
-
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
283
|
-
var activeAccount, _ref3, bundle, options, origin, product_variant_id, product;
|
|
284
|
-
return _regeneratorRuntime().wrap(function
|
|
285
|
-
while (1) switch (
|
|
356
|
+
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
|
|
357
|
+
var activeAccount, _ref3, bundle, options, origin, product_variant_id, product, addCartItem;
|
|
358
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
359
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
286
360
|
case 0:
|
|
287
361
|
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
288
362
|
activeAccount = this.getActiveAccount();
|
|
289
|
-
if (activeAccount) {
|
|
290
|
-
_context5.next = 3;
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
throw new Error("没有找到当前账户");
|
|
294
|
-
case 3:
|
|
295
363
|
_ref3 = productData || {}, bundle = _ref3.bundle, options = _ref3.options, origin = _ref3.origin, product_variant_id = _ref3.product_variant_id;
|
|
296
364
|
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
297
365
|
product_variant_id: product_variant_id
|
|
298
366
|
});
|
|
299
|
-
|
|
300
|
-
account: activeAccount,
|
|
367
|
+
addCartItem = {
|
|
301
368
|
product: product,
|
|
302
369
|
bundle: bundle,
|
|
303
370
|
options: options
|
|
304
|
-
}
|
|
371
|
+
};
|
|
372
|
+
if (activeAccount) {
|
|
373
|
+
addCartItem.account = activeAccount;
|
|
374
|
+
}
|
|
375
|
+
this.store.cart.addItem(addCartItem);
|
|
305
376
|
case 6:
|
|
306
377
|
case "end":
|
|
307
|
-
return
|
|
378
|
+
return _context6.stop();
|
|
308
379
|
}
|
|
309
|
-
},
|
|
380
|
+
}, _callee6, this);
|
|
310
381
|
}));
|
|
311
|
-
function storeProduct(
|
|
382
|
+
function storeProduct(_x6) {
|
|
312
383
|
return _storeProduct.apply(this, arguments);
|
|
313
384
|
}
|
|
314
385
|
return storeProduct;
|
|
315
|
-
}() //
|
|
386
|
+
}() // 添加单个账户或者 guest
|
|
316
387
|
}, {
|
|
317
388
|
key: "addAccount",
|
|
318
389
|
value: function () {
|
|
319
|
-
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
320
|
-
var
|
|
321
|
-
return _regeneratorRuntime().wrap(function
|
|
322
|
-
while (1) switch (
|
|
390
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(account, extra) {
|
|
391
|
+
var accountModules, newAccount;
|
|
392
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
393
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
323
394
|
case 0:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
395
|
+
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
396
|
+
_context7.next = 5;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
_context7.next = 3;
|
|
400
|
+
return this.store.accountList.addHolderAccounts([account], extra.customerId);
|
|
401
|
+
case 3:
|
|
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:
|
|
328
411
|
case "end":
|
|
329
|
-
return
|
|
412
|
+
return _context7.stop();
|
|
330
413
|
}
|
|
331
|
-
},
|
|
414
|
+
}, _callee7, this);
|
|
332
415
|
}));
|
|
333
|
-
function addAccount(
|
|
416
|
+
function addAccount(_x7, _x8) {
|
|
334
417
|
return _addAccount.apply(this, arguments);
|
|
335
418
|
}
|
|
336
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;
|
|
337
480
|
}() // 获取所有账户
|
|
338
481
|
}, {
|
|
339
482
|
key: "getAccounts",
|
|
340
483
|
value: function () {
|
|
341
|
-
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
484
|
+
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
342
485
|
var accounts;
|
|
343
|
-
return _regeneratorRuntime().wrap(function
|
|
344
|
-
while (1) switch (
|
|
486
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
487
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
345
488
|
case 0:
|
|
346
489
|
accounts = this.store.accountList.getAccounts();
|
|
347
|
-
return
|
|
490
|
+
return _context9.abrupt("return", accounts.map(function (account) {
|
|
348
491
|
return account.getAccount();
|
|
349
492
|
}));
|
|
350
493
|
case 2:
|
|
351
494
|
case "end":
|
|
352
|
-
return
|
|
495
|
+
return _context9.stop();
|
|
353
496
|
}
|
|
354
|
-
},
|
|
497
|
+
}, _callee9, this);
|
|
355
498
|
}));
|
|
356
499
|
function getAccounts() {
|
|
357
500
|
return _getAccounts.apply(this, arguments);
|
|
@@ -385,22 +528,45 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
385
528
|
this.clearCartByAccount(id);
|
|
386
529
|
}
|
|
387
530
|
|
|
388
|
-
|
|
531
|
+
/**
|
|
532
|
+
* 获取holder类型账户列表
|
|
533
|
+
* @param params
|
|
534
|
+
*/
|
|
535
|
+
}, {
|
|
536
|
+
key: "fetchHolderAccountsAsync",
|
|
537
|
+
value: (function () {
|
|
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) {
|
|
541
|
+
case 0:
|
|
542
|
+
return _context10.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
|
|
543
|
+
case 1:
|
|
544
|
+
case "end":
|
|
545
|
+
return _context10.stop();
|
|
546
|
+
}
|
|
547
|
+
}, _callee10, this);
|
|
548
|
+
}));
|
|
549
|
+
function fetchHolderAccountsAsync(_x11) {
|
|
550
|
+
return _fetchHolderAccountsAsync.apply(this, arguments);
|
|
551
|
+
}
|
|
552
|
+
return fetchHolderAccountsAsync;
|
|
553
|
+
}() // 设置日期范围,注入到日期模块中
|
|
554
|
+
)
|
|
389
555
|
}, {
|
|
390
556
|
key: "setDateRange",
|
|
391
557
|
value: function () {
|
|
392
|
-
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
393
|
-
return _regeneratorRuntime().wrap(function
|
|
394
|
-
while (1) switch (
|
|
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) {
|
|
395
561
|
case 0:
|
|
396
562
|
this.store.date.setDateRange(dateRange);
|
|
397
563
|
case 1:
|
|
398
564
|
case "end":
|
|
399
|
-
return
|
|
565
|
+
return _context11.stop();
|
|
400
566
|
}
|
|
401
|
-
},
|
|
567
|
+
}, _callee11, this);
|
|
402
568
|
}));
|
|
403
|
-
function setDateRange(
|
|
569
|
+
function setDateRange(_x12) {
|
|
404
570
|
return _setDateRange.apply(this, arguments);
|
|
405
571
|
}
|
|
406
572
|
return setDateRange;
|
|
@@ -415,16 +581,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
415
581
|
}, {
|
|
416
582
|
key: "getDateRange",
|
|
417
583
|
value: function () {
|
|
418
|
-
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
419
|
-
return _regeneratorRuntime().wrap(function
|
|
420
|
-
while (1) switch (
|
|
584
|
+
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
585
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
586
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
421
587
|
case 0:
|
|
422
|
-
return
|
|
588
|
+
return _context12.abrupt("return", this.store.date.getDateRange());
|
|
423
589
|
case 1:
|
|
424
590
|
case "end":
|
|
425
|
-
return
|
|
591
|
+
return _context12.stop();
|
|
426
592
|
}
|
|
427
|
-
},
|
|
593
|
+
}, _callee12, this);
|
|
428
594
|
}));
|
|
429
595
|
function getDateRange() {
|
|
430
596
|
return _getDateRange.apply(this, arguments);
|
|
@@ -441,12 +607,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
441
607
|
}, {
|
|
442
608
|
key: "getAvailableDate",
|
|
443
609
|
value: function () {
|
|
444
|
-
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
445
|
-
var
|
|
610
|
+
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
611
|
+
var _this3 = this,
|
|
612
|
+
_this$otherParams3,
|
|
613
|
+
_this$otherParams4;
|
|
446
614
|
var params,
|
|
447
615
|
products,
|
|
448
616
|
startDate,
|
|
449
617
|
endDate,
|
|
618
|
+
type,
|
|
450
619
|
tempProducts,
|
|
451
620
|
tempStartDate,
|
|
452
621
|
tempEndDate,
|
|
@@ -455,45 +624,63 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
455
624
|
rules,
|
|
456
625
|
resourcesMap,
|
|
457
626
|
res,
|
|
458
|
-
|
|
459
|
-
return _regeneratorRuntime().wrap(function
|
|
460
|
-
while (1) switch (
|
|
627
|
+
_args13 = arguments;
|
|
628
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
629
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
461
630
|
case 0:
|
|
462
|
-
params =
|
|
631
|
+
params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
463
632
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
464
|
-
products = params.products, startDate = params.startDate, endDate = params.endDate;
|
|
633
|
+
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
634
|
+
if (dayjs(startDate).isBefore(dayjs()) && (dayjs(endDate).isAfter(dayjs()) || dayjs(endDate).isSame(dayjs()))) {
|
|
635
|
+
startDate = dayjs().format('YYYY-MM-DD');
|
|
636
|
+
}
|
|
465
637
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
466
638
|
return p._productOrigin;
|
|
467
639
|
});
|
|
640
|
+
if (tempProducts.length) {
|
|
641
|
+
tempProducts.forEach(function (p) {
|
|
642
|
+
if (p !== null && p !== void 0 && p['schedule.ids']) {
|
|
643
|
+
var scheduleData = _this3.getScheduleDataByIds(p['schedule.ids']);
|
|
644
|
+
p['_schedule'] = scheduleData;
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
649
|
+
if (this.store.currentProduct) {
|
|
650
|
+
tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct.getData()), {}, {
|
|
651
|
+
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
652
|
+
})];
|
|
653
|
+
}
|
|
468
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]);
|
|
469
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]);
|
|
470
656
|
if (tempProducts.length) {
|
|
471
|
-
|
|
657
|
+
_context13.next = 10;
|
|
472
658
|
break;
|
|
473
659
|
}
|
|
474
|
-
return
|
|
475
|
-
case
|
|
660
|
+
return _context13.abrupt("return", []);
|
|
661
|
+
case 10:
|
|
476
662
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
477
663
|
_ref4 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref4.resourceIds, rules = _ref4.rules, resourcesMap = _ref4.resourcesMap;
|
|
478
|
-
console.log("resourceIds", tempProducts);
|
|
479
664
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
480
|
-
|
|
481
|
-
return this.store.date.
|
|
665
|
+
_context13.next = 14;
|
|
666
|
+
return this.store.date.getResourceDates({
|
|
667
|
+
url: params.url,
|
|
482
668
|
query: {
|
|
483
669
|
start_date: tempStartDate,
|
|
484
670
|
end_date: tempEndDate,
|
|
485
671
|
resource_ids: resourceIds
|
|
486
672
|
},
|
|
487
|
-
rules: rules
|
|
673
|
+
rules: rules,
|
|
674
|
+
type: type
|
|
488
675
|
});
|
|
489
|
-
case 12:
|
|
490
|
-
res = _context10.sent;
|
|
491
|
-
return _context10.abrupt("return", res);
|
|
492
676
|
case 14:
|
|
677
|
+
res = _context13.sent;
|
|
678
|
+
return _context13.abrupt("return", res);
|
|
679
|
+
case 16:
|
|
493
680
|
case "end":
|
|
494
|
-
return
|
|
681
|
+
return _context13.stop();
|
|
495
682
|
}
|
|
496
|
-
},
|
|
683
|
+
}, _callee13, this);
|
|
497
684
|
}));
|
|
498
685
|
function getAvailableDate() {
|
|
499
686
|
return _getAvailableDate.apply(this, arguments);
|
|
@@ -506,22 +693,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
506
693
|
}, {
|
|
507
694
|
key: "getSummary",
|
|
508
695
|
value: (function () {
|
|
509
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
696
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
510
697
|
var cartItems, summary;
|
|
511
|
-
return _regeneratorRuntime().wrap(function
|
|
512
|
-
while (1) switch (
|
|
698
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
699
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
513
700
|
case 0:
|
|
514
701
|
cartItems = this.store.cart.getItems();
|
|
515
|
-
|
|
702
|
+
_context14.next = 3;
|
|
516
703
|
return this.store.summary.getSummary(cartItems);
|
|
517
704
|
case 3:
|
|
518
|
-
summary =
|
|
519
|
-
return
|
|
705
|
+
summary = _context14.sent;
|
|
706
|
+
return _context14.abrupt("return", summary);
|
|
520
707
|
case 5:
|
|
521
708
|
case "end":
|
|
522
|
-
return
|
|
709
|
+
return _context14.stop();
|
|
523
710
|
}
|
|
524
|
-
},
|
|
711
|
+
}, _callee14, this);
|
|
525
712
|
}));
|
|
526
713
|
function getSummary() {
|
|
527
714
|
return _getSummary.apply(this, arguments);
|
|
@@ -535,18 +722,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
535
722
|
}, {
|
|
536
723
|
key: "getProtocol",
|
|
537
724
|
value: (function () {
|
|
538
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
539
|
-
return _regeneratorRuntime().wrap(function
|
|
540
|
-
while (1) switch (
|
|
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) {
|
|
541
728
|
case 0:
|
|
542
|
-
return
|
|
729
|
+
return _context15.abrupt("return", this.store.summary.getProtocol(protocolId));
|
|
543
730
|
case 1:
|
|
544
731
|
case "end":
|
|
545
|
-
return
|
|
732
|
+
return _context15.stop();
|
|
546
733
|
}
|
|
547
|
-
},
|
|
734
|
+
}, _callee15, this);
|
|
548
735
|
}));
|
|
549
|
-
function getProtocol(
|
|
736
|
+
function getProtocol(_x13) {
|
|
550
737
|
return _getProtocol.apply(this, arguments);
|
|
551
738
|
}
|
|
552
739
|
return getProtocol;
|
|
@@ -555,16 +742,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
555
742
|
}, {
|
|
556
743
|
key: "getProducts",
|
|
557
744
|
value: function () {
|
|
558
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
559
|
-
return _regeneratorRuntime().wrap(function
|
|
560
|
-
while (1) switch (
|
|
745
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
746
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
747
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
561
748
|
case 0:
|
|
562
|
-
return
|
|
749
|
+
return _context16.abrupt("return", this.store.products.getProducts());
|
|
563
750
|
case 1:
|
|
564
751
|
case "end":
|
|
565
|
-
return
|
|
752
|
+
return _context16.stop();
|
|
566
753
|
}
|
|
567
|
-
},
|
|
754
|
+
}, _callee16, this);
|
|
568
755
|
}));
|
|
569
756
|
function getProducts() {
|
|
570
757
|
return _getProducts.apply(this, arguments);
|
|
@@ -574,15 +761,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
574
761
|
}, {
|
|
575
762
|
key: "setLoginAccount",
|
|
576
763
|
value: function () {
|
|
577
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
764
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(accountId, accountInfo) {
|
|
578
765
|
var _this4 = this;
|
|
579
766
|
var account, stateAccountId, cartItems;
|
|
580
|
-
return _regeneratorRuntime().wrap(function
|
|
581
|
-
while (1) switch (
|
|
767
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
768
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
582
769
|
case 0:
|
|
583
770
|
account = this.store.accountList.getAccount(accountId);
|
|
584
771
|
if (!account) {
|
|
585
|
-
|
|
772
|
+
_context17.next = 9;
|
|
586
773
|
break;
|
|
587
774
|
}
|
|
588
775
|
stateAccountId = account.getId();
|
|
@@ -598,17 +785,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
785
|
}
|
|
599
786
|
});
|
|
600
787
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
601
|
-
|
|
788
|
+
_context17.next = 10;
|
|
602
789
|
break;
|
|
603
790
|
case 9:
|
|
604
791
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
605
792
|
case 10:
|
|
606
793
|
case "end":
|
|
607
|
-
return
|
|
794
|
+
return _context17.stop();
|
|
608
795
|
}
|
|
609
|
-
},
|
|
796
|
+
}, _callee17, this);
|
|
610
797
|
}));
|
|
611
|
-
function setLoginAccount(
|
|
798
|
+
function setLoginAccount(_x14, _x15) {
|
|
612
799
|
return _setLoginAccount.apply(this, arguments);
|
|
613
800
|
}
|
|
614
801
|
return setLoginAccount;
|
|
@@ -616,14 +803,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
616
803
|
}, {
|
|
617
804
|
key: "generateCartData",
|
|
618
805
|
value: function () {
|
|
619
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
620
|
-
return _regeneratorRuntime().wrap(function
|
|
621
|
-
while (1) switch (
|
|
806
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
807
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
808
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
622
809
|
case 0:
|
|
623
810
|
case "end":
|
|
624
|
-
return
|
|
811
|
+
return _context18.stop();
|
|
625
812
|
}
|
|
626
|
-
},
|
|
813
|
+
}, _callee18);
|
|
627
814
|
}));
|
|
628
815
|
function generateCartData() {
|
|
629
816
|
return _generateCartData.apply(this, arguments);
|
|
@@ -633,34 +820,49 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
633
820
|
}, {
|
|
634
821
|
key: "getFreeProduct",
|
|
635
822
|
value: function () {
|
|
636
|
-
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
823
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(id) {
|
|
637
824
|
var res;
|
|
638
|
-
return _regeneratorRuntime().wrap(function
|
|
639
|
-
while (1) switch (
|
|
825
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
826
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
640
827
|
case 0:
|
|
641
|
-
|
|
828
|
+
_context19.next = 2;
|
|
642
829
|
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
643
830
|
case 2:
|
|
644
|
-
res =
|
|
645
|
-
return
|
|
831
|
+
res = _context19.sent;
|
|
832
|
+
return _context19.abrupt("return", res);
|
|
646
833
|
case 4:
|
|
647
834
|
case "end":
|
|
648
|
-
return
|
|
835
|
+
return _context19.stop();
|
|
649
836
|
}
|
|
650
|
-
},
|
|
837
|
+
}, _callee19, this);
|
|
651
838
|
}));
|
|
652
|
-
function getFreeProduct(
|
|
839
|
+
function getFreeProduct(_x16) {
|
|
653
840
|
return _getFreeProduct.apply(this, arguments);
|
|
654
841
|
}
|
|
655
842
|
return getFreeProduct;
|
|
656
|
-
}()
|
|
843
|
+
}()
|
|
844
|
+
/**
|
|
845
|
+
* 检查购物车提交订单前是否符合条件
|
|
846
|
+
* @param type 类型 "holder" | "account"
|
|
847
|
+
* @returns boolean
|
|
848
|
+
*/
|
|
849
|
+
}, {
|
|
850
|
+
key: "checkBeforeSubmitOrder",
|
|
851
|
+
value: function checkBeforeSubmitOrder(type) {
|
|
852
|
+
return this.store.order.checkBeforeSubmitOrder({
|
|
853
|
+
type: type,
|
|
854
|
+
cartItems: this.store.cart.getItems()
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// 购物车提交订单
|
|
657
859
|
}, {
|
|
658
860
|
key: "submitOrder",
|
|
659
861
|
value: function () {
|
|
660
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
862
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
661
863
|
var cartItems, newCartItems;
|
|
662
|
-
return _regeneratorRuntime().wrap(function
|
|
663
|
-
while (1) switch (
|
|
864
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
865
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
664
866
|
case 0:
|
|
665
867
|
cartItems = this.store.cart.getItems();
|
|
666
868
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
@@ -673,16 +875,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
673
875
|
return _objectSpread({}, newResourcesItem);
|
|
674
876
|
});
|
|
675
877
|
});
|
|
676
|
-
return
|
|
878
|
+
return _context20.abrupt("return", this.store.order.submitOrder({
|
|
677
879
|
query: {
|
|
678
880
|
cartItems: newCartItems
|
|
679
881
|
}
|
|
680
882
|
}));
|
|
681
883
|
case 4:
|
|
682
884
|
case "end":
|
|
683
|
-
return
|
|
885
|
+
return _context20.stop();
|
|
684
886
|
}
|
|
685
|
-
},
|
|
887
|
+
}, _callee20, this);
|
|
686
888
|
}));
|
|
687
889
|
function submitOrder() {
|
|
688
890
|
return _submitOrder.apply(this, arguments);
|
|
@@ -692,14 +894,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
692
894
|
}, {
|
|
693
895
|
key: "pay",
|
|
694
896
|
value: function () {
|
|
695
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
696
|
-
return _regeneratorRuntime().wrap(function
|
|
697
|
-
while (1) switch (
|
|
897
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
898
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
899
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
698
900
|
case 0:
|
|
699
901
|
case "end":
|
|
700
|
-
return
|
|
902
|
+
return _context21.stop();
|
|
701
903
|
}
|
|
702
|
-
},
|
|
904
|
+
}, _callee21);
|
|
703
905
|
}));
|
|
704
906
|
function pay() {
|
|
705
907
|
return _pay.apply(this, arguments);
|
|
@@ -709,14 +911,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
709
911
|
}, {
|
|
710
912
|
key: "getPayInfo",
|
|
711
913
|
value: function () {
|
|
712
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
713
|
-
return _regeneratorRuntime().wrap(function
|
|
714
|
-
while (1) switch (
|
|
914
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
915
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
916
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
715
917
|
case 0:
|
|
716
918
|
case "end":
|
|
717
|
-
return
|
|
919
|
+
return _context22.stop();
|
|
718
920
|
}
|
|
719
|
-
},
|
|
921
|
+
}, _callee22);
|
|
720
922
|
}));
|
|
721
923
|
function getPayInfo() {
|
|
722
924
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -726,15 +928,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
726
928
|
}, {
|
|
727
929
|
key: "setOtherParams",
|
|
728
930
|
value: function () {
|
|
729
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
931
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
730
932
|
var _ref5,
|
|
731
933
|
_ref5$cover,
|
|
732
934
|
cover,
|
|
733
|
-
|
|
734
|
-
return _regeneratorRuntime().wrap(function
|
|
735
|
-
while (1) switch (
|
|
935
|
+
_args23 = arguments;
|
|
936
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
937
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
736
938
|
case 0:
|
|
737
|
-
_ref5 =
|
|
939
|
+
_ref5 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
738
940
|
if (cover) {
|
|
739
941
|
this.otherParams = params;
|
|
740
942
|
} else {
|
|
@@ -742,11 +944,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
742
944
|
}
|
|
743
945
|
case 2:
|
|
744
946
|
case "end":
|
|
745
|
-
return
|
|
947
|
+
return _context23.stop();
|
|
746
948
|
}
|
|
747
|
-
},
|
|
949
|
+
}, _callee23, this);
|
|
748
950
|
}));
|
|
749
|
-
function setOtherParams(
|
|
951
|
+
function setOtherParams(_x17) {
|
|
750
952
|
return _setOtherParams.apply(this, arguments);
|
|
751
953
|
}
|
|
752
954
|
return setOtherParams;
|
|
@@ -754,16 +956,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
754
956
|
}, {
|
|
755
957
|
key: "getOtherParams",
|
|
756
958
|
value: function () {
|
|
757
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
758
|
-
return _regeneratorRuntime().wrap(function
|
|
759
|
-
while (1) switch (
|
|
959
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
960
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
961
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
760
962
|
case 0:
|
|
761
|
-
return
|
|
963
|
+
return _context24.abrupt("return", this.otherParams);
|
|
762
964
|
case 1:
|
|
763
965
|
case "end":
|
|
764
|
-
return
|
|
966
|
+
return _context24.stop();
|
|
765
967
|
}
|
|
766
|
-
},
|
|
968
|
+
}, _callee24, this);
|
|
767
969
|
}));
|
|
768
970
|
function getOtherParams() {
|
|
769
971
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -774,11 +976,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
774
976
|
key: "updateCart",
|
|
775
977
|
value: function updateCart(params) {
|
|
776
978
|
var _this5 = this;
|
|
777
|
-
this.store.cart.updateItem(params);
|
|
778
979
|
var targetCartItem = this.store.cart.getItem(params._id);
|
|
779
980
|
if (!targetCartItem) {
|
|
780
981
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
781
982
|
}
|
|
983
|
+
if (params.resources) {
|
|
984
|
+
params.resources = params.resources.map(function (n) {
|
|
985
|
+
n.capacity = targetCartItem.num || 1;
|
|
986
|
+
checkSubResourcesCapacity(n);
|
|
987
|
+
return n;
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
this.store.cart.updateItem(params);
|
|
782
991
|
// 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,则要把选择了相同资源的 product._origin.resources 给去除
|
|
783
992
|
var cartItems = this.store.cart.getItems();
|
|
784
993
|
cartItems.forEach(function (item) {
|
|
@@ -868,17 +1077,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
868
1077
|
value: function getResourcesList() {
|
|
869
1078
|
var dateRange = this.store.date.getDateRange();
|
|
870
1079
|
var resources = [];
|
|
871
|
-
dateRange.
|
|
872
|
-
|
|
873
|
-
|
|
1080
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1081
|
+
dateRange.forEach(function (n) {
|
|
1082
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1086
|
+
if (!resources.length) {
|
|
1087
|
+
var dateList = this.store.date.getDateList();
|
|
1088
|
+
dateList.forEach(function (n) {
|
|
1089
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
874
1092
|
var resourcesMap = getResourcesMap(resources);
|
|
875
1093
|
var cartItems = this.store.cart.getItems();
|
|
876
1094
|
var arr = [];
|
|
1095
|
+
var capacityMap = {};
|
|
877
1096
|
cartItems.forEach(function (cartItem) {
|
|
878
1097
|
var _cartItem$_productOri, _cartItem$_productOri2;
|
|
879
|
-
|
|
880
|
-
if (
|
|
881
|
-
|
|
1098
|
+
var selectedResources = [];
|
|
1099
|
+
if (cartItem.holder_id) {
|
|
1100
|
+
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1101
|
+
}
|
|
882
1102
|
var formatCapacity = formatDefaultCapacitys({
|
|
883
1103
|
capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
|
|
884
1104
|
product_bundle: cartItem._origin.product.product_bundle
|
|
@@ -887,6 +1107,31 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
887
1107
|
capacity: formatCapacity
|
|
888
1108
|
});
|
|
889
1109
|
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
|
|
1110
|
+
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1111
|
+
if (cartItem._origin.start_time) {
|
|
1112
|
+
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
1113
|
+
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
1114
|
+
productResources.forEach(function (n) {
|
|
1115
|
+
n.renderList = n.renderList.filter(function (m) {
|
|
1116
|
+
var recordCount = capacityMap[m.id] || 0;
|
|
1117
|
+
var canUseTime = m.times.find(function (item) {
|
|
1118
|
+
var res = getIsUsableByTimeItem({
|
|
1119
|
+
timeSlice: {
|
|
1120
|
+
start_time: startTime.format('HH:mm'),
|
|
1121
|
+
end_time: endTime.format('HH:mm'),
|
|
1122
|
+
start_at: startTime,
|
|
1123
|
+
end_at: endTime
|
|
1124
|
+
},
|
|
1125
|
+
time: item,
|
|
1126
|
+
resource: m,
|
|
1127
|
+
currentCount: recordCount + (currentCapacity || 0)
|
|
1128
|
+
});
|
|
1129
|
+
return res.usable;
|
|
1130
|
+
});
|
|
1131
|
+
return canUseTime;
|
|
1132
|
+
});
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
890
1135
|
arr.push({
|
|
891
1136
|
id: cartItem.id,
|
|
892
1137
|
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
@@ -979,11 +1224,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
979
1224
|
// .format("HH:mm");
|
|
980
1225
|
// 根据 start_time 和 end_time 去匹配资源
|
|
981
1226
|
var targetResource = null;
|
|
982
|
-
var
|
|
983
|
-
|
|
1227
|
+
var _iterator2 = _createForOfIteratorHelper(resources),
|
|
1228
|
+
_step2;
|
|
984
1229
|
try {
|
|
985
1230
|
var _loop = function _loop() {
|
|
986
|
-
var n =
|
|
1231
|
+
var n = _step2.value;
|
|
987
1232
|
var canUseTime = n.times.find(function (item) {
|
|
988
1233
|
var res = getIsUsableByTimeItem({
|
|
989
1234
|
timeSlice: timeSlots,
|
|
@@ -998,13 +1243,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
998
1243
|
return 1; // break
|
|
999
1244
|
}
|
|
1000
1245
|
};
|
|
1001
|
-
for (
|
|
1246
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1002
1247
|
if (_loop()) break;
|
|
1003
1248
|
}
|
|
1004
1249
|
} catch (err) {
|
|
1005
|
-
|
|
1250
|
+
_iterator2.e(err);
|
|
1006
1251
|
} finally {
|
|
1007
|
-
|
|
1252
|
+
_iterator2.f();
|
|
1008
1253
|
}
|
|
1009
1254
|
return {
|
|
1010
1255
|
selectedResource: targetResource
|
|
@@ -1082,11 +1327,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1082
1327
|
// .format("HH:mm");
|
|
1083
1328
|
// 根据 start_time 和 end_time 去匹配资源
|
|
1084
1329
|
var targetResource = null;
|
|
1085
|
-
var
|
|
1086
|
-
|
|
1330
|
+
var _iterator3 = _createForOfIteratorHelper(resources),
|
|
1331
|
+
_step3;
|
|
1087
1332
|
try {
|
|
1088
1333
|
var _loop2 = function _loop2() {
|
|
1089
|
-
var n =
|
|
1334
|
+
var n = _step3.value;
|
|
1090
1335
|
var recordCount = countMap[n.id] || 0;
|
|
1091
1336
|
var canUseTime = n.times.find(function (item) {
|
|
1092
1337
|
var res = getIsUsableByTimeItem({
|
|
@@ -1102,13 +1347,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1102
1347
|
return 1; // break
|
|
1103
1348
|
}
|
|
1104
1349
|
};
|
|
1105
|
-
for (
|
|
1350
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1106
1351
|
if (_loop2()) break;
|
|
1107
1352
|
}
|
|
1108
1353
|
} catch (err) {
|
|
1109
|
-
|
|
1354
|
+
_iterator3.e(err);
|
|
1110
1355
|
} finally {
|
|
1111
|
-
|
|
1356
|
+
_iterator3.f();
|
|
1112
1357
|
}
|
|
1113
1358
|
return {
|
|
1114
1359
|
selectedResource: targetResource
|
|
@@ -1170,11 +1415,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1170
1415
|
if (timeSlots) {
|
|
1171
1416
|
if (index !== 0 && recordTimeSlots) {
|
|
1172
1417
|
var _item$_productOrigin$, _item$_productOrigin3, _ref9, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref10, _item$_productOrigin6;
|
|
1173
|
-
var start_at = dayjs(recordTimeSlots.end_time).add((_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, (_ref9 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref9 !== void 0 ? _ref9 :
|
|
1174
|
-
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref10 !== void 0 ? _ref10 :
|
|
1418
|
+
var start_at = dayjs(recordTimeSlots.end_time).add((_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, (_ref9 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
|
|
1419
|
+
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
1175
1420
|
recordTimeSlots = {
|
|
1176
|
-
start_time: start_at.format(
|
|
1177
|
-
end_time: end_at.format(
|
|
1421
|
+
start_time: start_at.format('HH:mm'),
|
|
1422
|
+
end_time: end_at.format('HH:mm'),
|
|
1178
1423
|
start_at: start_at,
|
|
1179
1424
|
end_at: end_at
|
|
1180
1425
|
};
|
|
@@ -1320,13 +1565,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1320
1565
|
|
|
1321
1566
|
// 处理每个账号的商品
|
|
1322
1567
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
1323
|
-
var currentStartTime = timeSlots.start_at.format(
|
|
1568
|
+
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
1324
1569
|
accountItems.forEach(function (item, index) {
|
|
1325
1570
|
var newResources = cloneDeep(item._origin.resources);
|
|
1326
1571
|
newResources.forEach(function (resource) {
|
|
1327
1572
|
var _item$_productOrigin$4, _item$_productOrigin10, _ref11, _item$_productOrigin11;
|
|
1328
1573
|
resource.startTime = currentStartTime;
|
|
1329
|
-
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 :
|
|
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');
|
|
1330
1575
|
delete resource.times;
|
|
1331
1576
|
});
|
|
1332
1577
|
_this9.store.cart.updateItem({
|
|
@@ -1347,32 +1592,203 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1347
1592
|
}, {
|
|
1348
1593
|
key: "clearCacheByModule",
|
|
1349
1594
|
value: function clearCacheByModule(module) {}
|
|
1595
|
+
}, {
|
|
1596
|
+
key: "getScheduleDataByIds",
|
|
1597
|
+
value: function getScheduleDataByIds(scheduleIds) {
|
|
1598
|
+
var targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1599
|
+
var targetSchedulesData = targetSchedules.map(function (item) {
|
|
1600
|
+
return calcCalendarDataByScheduleResult(item);
|
|
1601
|
+
});
|
|
1602
|
+
var newSchedule = {};
|
|
1603
|
+
targetSchedulesData.forEach(function (item) {
|
|
1604
|
+
item.forEach(function (n) {
|
|
1605
|
+
if (!newSchedule[n.date]) {
|
|
1606
|
+
newSchedule[n.date] = n;
|
|
1607
|
+
} else {
|
|
1608
|
+
if (!n.isExcluded) {
|
|
1609
|
+
newSchedule[n.date].isExcluded = false;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
});
|
|
1614
|
+
var newScheduleArr = Object.values(newSchedule);
|
|
1615
|
+
return newScheduleArr;
|
|
1616
|
+
}
|
|
1617
|
+
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
1350
1618
|
}, {
|
|
1351
1619
|
key: "openProductDetail",
|
|
1352
1620
|
value: function () {
|
|
1353
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1354
|
-
var targetProduct;
|
|
1355
|
-
return _regeneratorRuntime().wrap(function
|
|
1356
|
-
while (1) switch (
|
|
1621
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
|
|
1622
|
+
var targetProduct, targetProductData, newScheduleArr;
|
|
1623
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1624
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1357
1625
|
case 0:
|
|
1358
|
-
|
|
1626
|
+
_context25.next = 2;
|
|
1359
1627
|
return this.store.products.getProduct(productId);
|
|
1360
1628
|
case 2:
|
|
1361
|
-
targetProduct =
|
|
1629
|
+
targetProduct = _context25.sent;
|
|
1362
1630
|
if (targetProduct) {
|
|
1631
|
+
targetProductData = targetProduct.getData();
|
|
1363
1632
|
this.store.currentProduct = targetProduct;
|
|
1633
|
+
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
1634
|
+
targetProduct.setOtherParams('schedule', newScheduleArr);
|
|
1364
1635
|
}
|
|
1365
1636
|
case 4:
|
|
1366
1637
|
case "end":
|
|
1367
|
-
return
|
|
1638
|
+
return _context25.stop();
|
|
1368
1639
|
}
|
|
1369
|
-
},
|
|
1640
|
+
}, _callee25, this);
|
|
1370
1641
|
}));
|
|
1371
|
-
function openProductDetail(
|
|
1642
|
+
function openProductDetail(_x18) {
|
|
1372
1643
|
return _openProductDetail.apply(this, arguments);
|
|
1373
1644
|
}
|
|
1374
1645
|
return openProductDetail;
|
|
1375
1646
|
}()
|
|
1647
|
+
}, {
|
|
1648
|
+
key: "closeProductDetail",
|
|
1649
|
+
value: function closeProductDetail() {
|
|
1650
|
+
var _this$store$currentPr;
|
|
1651
|
+
(_this$store$currentPr = this.store.currentProduct) === null || _this$store$currentPr === void 0 || _this$store$currentPr.setOtherParams('schedule', []);
|
|
1652
|
+
this.store.currentProduct = undefined;
|
|
1653
|
+
}
|
|
1654
|
+
}, {
|
|
1655
|
+
key: "getTimeslotBySchedule",
|
|
1656
|
+
value: function getTimeslotBySchedule(_ref12) {
|
|
1657
|
+
var _this$store$currentPr2;
|
|
1658
|
+
var date = _ref12.date,
|
|
1659
|
+
scheduleIds = _ref12.scheduleIds,
|
|
1660
|
+
resources = _ref12.resources;
|
|
1661
|
+
var targetProduct = this.store.currentProduct;
|
|
1662
|
+
var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
|
|
1663
|
+
var targetSchedules = [];
|
|
1664
|
+
// 如果外面传递了 scheduleIds,优先取入参
|
|
1665
|
+
if (scheduleIds !== null && scheduleIds !== void 0 && scheduleIds.length) {
|
|
1666
|
+
targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1667
|
+
} else {
|
|
1668
|
+
targetSchedules = this.store.schedule.getScheduleListByIds(targetProductData['schedule.ids']);
|
|
1669
|
+
}
|
|
1670
|
+
var resourcesDates = this.store.date.getDateList();
|
|
1671
|
+
var targetResourceDate = resourcesDates.find(function (n) {
|
|
1672
|
+
return n.date === date;
|
|
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);
|
|
1678
|
+
var minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, date);
|
|
1679
|
+
var scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime);
|
|
1680
|
+
console.log('scheduleTimeSlots:', scheduleTimeSlots, productResources);
|
|
1681
|
+
// 当前所有待选择资源的集合,先提出来,提升性能
|
|
1682
|
+
var allProductResources = productResources.flatMap(function (n) {
|
|
1683
|
+
return n.renderList;
|
|
1684
|
+
});
|
|
1685
|
+
// 计算每个日程切片下日程可用的资源的容量总和
|
|
1686
|
+
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
1687
|
+
var count = 0;
|
|
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
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
});
|
|
1710
|
+
var startDayJs = dayjs(item.start);
|
|
1711
|
+
var endDayJs = dayjs(item.end);
|
|
1712
|
+
return {
|
|
1713
|
+
start_time: startDayJs.format('HH:mm'),
|
|
1714
|
+
end_time: endDayJs.format('HH:mm'),
|
|
1715
|
+
start_at: startDayJs,
|
|
1716
|
+
end_at: endDayJs,
|
|
1717
|
+
count: count
|
|
1718
|
+
};
|
|
1719
|
+
});
|
|
1720
|
+
return formatScheduleTimeSlots;
|
|
1721
|
+
}
|
|
1722
|
+
}, {
|
|
1723
|
+
key: "addProductToCart",
|
|
1724
|
+
value: function addProductToCart(_ref13) {
|
|
1725
|
+
var product = _ref13.product,
|
|
1726
|
+
date = _ref13.date,
|
|
1727
|
+
account = _ref13.account;
|
|
1728
|
+
var _ref14 = product || {},
|
|
1729
|
+
bundle = _ref14.bundle,
|
|
1730
|
+
options = _ref14.options,
|
|
1731
|
+
origin = _ref14.origin,
|
|
1732
|
+
product_variant_id = _ref14.product_variant_id;
|
|
1733
|
+
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1734
|
+
product_variant_id: product_variant_id
|
|
1735
|
+
});
|
|
1736
|
+
this.store.cart.addItem({
|
|
1737
|
+
product: productData,
|
|
1738
|
+
date: date,
|
|
1739
|
+
account: account,
|
|
1740
|
+
bundle: bundle,
|
|
1741
|
+
options: options
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
}, {
|
|
1745
|
+
key: "setOtherData",
|
|
1746
|
+
value: function setOtherData(key, value) {
|
|
1747
|
+
this.otherData[key] = value;
|
|
1748
|
+
this.checkSaveCache({
|
|
1749
|
+
cacheId: this.cacheId,
|
|
1750
|
+
fatherModule: this.name,
|
|
1751
|
+
store: {
|
|
1752
|
+
otherData: this.otherData
|
|
1753
|
+
},
|
|
1754
|
+
cacheKey: ['otherData']
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
}, {
|
|
1758
|
+
key: "getOtherData",
|
|
1759
|
+
value: function getOtherData(key) {
|
|
1760
|
+
return this.otherData[key];
|
|
1761
|
+
}
|
|
1762
|
+
}, {
|
|
1763
|
+
key: "getProductTypeById",
|
|
1764
|
+
value: function () {
|
|
1765
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
1766
|
+
var product;
|
|
1767
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1768
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1769
|
+
case 0:
|
|
1770
|
+
_context26.next = 2;
|
|
1771
|
+
return this.store.products.getProduct(id);
|
|
1772
|
+
case 2:
|
|
1773
|
+
product = _context26.sent;
|
|
1774
|
+
if (!product) {
|
|
1775
|
+
_context26.next = 5;
|
|
1776
|
+
break;
|
|
1777
|
+
}
|
|
1778
|
+
return _context26.abrupt("return", product.getProductType());
|
|
1779
|
+
case 5:
|
|
1780
|
+
return _context26.abrupt("return", 'normal');
|
|
1781
|
+
case 6:
|
|
1782
|
+
case "end":
|
|
1783
|
+
return _context26.stop();
|
|
1784
|
+
}
|
|
1785
|
+
}, _callee26, this);
|
|
1786
|
+
}));
|
|
1787
|
+
function getProductTypeById(_x19) {
|
|
1788
|
+
return _getProductTypeById.apply(this, arguments);
|
|
1789
|
+
}
|
|
1790
|
+
return getProductTypeById;
|
|
1791
|
+
}()
|
|
1376
1792
|
}]);
|
|
1377
1793
|
return BookingByStepImpl;
|
|
1378
1794
|
}(BaseModule);
|