@pisell/pisellos 0.0.25 → 0.0.26

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
  }
@@ -61,6 +61,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
61
61
  case 0:
62
62
  this.core = core;
63
63
  this.store = options.store;
64
+ debugger;
64
65
  if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
65
66
  this.store.list = options.initialState.list;
66
67
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
@@ -79,20 +80,20 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
79
80
  this.request = core.getPlugin("request");
80
81
  this.window = core.getPlugin("window");
81
82
  if (this.request) {
82
- _context.next = 9;
83
+ _context.next = 10;
83
84
  break;
84
85
  }
85
86
  throw new Error("购物车模块需要 request 插件支持");
86
- case 9:
87
+ case 10:
87
88
  if (this.window) {
88
- _context.next = 11;
89
+ _context.next = 12;
89
90
  break;
90
91
  }
91
92
  throw new Error("购物车模块需要 window 插件支持");
92
- case 11:
93
+ case 12:
93
94
  // this.store.temp = {};
94
95
  console.log("[CartModule] 初始化完成");
95
- case 12:
96
+ case 13:
96
97
  case "end":
97
98
  return _context.stop();
98
99
  }
@@ -115,6 +116,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
115
116
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
116
117
  while (1) switch (_context2.prev = _context2.next) {
117
118
  case 0:
119
+ debugger;
118
120
  account = params.account, product = params.product, bundle = params.bundle, options = params.options; // 生成一个唯一的 ID
119
121
  cartItem = {
120
122
  _id: getUniqueId(),
@@ -141,9 +143,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
141
143
  this.store.list = items;
142
144
 
143
145
  // 触发事件
144
- _context2.next = 8;
146
+ _context2.next = 9;
145
147
  return this.core.effects.emit("".concat(this.name, ":onAddItem"), cartItem);
146
- case 8:
148
+ case 9:
147
149
  case "end":
148
150
  return _context2.stop();
149
151
  }
@@ -78,7 +78,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
78
78
  * 从购物车中按类别删除信息
79
79
  */
80
80
  deleteCartItemInfo(types: "resource" | "time"): void;
81
- destory(): void;
81
+ destroy(): void;
82
82
  getResourcesList(): any[];
83
83
  getResourcesListByCartItem(id: string | number): {
84
84
  id: number | undefined;
@@ -75,6 +75,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
75
75
  }
76
76
  throw new Error("bookingByStep解决方案需要 request 插件支持");
77
77
  case 9:
78
+ debugger;
79
+
78
80
  // 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
79
81
  // 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
80
82
  targetCacheData = {};
@@ -105,7 +107,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
105
107
  }
106
108
  });
107
109
  this.core.effects.emit(BookingByStepHooks.onInited, {});
108
- case 14:
110
+ case 15:
109
111
  case "end":
110
112
  return _context.stop();
111
113
  }
@@ -719,15 +721,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
719
721
  this.store.cart.deleteCartItemInfo(types);
720
722
  }
721
723
  }, {
722
- key: "destory",
723
- value: function destory() {
724
+ key: "destroy",
725
+ value: function destroy() {
724
726
  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();
727
+ (_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
728
+ (_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
729
+ (_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
730
+ (_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
731
+ (_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
732
+ (_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
731
733
  this.core.effects.offByModuleDestroy(this.name);
732
734
  this.core.unregisterModule(this);
733
735
  }
@@ -1024,7 +1026,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1024
1026
  }
1025
1027
  } else {
1026
1028
  var _productResources$fin;
1027
- debugger;
1028
1029
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1029
1030
  var productResources = getResourcesByProduct(resourcesMap, item, allCartItems);
1030
1031
  // 自动选择 productResources 中对应 resources_code 的资源
@@ -1045,7 +1046,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1045
1046
  }
1046
1047
  });
1047
1048
  });
1048
- debugger;
1049
1049
  return {
1050
1050
  errorList: errorList
1051
1051
  };
@@ -1088,7 +1088,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1088
1088
  duration = accountDuration;
1089
1089
  }
1090
1090
  });
