@pisell/pisellos 0.0.25 → 0.0.27

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.
@@ -246,7 +246,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
246
246
  }
247
247
  throw new Error("Account with id ".concat(id, " not found"));
248
248
  case 6:
249
- this.store.accounts[index].destory();
249
+ this.store.accounts[index].destroy();
250
250
  this.store.accounts = [].concat(_toConsumableArray((this.store.accounts || []).slice(0, index)), _toConsumableArray((this.store.accounts || []).slice(index + 1)));
251
251
  this.store.accountList = this.store.accountList.filter(function (account) {
252
252
  return account.id !== id;
@@ -7,7 +7,7 @@ export declare class BaseModule {
7
7
  isSolution: boolean;
8
8
  protected core: PisellCore;
9
9
  constructor(name?: string, version?: string);
10
- destory(): void;
10
+ destroy(): void;
11
11
  checkSaveCache({ cacheId, fatherModule, store, cacheKey }: {
12
12
  cacheId: string | undefined;
13
13
  fatherModule: string | undefined;
@@ -18,8 +18,8 @@ export var BaseModule = /*#__PURE__*/function () {
18
18
  this.version = version || this.defaultVersion;
19
19
  }
20
20
  _createClass(BaseModule, [{
21
- key: "destory",
22
- value: function destory() {
21
+ key: "destroy",
22
+ value: function destroy() {
23
23
  this.core.effects.offByModuleDestroy(this.name);
24
24
  this.core.unregisterModule(this);
25
25
  }
@@ -1,5 +1,6 @@
1
1
  import { Module, PisellCore } from "../../types";
2
2
  import { BaseModule } from "../../modules/BaseModule";
3
+ import { Response } from "../../plugins";
3
4
  import { BookingByStepState } from "./types";
4
5
  import { CartItem, IUpdateItemParams, ProductData } from "../../modules";
5
6
  import { Account } from "../../modules/Account/types";
@@ -59,6 +60,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
59
60
  getProducts(): Promise<ProductData[]>;
60
61
  setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
61
62
  generateCartData(): Promise<void>;
63
+ getFreeProduct(id: string | number): Promise<Response<any>>;
62
64
  submitOrder(): Promise<void>;
63
65
  pay(): Promise<void>;
64
66
  getPayInfo(): Promise<void>;
@@ -78,7 +80,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
78
80
  * 从购物车中按类别删除信息
79
81
  */
80
82
  deleteCartItemInfo(types: "resource" | "time"): void;
81
- destory(): void;
83
+ destroy(): void;
82
84
  getResourcesList(): any[];
83
85
  getResourcesListByCartItem(id: string | number): {
84
86
  id: number | undefined;
@@ -531,17 +531,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
531
531
  return _generateCartData.apply(this, arguments);
532
532
  }
533
533
  return generateCartData;
534
- }() // 购物车提交订单
534
+ }() // 免费领取商品相关逻辑,上线了来不及加了,先放在这,后面要做到 payment 里面的
535
535
  }, {
536
- key: "submitOrder",
536
+ key: "getFreeProduct",
537
537
  value: function () {
538
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
539
- var cartItems;
538
+ var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id) {
539
+ var res;
540
540
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
541
541
  while (1) switch (_context13.prev = _context13.next) {
542
542
  case 0:
543
- cartItems = this.store.cart.getItems(); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
544
- cartItems.forEach(function (item) {
543
+ _context13.next = 2;
544
+ return this.request.post("/pay/order/free-pay/".concat(id));
545
+ case 2:
546
+ res = _context13.sent;
547
+ return _context13.abrupt("return", res);
548
+ case 4:
549
+ case "end":
550
+ return _context13.stop();
551
+ }
552
+ }, _callee13, this);
553
+ }));
554
+ function getFreeProduct(_x9) {
555
+ return _getFreeProduct.apply(this, arguments);
556
+ }
557
+ return getFreeProduct;
558
+ }() // 购物车提交订单
559
+ }, {
560
+ key: "submitOrder",
561
+ value: function () {
562
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
563
+ var cartItems, newCartItems;
564
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
565
+ while (1) switch (_context14.prev = _context14.next) {
566
+ case 0:
567
+ cartItems = this.store.cart.getItems();
568
+ newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
569
+ newCartItems.forEach(function (item) {
545
570
  item._origin.resources = item._origin.resources.map(function (n) {
546
571
  var newResourcesItem = cloneDeep(n);
547
572
  delete newResourcesItem.id;
@@ -550,16 +575,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
550
575
  return _objectSpread({}, newResourcesItem);
551
576
  });
552
577
  });
553
- return _context13.abrupt("return", this.store.order.commitOrder({
578
+ return _context14.abrupt("return", this.store.order.commitOrder({
554
579
  query: {
555
- cartItems: cartItems
580
+ cartItems: newCartItems
556
581
  }
557
582
  }));
558
- case 3:
583
+ case 4:
559
584
  case "end":
560
- return _context13.stop();
585
+ return _context14.stop();
561
586
  }
562
- }, _callee13, this);
587
+ }, _callee14, this);
563
588
  }));
564
589
  function submitOrder() {
565
590
  return _submitOrder.apply(this, arguments);
@@ -569,14 +594,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
569
594
  }, {
570
595
  key: "pay",
571
596
  value: function () {
572
- var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
573
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
574
- while (1) switch (_context14.prev = _context14.next) {
597
+ var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
598
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
599
+ while (1) switch (_context15.prev = _context15.next) {
575
600
  case 0:
576
601
  case "end":
577
- return _context14.stop();
602
+ return _context15.stop();
578
603
  }
579
- }, _callee14);
604
+ }, _callee15);
580
605
  }));
