@pisell/pisellos 0.0.50 → 0.0.51
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,7 +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
|
|
47
|
+
loadProductByScheduleDate({ date, product_ids, }: {
|
|
48
|
+
date: string;
|
|
49
|
+
product_ids?: number[];
|
|
50
|
+
}): Promise<any>;
|
|
48
51
|
loadAllSchedule(): Promise<void>;
|
|
49
52
|
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
50
53
|
startDate: string;
|
|
@@ -113,8 +113,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
this.core.effects.emit(BookingByStepHooks.onInited, {});
|
|
116
|
-
|
|
117
|
-
case 16:
|
|
116
|
+
case 15:
|
|
118
117
|
case "end":
|
|
119
118
|
return _context.stop();
|
|
120
119
|
}
|
|
@@ -211,7 +210,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
211
210
|
ids: product_ids,
|
|
212
211
|
collection: collection,
|
|
213
212
|
front_end_cache_id: this.cacheId,
|
|
214
|
-
|
|
213
|
+
client_schedule_ids: schedule_ids
|
|
215
214
|
}, {
|
|
216
215
|
useCache: true
|
|
217
216
|
});
|
|
@@ -233,24 +232,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
233
232
|
}, {
|
|
234
233
|
key: "loadProductByScheduleDate",
|
|
235
234
|
value: function () {
|
|
236
|
-
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(
|
|
237
|
-
var scheduleList, scheduleIds;
|
|
235
|
+
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
236
|
+
var date, product_ids, scheduleList, scheduleIds;
|
|
238
237
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
239
238
|
while (1) switch (_context3.prev = _context3.next) {
|
|
240
239
|
case 0:
|
|
241
|
-
|
|
240
|
+
date = _ref2.date, product_ids = _ref2.product_ids;
|
|
241
|
+
scheduleList = this.store.schedule.getAvailabilityScheduleDateList(); // 缓存下这次选择的结果,如果是先选日期再选 duration 类商品,后面用得到
|
|
242
|
+
this.setDateRange([{
|
|
243
|
+
date: date,
|
|
244
|
+
status: 'available',
|
|
245
|
+
week: '',
|
|
246
|
+
weekNum: 0
|
|
247
|
+
}]);
|
|
242
248
|
scheduleIds = scheduleList.filter(function (n) {
|
|
243
249
|
return n.date === date;
|
|
244
250
|
}).flatMap(function (n) {
|
|
245
251
|
return n.schedule_id;
|
|
246
252
|
});
|
|
247
|
-
_context3.next =
|
|
253
|
+
_context3.next = 6;
|
|
248
254
|
return this.loadProducts({
|
|
249
|
-
schedule_ids: scheduleIds
|
|
255
|
+
schedule_ids: scheduleIds,
|
|
256
|
+
product_ids: product_ids
|
|
250
257
|
});
|
|
251
|
-
case
|
|
258
|
+
case 6:
|
|
252
259
|
return _context3.abrupt("return", _context3.sent);
|
|
253
|
-
case
|
|
260
|
+
case 7:
|
|
254
261
|
case "end":
|
|
255
262
|
return _context3.stop();
|
|
256
263
|
}
|
|
@@ -289,13 +296,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
289
296
|
}, {
|
|
290
297
|
key: "loadScheduleAvailableDate",
|
|
291
298
|
value: function () {
|
|
292
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(
|
|
299
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
293
300
|
var _res$data$date_list;
|
|
294
301
|
var startDate, endDate, custom_page_id, dates, res;
|
|
295
302
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
296
303
|
while (1) switch (_context5.prev = _context5.next) {
|
|
297
304
|
case 0:
|
|
298
|
-
startDate =
|
|
305
|
+
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
|
|
299
306
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
300
307
|
if (dayjs(startDate).isBefore(dayjs())) {
|
|
301
308
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
@@ -353,13 +360,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
353
360
|
key: "storeProduct",
|
|
354
361
|
value: function () {
|
|
355
362
|
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
|
|
356
|
-
var activeAccount,
|
|
363
|
+
var activeAccount, _ref4, bundle, options, origin, product_variant_id, product, addCartItem;
|
|
357
364
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
358
365
|
while (1) switch (_context6.prev = _context6.next) {
|
|
359
366
|
case 0:
|
|
360
367
|
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
361
368
|
activeAccount = this.getActiveAccount();
|
|
362
|
-
|
|
369
|
+
_ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id;
|
|
363
370
|
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
364
371
|
product_variant_id: product_variant_id
|
|
365
372
|
});
|
|
@@ -607,18 +614,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
607
614
|
key: "getAvailableDate",
|
|
608
615
|
value: function () {
|
|
609
616
|
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
610
|
-
var _this3 = this
|
|
611
|
-
_this$otherParams3,
|
|
612
|
-
_this$otherParams4;
|
|
617
|
+
var _this3 = this;
|
|
613
618
|
var params,
|
|
614
619
|
products,
|
|
615
620
|
startDate,
|
|
616
621
|
endDate,
|
|
617
622
|
type,
|
|
618
623
|
tempProducts,
|
|
624
|
+
dateRange,
|
|
619
625
|
tempStartDate,
|
|
620
626
|
tempEndDate,
|
|
621
|
-
|
|
627
|
+
_ref5,
|
|
622
628
|
resourceIds,
|
|
623
629
|
rules,
|
|
624
630
|
resourcesMap,
|
|
@@ -650,18 +656,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
650
656
|
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
651
657
|
})];
|
|
652
658
|
}
|
|
653
|
-
|
|
654
|
-
|
|
659
|
+
_context13.next = 8;
|
|
660
|
+
return this.getDateRange();
|
|
661
|
+
case 8:
|
|
662
|
+
dateRange = _context13.sent;
|
|
663
|
+
tempStartDate = startDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[0].date);
|
|
664
|
+
tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[0].date);
|
|
655
665
|
if (tempProducts.length) {
|
|
656
|
-
_context13.next =
|
|
666
|
+
_context13.next = 13;
|
|
657
667
|
break;
|
|
658
668
|
}
|
|
659
669
|
return _context13.abrupt("return", []);
|
|
660
|
-
case
|
|
670
|
+
case 13:
|
|
661
671
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
662
|
-
|
|
672
|
+
_ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
|
|
663
673
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
664
|
-
_context13.next =
|
|
674
|
+
_context13.next = 17;
|
|
665
675
|
return this.store.date.getResourceDates({
|
|
666
676
|
url: params.url,
|
|
667
677
|
query: {
|
|
@@ -672,10 +682,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
672
682
|
rules: rules,
|
|
673
683
|
type: type
|
|
674
684
|
});
|
|
675
|
-
case
|
|
685
|
+
case 17:
|
|
676
686
|
res = _context13.sent;
|
|
677
687
|
return _context13.abrupt("return", res);
|
|
678
|
-
case
|
|
688
|
+
case 19:
|
|
679
689
|
case "end":
|
|
680
690
|
return _context13.stop();
|
|
681
691
|
}
|
|
@@ -928,14 +938,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
928
938
|
key: "setOtherParams",
|
|
929
939
|
value: function () {
|
|
930
940
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
931
|
-
var
|
|
932
|
-
|
|
941
|
+
var _ref6,
|
|
942
|
+
_ref6$cover,
|
|
933
943
|
cover,
|
|
934
944
|
_args23 = arguments;
|
|
935
945
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
936
946
|
while (1) switch (_context23.prev = _context23.next) {
|
|
937
947
|
case 0:
|
|
938
|
-
|
|
948
|
+
_ref6 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
|
|
939
949
|
if (cover) {
|
|
940
950
|
this.otherParams = params;
|
|
941
951
|
} else {
|
|
@@ -1198,10 +1208,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1198
1208
|
// 通过资源列表和指定的资源 id,获取指定资源的时间切片
|
|
1199
1209
|
}, {
|
|
1200
1210
|
key: "getResourceTimeSlot",
|
|
1201
|
-
value: function getResourceTimeSlot(
|
|
1202
|
-
var product =
|
|
1203
|
-
resources =
|
|
1204
|
-
currentResourceId =
|
|
1211
|
+
value: function getResourceTimeSlot(_ref7) {
|
|
1212
|
+
var product = _ref7.product,
|
|
1213
|
+
resources = _ref7.resources,
|
|
1214
|
+
currentResourceId = _ref7.currentResourceId;
|
|
1205
1215
|
var dateRange = this.store.date.getDateRange();
|
|
1206
1216
|
var timeSlots = getTimeSlicesByResource({
|
|
1207
1217
|
resource: resources.find(function (n) {
|
|
@@ -1217,10 +1227,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1217
1227
|
// 自动分派可用的资源-单种资源类型——此方法目前未使用,未经验证
|
|
1218
1228
|
}, {
|
|
1219
1229
|
key: "autoSelectResource",
|
|
1220
|
-
value: function autoSelectResource(
|
|
1221
|
-
var resourceProductData =
|
|
1222
|
-
resources =
|
|
1223
|
-
timeSlots =
|
|
1230
|
+
value: function autoSelectResource(_ref8) {
|
|
1231
|
+
var resourceProductData = _ref8.resourceProductData,
|
|
1232
|
+
resources = _ref8.resources,
|
|
1233
|
+
timeSlots = _ref8.timeSlots;
|
|
1224
1234
|
var dateRange = this.store.date.getDateRange();
|
|
1225
1235
|
if (timeSlots) {
|
|
1226
1236
|
// 如果 start_time 存在,则直接根据 start_time 算出商品总共需要的时长,然后根据时长去匹配资源
|
|
@@ -1289,12 +1299,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1289
1299
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
1290
1300
|
}, {
|
|
1291
1301
|
key: "autoSelectAccountResources",
|
|
1292
|
-
value: function autoSelectAccountResources(
|
|
1293
|
-
var holder_id =
|
|
1294
|
-
resources_code =
|
|
1295
|
-
timeSlots =
|
|
1296
|
-
countMap =
|
|
1297
|
-
capacity =
|
|
1302
|
+
value: function autoSelectAccountResources(_ref9) {
|
|
1303
|
+
var holder_id = _ref9.holder_id,
|
|
1304
|
+
resources_code = _ref9.resources_code,
|
|
1305
|
+
timeSlots = _ref9.timeSlots,
|
|
1306
|
+
countMap = _ref9.countMap,
|
|
1307
|
+
capacity = _ref9.capacity;
|
|
1298
1308
|
var dateRange = this.store.date.getDateRange();
|
|
1299
1309
|
var cartItems = this.store.cart.getItems();
|
|
1300
1310
|
// 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
|
|
@@ -1421,9 +1431,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1421
1431
|
});
|
|
1422
1432
|
if (timeSlots) {
|
|
1423
1433
|
if (index !== 0 && recordTimeSlots) {
|
|
1424
|
-
var _item$_productOrigin$, _item$_productOrigin3,
|
|
1425
|
-
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, (
|
|
1426
|
-
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, (
|
|
1434
|
+
var _item$_productOrigin$, _item$_productOrigin3, _ref10, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref11, _item$_productOrigin6;
|
|
1435
|
+
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, (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
1436
|
+
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, (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : 'minutes');
|
|
1427
1437
|
recordTimeSlots = {
|
|
1428
1438
|
start_time: start_at.format('HH:mm'),
|
|
1429
1439
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1580,9 +1590,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1580
1590
|
accountItems.forEach(function (item, index) {
|
|
1581
1591
|
var newResources = cloneDeep(item._origin.resources);
|
|
1582
1592
|
newResources.forEach(function (resource) {
|
|
1583
|
-
var _item$_productOrigin$4, _item$_productOrigin10,
|
|
1593
|
+
var _item$_productOrigin$4, _item$_productOrigin10, _ref12, _item$_productOrigin11;
|
|
1584
1594
|
resource.startTime = currentStartTime;
|
|
1585
|
-
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, (
|
|
1595
|
+
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, (_ref12 = (_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 && _ref12 !== void 0 ? _ref12 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
1586
1596
|
delete resource.times;
|
|
1587
1597
|
});
|
|
1588
1598
|
_this9.store.cart.updateItem({
|
|
@@ -1664,11 +1674,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1664
1674
|
}
|
|
1665
1675
|
}, {
|
|
1666
1676
|
key: "getTimeslotBySchedule",
|
|
1667
|
-
value: function getTimeslotBySchedule(
|
|
1677
|
+
value: function getTimeslotBySchedule(_ref13) {
|
|
1668
1678
|
var _this$store$currentPr2;
|
|
1669
|
-
var date =
|
|
1670
|
-
scheduleIds =
|
|
1671
|
-
resources =
|
|
1679
|
+
var date = _ref13.date,
|
|
1680
|
+
scheduleIds = _ref13.scheduleIds,
|
|
1681
|
+
resources = _ref13.resources;
|
|
1672
1682
|
var targetProduct = this.store.currentProduct;
|
|
1673
1683
|
var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
|
|
1674
1684
|
var targetSchedules = [];
|
|
@@ -1732,15 +1742,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1732
1742
|
}
|
|
1733
1743
|
}, {
|
|
1734
1744
|
key: "addProductToCart",
|
|
1735
|
-
value: function addProductToCart(
|
|
1736
|
-
var
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1745
|
+
value: function addProductToCart(_ref14) {
|
|
1746
|
+
var _this10 = this;
|
|
1747
|
+
var product = _ref14.product,
|
|
1748
|
+
date = _ref14.date,
|
|
1749
|
+
account = _ref14.account;
|
|
1750
|
+
var _ref15 = product || {},
|
|
1751
|
+
bundle = _ref15.bundle,
|
|
1752
|
+
options = _ref15.options,
|
|
1753
|
+
origin = _ref15.origin,
|
|
1754
|
+
product_variant_id = _ref15.product_variant_id;
|
|
1744
1755
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1745
1756
|
product_variant_id: product_variant_id
|
|
1746
1757
|
});
|
|
@@ -1751,6 +1762,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1751
1762
|
bundle: bundle,
|
|
1752
1763
|
options: options
|
|
1753
1764
|
});
|
|
1765
|
+
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
1766
|
+
if (date) {
|
|
1767
|
+
var cartItems = this.store.cart.getItems();
|
|
1768
|
+
var cartItemsByDate = cartItems.filter(function (n) {
|
|
1769
|
+
return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
|
|
1770
|
+
});
|
|
1771
|
+
if (cartItemsByDate.length) {
|
|
1772
|
+
cartItemsByDate.forEach(function (n) {
|
|
1773
|
+
_this10.store.cart.removeItem(n._id);
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1754
1777
|
}
|
|
1755
1778
|
}, {
|
|
1756
1779
|
key: "setOtherData",
|
|
@@ -44,7 +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
|
|
47
|
+
loadProductByScheduleDate({ date, product_ids, }: {
|
|
48
|
+
date: string;
|
|
49
|
+
product_ids?: number[];
|
|
50
|
+
}): Promise<any>;
|
|
48
51
|
loadAllSchedule(): Promise<void>;
|
|
49
52
|
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
50
53
|
startDate: string;
|
|
@@ -103,7 +103,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
|
|
106
|
-
this.loadAllSchedule();
|
|
107
106
|
}
|
|
108
107
|
// 初始化step
|
|
109
108
|
initStep(stepList) {
|
|
@@ -173,17 +172,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
173
172
|
ids: product_ids,
|
|
174
173
|
collection,
|
|
175
174
|
front_end_cache_id: this.cacheId,
|
|
176
|
-
schedule_ids
|
|
175
|
+
client_schedule_ids: schedule_ids
|
|
177
176
|
},
|
|
178
177
|
{ useCache: true }
|
|
179
178
|
);
|
|
180
179
|
this.store.products.addProduct(productsData.data.list);
|
|
181
180
|
return productsData.data.list;
|
|
182
181
|
}
|
|
183
|
-
async loadProductByScheduleDate(
|
|
182
|
+
async loadProductByScheduleDate({
|
|
183
|
+
date,
|
|
184
|
+
product_ids
|
|
185
|
+
}) {
|
|
184
186
|
const scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
187
|
+
this.setDateRange([{ date, status: "available", week: "", weekNum: 0 }]);
|
|
185
188
|
const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
|
|
186
|
-
return await this.loadProducts({ schedule_ids: scheduleIds });
|
|
189
|
+
return await this.loadProducts({ schedule_ids: scheduleIds, product_ids });
|
|
187
190
|
}
|
|
188
191
|
// 加载当前店铺下所有 schedule
|
|
189
192
|
async loadAllSchedule() {
|
|
@@ -321,7 +324,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
321
324
|
}
|
|
322
325
|
// 获取商品/服务的可用日期
|
|
323
326
|
async getAvailableDate(params = {}) {
|
|
324
|
-
var _a, _b, _c, _d;
|
|
325
327
|
let { products, startDate, endDate, type } = params;
|
|
326
328
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)()) && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)()) || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)()))) {
|
|
327
329
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
@@ -343,8 +345,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
343
345
|
}
|
|
344
346
|
];
|
|
345
347
|
}
|
|
346
|
-
const
|
|
347
|
-
const
|
|
348
|
+
const dateRange = await this.getDateRange();
|
|
349
|
+
const tempStartDate = startDate || (dateRange == null ? void 0 : dateRange[0].date);
|
|
350
|
+
const tempEndDate = endDate || (dateRange == null ? void 0 : dateRange[0].date);
|
|
348
351
|
if (!tempProducts.length) {
|
|
349
352
|
return [];
|
|
350
353
|
}
|
|
@@ -1118,6 +1121,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1118
1121
|
bundle,
|
|
1119
1122
|
options
|
|
1120
1123
|
});
|
|
1124
|
+
if (date) {
|
|
1125
|
+
const cartItems = this.store.cart.getItems();
|
|
1126
|
+
const cartItemsByDate = cartItems.filter((n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day"));
|
|
1127
|
+
if (cartItemsByDate.length) {
|
|
1128
|
+
cartItemsByDate.forEach((n) => {
|
|
1129
|
+
this.store.cart.removeItem(n._id);
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1121
1133
|
}
|
|
1122
1134
|
setOtherData(key, value) {
|
|
1123
1135
|
this.otherData[key] = value;
|