@pisell/pisellos 3.0.4 → 3.0.6

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 (189) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +20 -1
  5. package/dist/modules/AccountList/index.js +243 -75
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +8 -5
  13. package/dist/modules/Cart/index.js +101 -25
  14. package/dist/modules/Cart/types.d.ts +82 -5
  15. package/dist/modules/Cart/types.js +22 -0
  16. package/dist/modules/Cart/utils.d.ts +106 -13
  17. package/dist/modules/Cart/utils.js +289 -76
  18. package/dist/modules/Date/index.d.ts +6 -6
  19. package/dist/modules/Date/index.js +41 -58
  20. package/dist/modules/Date/types.d.ts +22 -6
  21. package/dist/modules/Date/utils.d.ts +4 -3
  22. package/dist/modules/Date/utils.js +81 -30
  23. package/dist/modules/Discount/index.d.ts +4 -4
  24. package/dist/modules/Discount/index.js +11 -11
  25. package/dist/modules/Order/index.d.ts +11 -5
  26. package/dist/modules/Order/index.js +47 -18
  27. package/dist/modules/Order/types.d.ts +10 -3
  28. package/dist/modules/Order/utils.d.ts +10 -0
  29. package/dist/modules/Order/utils.js +15 -0
  30. package/dist/modules/Product/index.d.ts +14 -1
  31. package/dist/modules/Product/index.js +35 -0
  32. package/dist/modules/Product/types.d.ts +27 -3
  33. package/dist/modules/ProductList/index.js +11 -5
  34. package/dist/modules/Resource/types.d.ts +1 -0
  35. package/dist/modules/Resource/utils.js +1 -1
  36. package/dist/modules/Rules/index.d.ts +3 -3
  37. package/dist/modules/Rules/index.js +121 -53
  38. package/dist/modules/Rules/types.d.ts +5 -1
  39. package/dist/modules/Schedule/index.d.ts +18 -0
  40. package/dist/modules/Schedule/index.js +111 -0
  41. package/dist/modules/Schedule/type.d.ts +157 -0
  42. package/dist/modules/Schedule/type.js +1 -0
  43. package/dist/modules/Schedule/types.d.ts +182 -0
  44. package/dist/modules/Schedule/types.js +1 -0
  45. package/dist/modules/Schedule/utils.d.ts +67 -0
  46. package/dist/modules/Schedule/utils.js +729 -0
  47. package/dist/modules/Step/index.d.ts +14 -3
  48. package/dist/modules/Step/index.js +54 -2
  49. package/dist/modules/Summary/index.d.ts +12 -5
  50. package/dist/modules/Summary/index.js +33 -7
  51. package/dist/modules/Summary/types.d.ts +23 -2
  52. package/dist/modules/Summary/utils.d.ts +14 -4
  53. package/dist/modules/Summary/utils.js +46 -4
  54. package/dist/modules/index.d.ts +10 -0
  55. package/dist/modules/index.js +11 -1
  56. package/dist/plugins/index.d.ts +3 -3
  57. package/dist/plugins/request.d.ts +3 -3
  58. package/dist/plugins/request.js +30 -30
  59. package/dist/plugins/shopStore.d.ts +1 -1
  60. package/dist/solution/BookingByStep/index.d.ts +97 -24
  61. package/dist/solution/BookingByStep/index.js +1024 -322
  62. package/dist/solution/BookingByStep/types.d.ts +3 -10
  63. package/dist/solution/BookingByStep/types.js +11 -15
  64. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  65. package/dist/solution/BookingByStep/utils/products.js +3 -0
  66. package/dist/solution/BookingByStep/utils/resources.d.ts +60 -6
  67. package/dist/solution/BookingByStep/utils/resources.js +293 -52
  68. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  69. package/dist/solution/ShopDiscount/index.js +16 -16
  70. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  71. package/dist/solution/ShopDiscount/utils.js +1 -1
  72. package/lib/core/index.js +7 -2
  73. package/lib/modules/Account/index.d.ts +2 -6
  74. package/lib/modules/Account/index.js +15 -30
  75. package/lib/modules/Account/types.d.ts +12 -1
  76. package/lib/modules/AccountList/index.d.ts +20 -1
  77. package/lib/modules/AccountList/index.js +122 -13
  78. package/lib/modules/AccountList/types.d.ts +33 -1
  79. package/lib/modules/AccountList/utils.d.ts +9 -0
  80. package/lib/modules/AccountList/utils.js +39 -0
  81. package/lib/modules/BaseModule.d.ts +2 -2
  82. package/lib/modules/BaseModule.js +14 -3
  83. package/lib/modules/Cart/index.d.ts +8 -5
  84. package/lib/modules/Cart/index.js +81 -8
  85. package/lib/modules/Cart/types.d.ts +82 -5
  86. package/lib/modules/Cart/types.js +20 -2
  87. package/lib/modules/Cart/utils.d.ts +106 -13
  88. package/lib/modules/Cart/utils.js +188 -45
  89. package/lib/modules/Date/index.d.ts +6 -6
  90. package/lib/modules/Date/index.js +13 -28
  91. package/lib/modules/Date/types.d.ts +22 -6
  92. package/lib/modules/Date/utils.d.ts +4 -3
  93. package/lib/modules/Date/utils.js +47 -13
  94. package/lib/modules/Discount/index.d.ts +4 -4
  95. package/lib/modules/Discount/index.js +9 -2
  96. package/lib/modules/Guests/index.js +4 -1
  97. package/lib/modules/Order/index.d.ts +11 -5
  98. package/lib/modules/Order/index.js +24 -3
  99. package/lib/modules/Order/types.d.ts +10 -3
  100. package/lib/modules/Order/utils.d.ts +10 -0
  101. package/lib/modules/Order/utils.js +45 -0
  102. package/lib/modules/Payment/index.js +1 -6
  103. package/lib/modules/Product/index.d.ts +14 -1
  104. package/lib/modules/Product/index.js +19 -0
  105. package/lib/modules/Product/types.d.ts +27 -3
  106. package/lib/modules/ProductList/index.js +21 -7
  107. package/lib/modules/Resource/index.js +4 -1
  108. package/lib/modules/Resource/types.d.ts +1 -0
  109. package/lib/modules/Resource/utils.js +7 -4
  110. package/lib/modules/Rules/index.d.ts +3 -3
  111. package/lib/modules/Rules/index.js +118 -43
  112. package/lib/modules/Rules/types.d.ts +5 -1
  113. package/lib/modules/Schedule/index.d.ts +18 -0
  114. package/lib/modules/Schedule/index.js +81 -0
  115. package/lib/modules/Schedule/type.d.ts +157 -0
  116. package/lib/modules/Schedule/type.js +17 -0
  117. package/lib/modules/Schedule/types.d.ts +182 -0
  118. package/lib/modules/Schedule/types.js +17 -0
  119. package/lib/modules/Schedule/utils.d.ts +67 -0
  120. package/lib/modules/Schedule/utils.js +600 -0
  121. package/lib/modules/Step/index.d.ts +14 -3
  122. package/lib/modules/Step/index.js +38 -1
  123. package/lib/modules/Summary/index.d.ts +12 -5
  124. package/lib/modules/Summary/index.js +15 -1
  125. package/lib/modules/Summary/types.d.ts +23 -2
  126. package/lib/modules/Summary/utils.d.ts +14 -4
  127. package/lib/modules/Summary/utils.js +30 -1
  128. package/lib/modules/index.d.ts +10 -0
  129. package/lib/modules/index.js +21 -1
  130. package/lib/plugins/index.d.ts +3 -3
  131. package/lib/plugins/request.d.ts +3 -3
  132. package/lib/plugins/request.js +48 -11
  133. package/lib/plugins/shopStore.d.ts +1 -1
  134. package/lib/solution/BookingByStep/index.d.ts +97 -24
  135. package/lib/solution/BookingByStep/index.js +693 -145
  136. package/lib/solution/BookingByStep/types.d.ts +3 -10
  137. package/lib/solution/BookingByStep/types.js +37 -14
  138. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  139. package/lib/solution/BookingByStep/utils/products.js +3 -0
  140. package/lib/solution/BookingByStep/utils/resources.d.ts +60 -6
  141. package/lib/solution/BookingByStep/utils/resources.js +286 -54
  142. package/lib/solution/BuyTickets/index.js +34 -20
  143. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  144. package/lib/solution/ShopDiscount/index.js +10 -2
  145. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  146. package/package.json +4 -2
  147. package/dist/core/index.d.ts.map +0 -1
  148. package/dist/effects/index.d.ts.map +0 -1
  149. package/dist/index.d.ts.map +0 -1
  150. package/dist/modules/Account/index.d.ts.map +0 -1
  151. package/dist/modules/Account/types.d.ts.map +0 -1
  152. package/dist/modules/AccountList/types.d.ts.map +0 -1
  153. package/dist/modules/Cart/index.d.ts.map +0 -1
  154. package/dist/modules/Cart/types.d.ts.map +0 -1
  155. package/dist/modules/Date/types.d.ts.map +0 -1
  156. package/dist/modules/Date/utils.d.ts.map +0 -1
  157. package/dist/modules/Guests/index.d.ts.map +0 -1
  158. package/dist/modules/Guests/types.d.ts.map +0 -1
  159. package/dist/modules/Order/index.d.ts.map +0 -1
  160. package/dist/modules/Order/types.d.ts.map +0 -1
  161. package/dist/modules/Payment/index.d.ts.map +0 -1
  162. package/dist/modules/Payment/types.d.ts.map +0 -1
  163. package/dist/modules/Product/index.d.ts.map +0 -1
  164. package/dist/modules/Product/types.d.ts.map +0 -1
  165. package/dist/modules/ProductList/types.d.ts.map +0 -1
  166. package/dist/modules/Resource/index.d.ts.map +0 -1
  167. package/dist/modules/Resource/types.d.ts.map +0 -1
  168. package/dist/modules/Resource/utils.d.ts.map +0 -1
  169. package/dist/modules/Rules/types.d.ts.map +0 -1
  170. package/dist/modules/Step/index.d.ts.map +0 -1
  171. package/dist/modules/Step/tyeps.d.ts.map +0 -1
  172. package/dist/modules/Summary/index.d.ts.map +0 -1
  173. package/dist/modules/Summary/types.d.ts.map +0 -1
  174. package/dist/modules/Summary/utils.d.ts.map +0 -1
  175. package/dist/modules/index.d.ts.map +0 -1
  176. package/dist/plugins/index.d.ts.map +0 -1
  177. package/dist/plugins/request.d.ts.map +0 -1
  178. package/dist/plugins/shopStore.d.ts.map +0 -1
  179. package/dist/plugins/window.d.ts.map +0 -1
  180. package/dist/solution/BookingByStep/types.d.ts.map +0 -1
  181. package/dist/solution/BookingByStep/utils/products.d.ts.map +0 -1
  182. package/dist/solution/BuyTickets/index.d.ts.map +0 -1
  183. package/dist/solution/BuyTickets/types.d.ts.map +0 -1
  184. package/dist/solution/PlaceOrder/index.d.ts.map +0 -1
  185. package/dist/solution/ShopDiscount/types.d.ts.map +0 -1
  186. package/dist/solution/ShopDiscount/utils.d.ts.map +0 -1
  187. package/dist/solution/index.d.ts.map +0 -1
  188. package/dist/store/createStore.d.ts.map +0 -1
  189. package/dist/types/index.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { IStep, IStepModuleAPI } from "./tyeps";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { IStep, IStepModuleAPI } from './tyeps';