581
606
  function pay() {
582
607
  return _pay.apply(this, arguments);
@@ -586,14 +611,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
586
611
  }, {
587
612
  key: "getPayInfo",
588
613
  value: function () {
589
- var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
590
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
591
- while (1) switch (_context15.prev = _context15.next) {
614
+ var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
615
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
616
+ while (1) switch (_context16.prev = _context16.next) {
592
617
  case 0:
593
618
  case "end":
594
- return _context15.stop();
619
+ return _context16.stop();
595
620
  }
596
- }, _callee15);
621
+ }, _callee16);
597
622
  }));
598
623
  function getPayInfo() {
599
624
  return _getPayInfo.apply(this, arguments);
@@ -603,15 +628,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
603
628
  }, {
604
629
  key: "setOtherParams",
605
630
  value: function () {
606
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
631
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
607
632
  var _ref4,
608
633
  _ref4$cover,
609
634
  cover,
610
- _args16 = arguments;
611
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
612
- while (1) switch (_context16.prev = _context16.next) {
635
+ _args17 = arguments;
636
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
637
+ while (1) switch (_context17.prev = _context17.next) {
613
638
  case 0:
614
- _ref4 = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
639
+ _ref4 = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
615
640
  if (cover) {
616
641
  this.otherParams = params;
617
642
  } else {
@@ -619,11 +644,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
619
644
  }
620
645
  case 2:
621
646
  case "end":
622
- return _context16.stop();
647
+ return _context17.stop();
623
648
  }
624
- }, _callee16, this);
649
+ }, _callee17, this);
625
650
  }));
626
- function setOtherParams(_x9) {
651
+ function setOtherParams(_x10) {
627
652
  return _setOtherParams.apply(this, arguments);
628
653
  }
629
654
  return setOtherParams;
@@ -631,16 +656,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
631
656
  }, {
632
657
  key: "getOtherParams",
633
658
  value: function () {
634
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
635
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
636
- while (1) switch (_context17.prev = _context17.next) {
659
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
660
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
661
+ while (1) switch (_context18.prev = _context18.next) {
637
662
  case 0:
638
- return _context17.abrupt("return", this.otherParams);
663
+ return _context18.abrupt("return", this.otherParams);
639
664
  case 1:
640
665
  case "end":
641
- return _context17.stop();
666
+ return _context18.stop();
642
667
  }
643
- }, _callee17, this);
668
+ }, _callee18, this);
644
669
  }));