1091
- debugger;
1092
1091
  var timeSlots = getTimeSlicesByResources({
1093
1092
  resourceIds: resourceIds,
1094
1093
  resourcesMap: resourcesMap,
@@ -165,7 +165,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
165
165
  targetCacheData = data[this.options.otherParams.cacheId];
166
166
  }
167
167
  }
168
-
168
+ debugger;
169
169
  // 注册优惠模块
170
170
  var discount = new DiscountModule("".concat(this.name, "_discount"));
171
171
  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
  }
@@ -42,6 +42,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
42
42
  var _a, _b, _c;
43
43
  this.core = core;
44
44
  this.store = options.store;
45
+ debugger;
45
46
  if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
46
47
  this.store.list = options.initialState.list;
47
48
  this.core.effects.emit(`${this.name}:changed`, this.store.list);
@@ -69,6 +70,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
69
70
  * 添加商品到购物车
70
71
  */
71
72
  async addItem(params) {
73
+ debugger;
72
74
  const { account, product, bundle, options } = params;
73
75
  let cartItem = {
74
76
  _id: (0, import_utils.getUniqueId)(),
@@ -78,7 +78,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
78
78
  * 从购物车中按类别删除信息
79
79
  */
80
80
  deleteCartItemInfo(types: "resource" | "time"): void;
81
- destory(): void;
81
+ destroy(): void;
82
82
  getResourcesList(): any[];
83
83
  getResourcesListByCartItem(id: string | number): {
84
84
  id: number | undefined;
@@ -59,6 +59,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
59
59
  if (!this.request) {
60
60
  throw new Error("bookingByStep解决方案需要 request 插件支持");
61
61
  }
62
+ debugger;
62
63
  let targetCacheData = {};
63
64
  if ((_a = this.otherParams) == null ? void 0 : _a.cacheId) {
64
65
  const sessionData = this.window.sessionStorage.getItem(this.name);
@@ -336,14 +337,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
336
337
  deleteCartItemInfo(types) {
337
338
  this.store.cart.deleteCartItemInfo(types);
338
339
  }
339
- destory() {
340
+ destroy() {
340
341
  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();
342
+ (_a = this.store.cart) == null ? void 0 : _a.destroy();
343
+ (_b = this.store.step) == null ? void 0 : _b.destroy();
344
+ (_c = this.store.products) == null ? void 0 : _c.destroy();
345
+ (_d = this.store.guests) == null ? void 0 : _d.destroy();
346
+ (_e = this.store.date) == null ? void 0 : _e.destroy();
347
+ (_f = this.store.accountList) == null ? void 0 : _f.destroy();
347
348
  this.core.effects.offByModuleDestroy(this.name);
348
349
  this.core.unregisterModule(this);
349
350
  }
@@ -573,7 +574,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
573
574
  errorList.push(item._id);
574
575
  }
575
576
  } else {
576
- debugger;
577
577
  const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
578
578
  const targetRenderList = (_a = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _a.renderList;
579
579
  if (targetRenderList && targetRenderList.length > 0) {
@@ -592,7 +592,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
592
592
  }
593
593
  });
594
594
  });
595
- debugger;
596
595
  return { errorList };
597
596
  }
598
597
  // 从购物车中获取已经分配好第一步资源的所有时间片
@@ -625,7 +624,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
625
624
  duration = accountDuration;
626
625
  }
627
626
  });
628
- debugger;
629
627
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
630
628
  resourceIds,
631
629
  resourcesMap,
@@ -91,6 +91,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
91
91
  targetCacheData = data[this.options.otherParams.cacheId];
92
92
  }
93
93
  }
94
+ debugger;
94
95
  const discount = new import_Discount.DiscountModule(`${this.name}_discount`);
95
96
  this.core.registerModule(discount, {
96
97
  initialState: targetCacheData == null ? void 0 : targetCacheData[discount.name],
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.26",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",