4
4
  export declare class StepModule extends BaseModule implements Module, IStepModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -19,5 +19,16 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
19
19
  prevStep(): void;
20
20
  nextStep(): void;
21
21
  gotoStep(stepIndex: number): void;
22
+ /**
23
+ * 添加步骤
24
+ * @param step 步骤
25
+ * @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
26
+ */
27
+ addStep(step: IStep, key?: string): void;
28
+ /**
29
+ * 删除步骤
30
+ * @param key 步骤的 key
31
+ */
32
+ removeStep(key: string): void;
22
33
  storeChange(): void;
23
34
  }
@@ -1,4 +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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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."); }
4
+ 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); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
2
8
  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; }
3
9
  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); } }
4
10
  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); }); }; }
@@ -23,8 +29,8 @@ export var StepModule = /*#__PURE__*/function (_BaseModule) {
23
29
  var _this;
24
30
  _classCallCheck(this, StepModule);
25
31
  _this = _super.call(this, name, version);
26
- _defineProperty(_assertThisInitialized(_this), "defaultName", "step");
27
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
32
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'step');
33
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
28
34
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
29
35
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
30
36
  _defineProperty(_assertThisInitialized(_this), "openCache", false);
@@ -118,6 +124,52 @@ export var StepModule = /*#__PURE__*/function (_BaseModule) {
118
124
  value: function gotoStep(stepIndex) {
119
125
  this.setCurrentStep(stepIndex);
120
126
  }
127
+
128
+ /**
129
+ * 添加步骤
130
+ * @param step 步骤
131
+ * @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
132
+ */
133
+ }, {
134
+ key: "addStep",
135
+ value: function addStep(step, key) {
136
+ var stepList = this.store.stepList;
137
+
138
+ // 前置检测step在stepList中是否存在
139
+ var index = stepList.findIndex(function (n) {
140
+ return n.key === step.key;
141
+ });
142
+ if (index !== -1) {
143
+ console.log('[StepModule] 步骤已存在,添加失败');
144
+ return;
145
+ }
146
+ if (key) {
147
+ var _index = this.store.stepList.findIndex(function (n) {
148
+ return n.key === key;
149
+ });
150
+ if (_index !== -1) {
151
+ stepList.splice(_index + 1, 0, step);
152
+ } else {
153
+ stepList = [].concat(_toConsumableArray(stepList), [step]);
154
+ }
155
+ } else {
156
+ stepList.splice(this.store.currentStepIndex + 1, 0, step);
157
+ }
158
+ this.store.stepList = _toConsumableArray(stepList);
159
+ }
160
+
161
+ /**
162
+ * 删除步骤
163
+ * @param key 步骤的 key
164
+ */
165
+ }, {
166
+ key: "removeStep",
167
+ value: function removeStep(key) {
168
+ var newStepList = this.store.stepList.filter(function (n) {
169
+ return n.key !== key;
170
+ });
171
+ this.store.stepList = _toConsumableArray(newStepList);
172
+ }
121
173
  }, {
122
174
  key: "storeChange",
123
175
  value: function storeChange() {
@@ -1,17 +1,24 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { CartItem } from "../Cart/types";
4
- import { ISummaryState, ISummaryModuleAPI } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { CartItem } from '../Cart/types';
4
+ import { ISummaryState, ISummaryModuleAPI } from './types';
5
5
  export declare class SummaryModule extends BaseModule implements Module, ISummaryModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
8
8
  private shopStore;
9
9
  private store;
10
+ private request;
10
11
  private cacheId;
11
12
  private openCache;
12
13
  private fatherModule;
13
14
  constructor(name?: string, version?: string);
14
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
15
- getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
16
+ getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
17
+ /**
18
+ * 获取协议
19
+ * @param protocolId 协议ID
20
+ * @returns 协议
21
+ */
22
+ getProtocol(protocolId: string): Promise<any>;
16
23
  storeChange(): void;
17
24
  }
@@ -24,10 +24,11 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
24
24
  var _this;
25
25
  _classCallCheck(this, SummaryModule);
26
26
  _this = _super.call(this, name, version);
27
- _defineProperty(_assertThisInitialized(_this), "defaultName", "summary");
28
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
27
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'summary');
28
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
29
29
  _defineProperty(_assertThisInitialized(_this), "shopStore", void 0);