645
670
  function getOtherParams() {
646
671
  return _getOtherParams.apply(this, arguments);
@@ -719,15 +744,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
719
744
  this.store.cart.deleteCartItemInfo(types);
720
745
  }
721
746
  }, {
722
- key: "destory",
723
- value: function destory() {
747
+ key: "destroy",
748
+ value: function destroy() {
724
749
  var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
725
- (_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destory();
726
- (_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destory();
727
- (_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destory();
728
- (_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destory();
729
- (_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destory();
730
- (_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destory();
750
+ (_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
751
+ (_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
752
+ (_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
753
+ (_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
754
+ (_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
755
+ (_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
731
756
  this.core.effects.offByModuleDestroy(this.name);
732
757
  this.core.unregisterModule(this);
733
758
  }
@@ -1024,7 +1049,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1024
1049
  }
1025
1050
  } else {
1026
1051
  var _productResources$fin;
1027
- debugger;
1028
1052
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1029
1053
  var productResources = getResourcesByProduct(resourcesMap, item, allCartItems);
1030
1054
  // 自动选择 productResources 中对应 resources_code 的资源
@@ -1045,7 +1069,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1045
1069
  }
1046
1070
  });
1047
1071
  });
1048
- debugger;
1049
1072
  return {
1050
1073
  errorList: errorList
1051
1074
  };
@@ -1088,7 +1111,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1088
1111
  duration = accountDuration;
1089
1112
  }
1090
1113
  });
1091
- debugger;
1092
1114
  var timeSlots = getTimeSlicesByResources({
1093
1115
  resourceIds: resourceIds,
1094
1116
  resourcesMap: resourcesMap,
@@ -165,7 +165,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
165
165
  targetCacheData = data[this.options.otherParams.cacheId];
166
166
  }
167
167
  }
168
-
169
168
  // 注册优惠模块
170
169
  var discount = new DiscountModule("".concat(this.name, "_discount"));
171
170
  this.core.registerModule(discount, {
@@ -126,7 +126,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
126
126
  if (index === -1) {
127
127
  throw new Error(`Account with id ${id} not found`);
128
128
  }
129
- this.store.accounts[index].destory();
129
+ this.store.accounts[index].destroy();
130
130
  this.store.accounts = [
131
131
  ...(this.store.accounts || []).slice(0, index),
132
132
  ...(this.store.accounts || []).slice(index + 1)
@@ -7,7 +7,7 @@ export declare class BaseModule {
7
7
  isSolution: boolean;
8
8
  protected core: PisellCore;
9
9
  constructor(name?: string, version?: string);
10
- destory(): void;
10
+ destroy(): void;
11
11
  checkSaveCache({ cacheId, fatherModule, store, cacheKey }: {
12
12
  cacheId: string | undefined;
13
13
  fatherModule: string | undefined;
@@ -30,7 +30,7 @@ var BaseModule = class {
30
30
  this.name = name || this.defaultName;
31
31
  this.version = version || this.defaultVersion;
32
32
  }
33
- destory() {
33
+ destroy() {
34
34
  this.core.effects.offByModuleDestroy(this.name);
35
35
  this.core.unregisterModule(this);
36
36
  }
@@ -1,5 +1,6 @@
1
1
  import { Module, PisellCore } from "../../types";
2
2
  import { BaseModule } from "../../modules/BaseModule";
3
+ import { Response } from "../../plugins";
3
4
  import { BookingByStepState } from "./types";
4
5
  import { CartItem, IUpdateItemParams, ProductData } from "../../modules";
5
6
  import { Account } from "../../modules/Account/types";
@@ -59,6 +60,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
59
60
  getProducts(): Promise<ProductData[]>;
60
61
  setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
61
62
  generateCartData(): Promise<void>;
63
+ getFreeProduct(id: string | number): Promise<Response<any>>;
62
64
  submitOrder(): Promise<void>;
63
65
  pay(): Promise<void>;
64
66
  getPayInfo(): Promise<void>;
@@ -78,7 +80,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
78
80
  * 从购物车中按类别删除信息
79
81
  */
80
82
  deleteCartItemInfo(types: "resource" | "time"): void;
81
- destory(): void;
83
+ destroy(): void;
82
84
  getResourcesList(): any[];
83
85
  getResourcesListByCartItem(id: string | number): {
84
86
  id: number | undefined;
@@ -256,10 +256,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
256
256
  // 生成购物车的正规数据
257
257
  async generateCartData() {
258
258
  }
259
+ // 免费领取商品相关逻辑,上线了来不及加了,先放在这,后面要做到 payment 里面的
260
+ async getFreeProduct(id) {
261
+ const res = await this.request.post(`/pay/order/free-pay/${id}`);
262
+ return res;
263
+ }
259
264
  // 购物车提交订单
260
265
  async submitOrder() {
261
266
  const cartItems = this.store.cart.getItems();
262
- cartItems.forEach((item) => {
267
+ const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
268
+ newCartItems.forEach((item) => {
263
269
  item._origin.resources = item._origin.resources.map((n) => {
264
270
  const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
265
271
  delete newResourcesItem.id;
@@ -268,7 +274,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
268
274
  return { ...newResourcesItem };
269
275
  });
270
276
  });
271
- return this.store.order.commitOrder({ query: { cartItems } });
277
+ return this.store.order.commitOrder({ query: { cartItems: newCartItems } });
272
278
  }
273
279
  // 拉起支付模块
274
280
  async pay() {
@@ -336,14 +342,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
336
342
  deleteCartItemInfo(types) {
337
343
  this.store.cart.deleteCartItemInfo(types);
338
344
  }
339
- destory() {
345
+ destroy() {
340
346
  var _a, _b, _c, _d, _e, _f;
341
- (_a = this.store.cart) == null ? void 0 : _a.destory();
342
- (_b = this.store.step) == null ? void 0 : _b.destory();
343
- (_c = this.store.products) == null ? void 0 : _c.destory();
344
- (_d = this.store.guests) == null ? void 0 : _d.destory();
345
- (_e = this.store.date) == null ? void 0 : _e.destory();
346
- (_f = this.store.accountList) == null ? void 0 : _f.destory();
347
+ (_a = this.store.cart) == null ? void 0 : _a.destroy();
348
+ (_b = this.store.step) == null ? void 0 : _b.destroy();
349
+ (_c = this.store.products) == null ? void 0 : _c.destroy();
350
+ (_d = this.store.guests) == null ? void 0 : _d.destroy();
351
+ (_e = this.store.date) == null ? void 0 : _e.destroy();
352
+ (_f = this.store.accountList) == null ? void 0 : _f.destroy();
347
353
  this.core.effects.offByModuleDestroy(this.name);
348
354
  this.core.unregisterModule(this);
349
355
  }
@@ -573,7 +579,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
573
579
  errorList.push(item._id);
574
580
  }
575
581
  } else {
576
- debugger;
577
582
  const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
578
583
  const targetRenderList = (_a = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _a.renderList;
579
584
  if (targetRenderList && targetRenderList.length > 0) {
@@ -592,7 +597,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
592
597
  }
593
598
  });
594
599
  });
595
- debugger;
596
600
  return { errorList };
597
601
  }
598
602
  // 从购物车中获取已经分配好第一步资源的所有时间片
@@ -625,7 +629,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
625
629
  duration = accountDuration;
626
630
  }
627
631
  });
628
- debugger;
629
632
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
630
633
  resourceIds,
631
634
  resourcesMap,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.25",
4
+ "version": "0.0.27",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",