@pisell/pisellos 0.0.64 → 0.0.66

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.
@@ -44,9 +44,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
44
44
  collection?: number | string[];
45
45
  schedule_ids?: number[];
46
46
  }): Promise<any>;
47
- loadProductByScheduleDate({ date, product_ids, }: {
47
+ loadProductByScheduleDate({ date, product_ids, category_ids, }: {
48
48
  date: string;
49
49
  product_ids?: number[];
50
+ category_ids?: number[];
50
51
  }): Promise<any>;
51
52
  loadAllSchedule(): Promise<void>;
52
53
  loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
@@ -243,11 +243,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
243
243
  key: "loadProductByScheduleDate",
244
244
  value: function () {
245
245
  var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
246
- var date, product_ids, scheduleList, scheduleIds;
246
+ var date, product_ids, _ref2$category_ids, category_ids, scheduleList, scheduleIds;
247
247
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
248
248
  while (1) switch (_context3.prev = _context3.next) {
249
249
  case 0:
250
- date = _ref2.date, product_ids = _ref2.product_ids;
250
+ date = _ref2.date, product_ids = _ref2.product_ids, _ref2$category_ids = _ref2.category_ids, category_ids = _ref2$category_ids === void 0 ? [] : _ref2$category_ids;
251
251
  scheduleList = this.store.schedule.getAvailabilityScheduleDateList(); // 缓存下这次选择的结果,如果是先选日期再选 duration 类商品,后面用得到
252
252
  this.setDateRange([{
253
253
  date: date,
@@ -268,7 +268,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
268
268
  _context3.next = 6;
269
269
  return this.loadProducts({
270
270
  schedule_ids: scheduleIds,
271
- product_ids: product_ids
271
+ product_ids: product_ids,
272
+ category_ids: category_ids
272
273
  });
273
274
  case 6:
274
275
  return _context3.abrupt("return", _context3.sent);
@@ -1504,12 +1505,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1504
1505
  var allCartItems = cloneDeep(_this8.store.cart.getItems());
1505
1506
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1506
1507
  var selectedResources = [];
1508
+ var _resources = cloneDeep(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || []);
1509
+ var currentResourcesRenderList = [];
1510
+ _resources.forEach(function (n) {
1511
+ var _n$renderList;
1512
+ if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
1513
+ currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
1514
+ }
1515
+ });
1516
+ var _resourcesMap = getResourcesMap(currentResourcesRenderList);
1507
1517
  if (item.holder_id) {
1508
- selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
1518
+ selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, _resourcesMap);
1509
1519
  } else {
1510
- selectedResources = getOthersCartSelectedResources(allCartItems, item._id, resourcesMap);
1520
+ selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap);
1511
1521
  }
1512
- var productResources = getResourcesByProduct(resourcesMap, ((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || [], selectedResources, currentCapacity);
1522
+ var productResources = getResourcesByProduct(_resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
1513
1523
  // 自动选择 productResources 中对应 resources_code 的资源
1514
1524
  var targetRenderList = (_productResources$fin = productResources.find(function (n) {
1515
1525
  return n.code === resources_code;
@@ -44,9 +44,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
44
44
  collection?: number | string[];
45
45
  schedule_ids?: number[];
46
46
  }): Promise<any>;
47
- loadProductByScheduleDate({ date, product_ids, }: {
47
+ loadProductByScheduleDate({ date, product_ids, category_ids, }: {
48
48
  date: string;
49
49
  product_ids?: number[];
50
+ category_ids?: number[];
50
51
  }): Promise<any>;
51
52
  loadAllSchedule(): Promise<void>;
52
53
  loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
@@ -187,7 +187,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
187
187
  }
188
188
  async loadProductByScheduleDate({
189
189
  date,
190
- product_ids
190
+ product_ids,
191
+ category_ids = []
191
192
  }) {
192
193
  const scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
193
194
  this.setDateRange([
@@ -195,7 +196,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
195
196
  { date, status: "available", week: "", weekNum: 0 }
196
197
  ]);
197
198
  const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
198
- return await this.loadProducts({ schedule_ids: scheduleIds, product_ids });
199
+ return await this.loadProducts({ schedule_ids: scheduleIds, product_ids, category_ids });
199
200
  }
200
201
  // 加载当前店铺下所有 schedule
201
202
  async loadAllSchedule() {
@@ -912,22 +913,31 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
912
913
  } else {
913
914
  const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
914
915
  let selectedResources = [];
916
+ const resources2 = (0, import_lodash_es.cloneDeep)(((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []);
917
+ const currentResourcesRenderList = [];
918
+ resources2.forEach((n) => {
919
+ var _a3;
920
+ if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
921
+ currentResourcesRenderList.push(...n.renderList || []);
922
+ }
923
+ });
924
+ const resourcesMap2 = (0, import_utils.getResourcesMap)(currentResourcesRenderList);
915
925
  if (item.holder_id) {
916
926
  selectedResources = (0, import_resources.getOthersSelectedResources)(
917
927
  allCartItems,
918
928
  item.holder_id,
919
- resourcesMap
929
+ resourcesMap2
920
930
  );
921
931
  } else {
922
932
  selectedResources = (0, import_resources.getOthersCartSelectedResources)(
923
933
  allCartItems,
924
934
  item._id,
925
- resourcesMap
935
+ resourcesMap2
926
936
  );
927
937
  }
928
938
  const productResources = (0, import_resources.getResourcesByProduct)(
929
- resourcesMap,
930
- ((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || [],
939
+ resourcesMap2,
940
+ (0, import_lodash_es.cloneDeep)(resources2),
931
941
  selectedResources,
932
942
  currentCapacity
933
943
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.64",
4
+ "version": "0.0.66",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",