30
30
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
31
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
31
32
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
32
33
  _defineProperty(_assertThisInitialized(_this), "openCache", false);
33
34
  _defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
@@ -43,7 +44,8 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
43
44
  case 0:
44
45
  this.core = core;
45
46
  this.store = options.store;
46
- this.shopStore = this.core.getPlugin("shopStore");
47
+ this.shopStore = this.core.getPlugin('shopStore');
48
+ this.request = this.core.getPlugin('request');
47
49
  if (options.initialState) {
48
50
  this.store.summary = options.initialState.summary;
49
51
  }
@@ -55,11 +57,11 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
55
57
  this.fatherModule = options.otherParams.fatherModule;
56
58
  }
57
59
  if (this.shopStore) {
58
- _context.next = 8;
60
+ _context.next = 9;
59
61
  break;
60
62
  }
61
- throw new Error("SummaryModule 需要 shopStore 插件支持");
62
- case 8:
63
+ throw new Error('SummaryModule 需要 shopStore 插件支持');
64
+ case 9:
63
65
  case "end":
64
66
  return _context.stop();
65
67
  }
@@ -79,7 +81,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
79
81
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
80
82
  while (1) switch (_context2.prev = _context2.next) {
81
83
  case 0:
82
- shopInfo = ((_this$shopStore$get = this.shopStore.get("core")) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.shop) || {};
84
+ shopInfo = ((_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.shop) || {};
83
85
  summary = calculatePriceDetails(shopInfo, cartItems);
84
86
  this.store.summary = summary;
85
87
  return _context2.abrupt("return", this.store.summary);
@@ -94,6 +96,30 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
94
96
  }
95
97
  return getSummary;
96
98
  }()
99
+ /**
100
+ * 获取协议
101
+ * @param protocolId 协议ID
102
+ * @returns 协议
103
+ */
104
+ }, {
105
+ key: "getProtocol",
106
+ value: (function () {
107
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(protocolId) {
108
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
109
+ while (1) switch (_context3.prev = _context3.next) {
110
+ case 0:
111
+ return _context3.abrupt("return", this.request.get("/shop-policy/".concat(protocolId)));
112
+ case 1:
113
+ case "end":
114
+ return _context3.stop();
115
+ }
116
+ }, _callee3, this);
117
+ }));
118
+ function getProtocol(_x4) {
119
+ return _getProtocol.apply(this, arguments);
120
+ }
121
+ return getProtocol;
122
+ }())
97
123
  }, {
98
124
  key: "storeChange",
99
125
  value: function storeChange() {
@@ -1,13 +1,34 @@
1
- import { CartItem } from "../Cart/types";
1
+ import { CartItem } from '../Cart/types';
2
2
  export interface ISummaryState {
3
3
  summary: {
4
+ /** 商品总价 */
4
5
  subtotal: string | number;
6
+ /** 最终总价 */
5
7
  total: string | number;
8
+ /** 税率标题 */
6
9
  taxTitle?: string;
10
+ /** 商品总费率 */
7
11
  totalTaxFee?: string | number;
12
+ /** 商品价格是否包含费率 */
8
13
  isPriceIncludeTax?: 0 | 1;
14
+ /** 定金 */
15
+ deposit?: {
16
+ /** 定金总价 */
17
+ total?: string | number;
18
+ /** */
19
+ policies?: IProtocol[];
20
+ };
9
21
  };
10
22
  }
23
+ /**
24
+ * 定金协议
25
+ */
26
+ export interface IProtocol {
27
+ /** 协议名称 */
28
+ title: string;
29
+ /** 协议id */
30
+ id: string;
31
+ }
11
32
  export interface ISummaryModuleAPI {
12
- getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
33
+ getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
13
34
  }
@@ -1,7 +1,7 @@
1
- import Decimal from "decimal.js";
2
- import { CartItem } from "../Cart/types";
3
- import { ISummaryState } from "./types";
4
- export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState["summary"];
1
+ import Decimal from 'decimal.js';
2
+ import { CartItem } from '../Cart/types';
3
+ import { ISummaryState } from './types';
4
+ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState['summary'];
5
5
  /**
6
6
  * 计算商品小计(不含其他费用)
7
7
  * @param items - 购物车商品数组
@@ -17,3 +17,13 @@ export declare const calculateSubtotal: (items: CartItem[]) => string;
17
17
  * @Author: xiangfeng.xue
18
18
  */
19
19
  export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
20
+ /**
21
+ * @title: 计算定金
22
+ * @param items - 购物车商品数组
23
+ * @returns 定金字符串,保留2位小数
24
+ */
25
+ export declare const calculateDeposit: (items: CartItem[]) => {
26
+ total: string;
27
+ protocols: any[];
28
+ hasDeposit: never;
29
+ } | undefined;
@@ -1,16 +1,20 @@
1
- import Decimal from "decimal.js";
1
+ import Decimal from 'decimal.js';
2
2
  export var calculatePriceDetails = function calculatePriceDetails(shopInfo, items) {
3
3
  var subtotal = new Decimal(calculateSubtotal(items));
4
4
  var totalTaxFee = new Decimal(calculateTaxFee(shopInfo, items));
5
5
 
6
6
  // 计算总价
7
7
  var total = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subtotal : subtotal.plus(totalTaxFee);
8
+
9
+ // 计算定金
10
+ var deposit = calculateDeposit(items);
8
11
  return {
9
12
  subtotal: subtotal.toFixed(2),
10
13
  total: total.toFixed(2),
11
14
  taxTitle: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_title,
12
15
  totalTaxFee: totalTaxFee.toFixed(2),
13
- isPriceIncludeTax: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.is_price_include_tax
16
+ isPriceIncludeTax: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.is_price_include_tax,
17
+ deposit: deposit
14
18
  };
15
19
  };
16
20
 
@@ -21,7 +25,7 @@ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, item
21
25
  */
22
26
  export var calculateSubtotal = function calculateSubtotal(items) {
23
27
  if (!(items !== null && items !== void 0 && items.length)) {
24
- return "0.00";
28
+ return '0.00';
25
29
  }
26
30
  var subtotal = items.reduce(function (sum, item) {
27
31
  var cartItemTotalPrice = new Decimal(item.total || 0);
@@ -40,7 +44,7 @@ export var calculateSubtotal = function calculateSubtotal(items) {
40
44
  */
41
45
  export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
42
46
  if (!(items !== null && items !== void 0 && items.length)) {
43
- return "0.00";
47
+ return '0.00';
44
48
  }
45
49
  var _ref = shopInfo || {},
46
50
  is_price_include_tax = _ref.is_price_include_tax,
@@ -52,4 +56,42 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
52
56
  return sum.plus(productTaxRate);
53
57
  }, new Decimal(0));
54
58
  return totalTaxFee;
59
+ };
60
+
61
+ /**
62
+ * @title: 计算定金
63
+ * @param items - 购物车商品数组
64
+ * @returns 定金字符串,保留2位小数
65
+ */
66
+ export var calculateDeposit = function calculateDeposit(items) {
67
+ if (!(items !== null && items !== void 0 && items.length)) {
68
+ return undefined;
69
+ }
70
+ var protocols = [];
71
+ var hasDeposit = false;
72
+ var total = items.reduce(function (sum, item) {
73
+ if (item !== null && item !== void 0 && item.deposit) {
74
+ var _item$deposit, _item$deposit2;
75
+ hasDeposit = true;
76
+ var cartItemTotalPrice = new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
77
+ // 将协议数据去重合并
78
+ item === null || item === void 0 || (_item$deposit2 = item.deposit) === null || _item$deposit2 === void 0 || (_item$deposit2 = _item$deposit2.protocols) === null || _item$deposit2 === void 0 || _item$deposit2.forEach(function (protocol) {
79
+ if (protocols.findIndex(function (p) {
80
+ return p.id === protocol.id;
81
+ }) === -1) {
82
+ protocols.push(protocol);
83
+ }
84
+ });
85
+ return sum.plus(cartItemTotalPrice);
86
+ }
87
+ return sum;
88
+ }, new Decimal(0));
89
+ if (hasDeposit) {
90
+ return {
91
+ total: total.toFixed(2),
92
+ protocols: protocols,
93
+ hasDeposit: hasDeposit
94
+ };
95
+ }
96
+ return undefined;
55
97
  };
@@ -1,3 +1,13 @@
1
1
  export * from './Product';
2
2
  export * from './ProductList';
3
3
  export * from './Cart';
4
+ export * from './Account';
5
+ export * from './AccountList';
6
+ export * from './Date';
7
+ export * from './Guests';
8
+ export * from './Order';
9
+ export * from './Payment';
10
+ export * from './Resource';
11
+ export * from './Step';
12
+ export * from './Summary';
13
+ export * from './Schedule';
@@ -1,3 +1,13 @@
1
1
  export * from "./Product";
2
2
  export * from "./ProductList";
3
- export * from "./Cart";
3
+ export * from "./Cart";
4
+ export * from "./Account";
5
+ export * from "./AccountList";
6
+ export * from "./Date";
7
+ export * from "./Guests";
8
+ export * from "./Order";
9
+ export * from "./Payment";
10
+ export * from "./Resource";
11
+ export * from "./Step";
12
+ export * from "./Summary";
13
+ export * from "./Schedule";
@@ -1,3 +1,3 @@
1
- export * from "./request";
2
- export * from "./window";
3
- export * from "./shopStore";
1
+ export * from './request';
2
+ export * from './window';
3
+ export * from './shopStore';
@@ -1,4 +1,4 @@
1
- import { Plugin } from "../types";
1
+ import { Plugin } from '../types';
2
2
  /**
3
3
  * RequestPlugin 接口定义
4
4
  */
@@ -40,13 +40,13 @@ export interface RequestPlugin extends Plugin {
40
40
  */
41
41
  export interface RequestOptions {
42
42
  url?: string;
43
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
43
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
44
44
  headers?: Record<string, string>;
45
45
  data?: any;
46
46
  body?: any;
47
47
  params?: Record<string, string | number | boolean>;
48
48
  timeout?: number;
49
- responseType?: "json" | "text" | "arraybuffer" | "blob";
49
+ responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
50
50
  withCredentials?: boolean;
51
51
  useCache?: boolean;
52
52
  }
@@ -52,7 +52,7 @@ export var RequestError = /*#__PURE__*/function (_Error) {
52
52
  _defineProperty(_assertThisInitialized(_this), "response", void 0);
53
53
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
54
54
  _defineProperty(_assertThisInitialized(_this), "config", void 0);
55
- _this.name = "RequestError";
55
+ _this.name = 'RequestError';
56
56
  _this.config = config;
57
57
  _this.request = request;
58
58
  _this.response = response;
@@ -67,19 +67,19 @@ export var RequestError = /*#__PURE__*/function (_Error) {
67
67
  var RequestPluginImpl = /*#__PURE__*/function () {
68
68
  function RequestPluginImpl() {
69
69
  _classCallCheck(this, RequestPluginImpl);
70
- _defineProperty(this, "name", "request");
71
- _defineProperty(this, "version", "1.0.0");
70
+ _defineProperty(this, "name", 'request');
71
+ _defineProperty(this, "version", '1.0.0');
72
72
  _defineProperty(this, "core", null);
73
73
  /**
74
74
  * 默认请求选项
75
75
  */
76
76
  _defineProperty(this, "defaultOptions", {
77
- method: "GET",
77
+ method: 'GET',
78
78
  headers: {
79
- "Content-Type": "application/json"
79
+ 'Content-Type': 'application/json'
80
80
  },
81
81
  timeout: 30000,
82
- responseType: "json"
82
+ responseType: 'json'
83
83
  });
84
84
  /**
85
85
  * 全局拦截器
@@ -96,14 +96,14 @@ var RequestPluginImpl = /*#__PURE__*/function () {
96
96
  // 初始化方法
97
97
  function initialize() {
98
98
  this.core = globalThis.pisellOS;
99
- console.log("[RequestPlugin] 初始化完成");
99
+ console.log('[RequestPlugin] 初始化完成');
100
100
  }
101
101
 
102
102
  // 销毁方法
103
103
  }, {
104
104
  key: "destroy",
105
105
  value: function destroy() {
106
- console.log("[RequestPlugin] 已销毁");
106
+ console.log('[RequestPlugin] 已销毁');
107
107
  }
108
108
 
109
109
  /**
@@ -142,7 +142,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
142
142
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
143
143
  return this.request(_objectSpread(_objectSpread({}, options), {}, {
144
144
  url: url,
145
- method: "GET"
145
+ method: 'GET'
146
146
  }));
147
147
  }
148
148
 
@@ -155,7 +155,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
155
155
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
156
156
  return this.request(_objectSpread(_objectSpread({}, options), {}, {
157
157
  url: url,
158
- method: "POST",
158
+ method: 'POST',
159
159
  data: data
160
160
  }));
161
161
  }
@@ -169,7 +169,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
169
169
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
170
170
  return this.request(_objectSpread(_objectSpread({}, options), {}, {
171
171
  url: url,
172
- method: "PUT",
172
+ method: 'PUT',
173
173
  data: data
174
174
  }));
175
175
  }
@@ -183,7 +183,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
183
183
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
184
184
  return this.request(_objectSpread(_objectSpread({}, options), {}, {
185
185
  url: url,
186
- method: "DELETE"
186
+ method: 'DELETE'
187
187
  }));
188
188
  }
189
189
 
@@ -202,10 +202,10 @@ var RequestPluginImpl = /*#__PURE__*/function () {
202
202
  config = _objectSpread(_objectSpread(_objectSpread({}, this.defaultOptions), options), {}, {
203
203
  headers: _objectSpread(_objectSpread({}, this.defaultOptions.headers), options.headers)
204
204
  });
205
- if (!config.headers["authorization"] && this.core) {
206
- windowPlugin = this.core.getPlugin("window");
205
+ if (!config.headers['authorization'] && this.core) {
206
+ windowPlugin = this.core.getPlugin('window');
207
207
  if (windowPlugin) {
208
- config.headers["authorization"] = windowPlugin.localStorage.getItem("token") || "";
208
+ config.headers['authorization'] = windowPlugin.localStorage.getItem('token') || '';
209
209
  }
210
210
  }
211
211
 
@@ -229,7 +229,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
229
229
  case 13:
230
230
  _context.prev = 13;
231
231
  _context.t0 = _context["catch"](7);
232
- _requestError2 = _context.t0 instanceof RequestError ? _context.t0 : new RequestError(_context.t0 instanceof Error ? _context.t0.message : "请求拦截器错误", config); // 应用错误拦截器
232
+ _requestError2 = _context.t0 instanceof RequestError ? _context.t0 : new RequestError(_context.t0 instanceof Error ? _context.t0.message : '请求拦截器错误', config); // 应用错误拦截器
233
233
  _processedError2 = _requestError2;
234
234
  _iterator5 = _createForOfIteratorHelper(this.interceptors.error);
235
235
  _context.prev = 18;
@@ -307,7 +307,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
307
307
  case 67:
308
308
  _context.prev = 67;
309
309
  _context.t4 = _context["catch"](61);
310
- requestError = _context.t4 instanceof RequestError ? _context.t4 : new RequestError(_context.t4 instanceof Error ? _context.t4.message : "响应拦截器错误", config, null, _response); // 应用错误拦截器
310
+ requestError = _context.t4 instanceof RequestError ? _context.t4 : new RequestError(_context.t4 instanceof Error ? _context.t4.message : '响应拦截器错误', config, null, _response); // 应用错误拦截器
311
311
  processedError = requestError;
312
312
  _iterator3 = _createForOfIteratorHelper(this.interceptors.error);
313
313
  _context.prev = 72;
@@ -363,7 +363,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
363
363
  case 108:
364
364
  _context.prev = 108;
365
365
  _context.t8 = _context["catch"](51);
366
- _requestError = _context.t8 instanceof RequestError ? _context.t8 : new RequestError(_context.t8 instanceof Error ? _context.t8.message : "请求错误", config); // 应用错误拦截器
366
+ _requestError = _context.t8 instanceof RequestError ? _context.t8 : new RequestError(_context.t8 instanceof Error ? _context.t8.message : '请求错误', config); // 应用错误拦截器
367
367
  _processedError = _requestError;
368
368
  _iterator4 = _createForOfIteratorHelper(this.interceptors.error);
369
369
  _context.prev = 113;
@@ -429,7 +429,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
429
429
  _context2.next = 3;
430
430
  break;
431
431
  }
432
- throw new RequestError("URL不能为空", config);
432
+ throw new RequestError('URL不能为空', config);
433
433
  case 3:
434
434
  // 处理 URL 参数
435
435
  fullUrl = url;
@@ -439,22 +439,22 @@ var RequestPluginImpl = /*#__PURE__*/function () {
439
439
  key = _ref2[0],
440
440
  value = _ref2[1];
441
441
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(String(value)));
442
- }).join("&");
443
- fullUrl += (url.includes("?") ? "&" : "?") + queryString;
442
+ }).join('&');
443
+ fullUrl += (url.includes('?') ? '&' : '?') + queryString;
444
444
  }
445
445
 
446
446
  // 准备请求选项
447
447
  fetchOptions = {
448
448
  method: method,
449
449
  headers: _objectSpread({}, headers),
450
- credentials: withCredentials ? "include" : "same-origin"
450
+ credentials: withCredentials ? 'include' : 'same-origin'
451
451
  }; // 处理请求体
452
- if (data !== undefined && method !== "GET" && method !== "HEAD") {
452
+ if (data !== undefined && method !== 'GET' && method !== 'HEAD') {
453
453
  if (data instanceof FormData) {
454
454
  fetchOptions.body = data;
455
455
  // 当使用 FormData 时,删除 Content-Type,让浏览器自动设置
456
- delete fetchOptions.headers["Content-Type"];
457
- } else if (_typeof(data) === "object") {
456
+ delete fetchOptions.headers['Content-Type'];
457
+ } else if (_typeof(data) === 'object') {
458
458
  fetchOptions.body = JSON.stringify(data);
459
459
  } else {
460
460
  fetchOptions.body = data;
@@ -471,7 +471,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
471
471
  });
472
472
  _context2.prev = 8;
473
473
  // 发起请求,并竞争超时
474
- fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(new RequestError("当前环境不支持 fetch API", config));
474
+ fetchPromise = typeof fetch !== 'undefined' ? fetch(fullUrl, fetchOptions) : Promise.reject(new RequestError('当前环境不支持 fetch API', config));
475
475
  _context2.next = 12;
476
476
  return Promise.race([fetchPromise, timeoutPromise]);
477
477
  case 12:
@@ -483,7 +483,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
483
483
  });
484
484
 
485
485
  // 解析响应内容
486
- if (!(responseType === "json")) {
486
+ if (!(responseType === 'json')) {
487
487
  _context2.next = 29;
488
488
  break;
489
489
  }
@@ -505,7 +505,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
505
505
  _context2.next = 58;
506
506
  break;
507
507
  case 29:
508
- if (!(responseType === "text")) {
508
+ if (!(responseType === 'text')) {
509
509
  _context2.next = 35;
510
510
  break;
511
511
  }
@@ -516,7 +516,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
516
516
  _context2.next = 58;
517
517
  break;
518
518
  case 35:
519
- if (!(responseType === "arraybuffer")) {
519
+ if (!(responseType === 'arraybuffer')) {
520
520
  _context2.next = 41;
521
521
  break;
522
522
  }
@@ -527,7 +527,7 @@ var RequestPluginImpl = /*#__PURE__*/function () {
527
527
  _context2.next = 58;
528
528
  break;
529
529
  case 41:
530
- if (!(responseType === "blob")) {
530
+ if (!(responseType === 'blob')) {
531
531
  _context2.next = 47;
532
532
  break;
533
533
  }