@pisell/pisellos 0.0.49 → 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,25 +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
|
-
});
|
|
247
|
-
|
|
248
|
-
_context3.next = 5;
|
|
252
|
+
});
|
|
253
|
+
_context3.next = 6;
|
|
249
254
|
return this.loadProducts({
|
|
250
|
-
schedule_ids: scheduleIds
|
|
255
|
+
schedule_ids: scheduleIds,
|
|
256
|
+
product_ids: product_ids
|
|
251
257
|
});
|
|
252
|
-
case 5:
|
|
253
|
-
return _context3.abrupt("return", _context3.sent);
|
|
254
258
|
case 6:
|
|
259
|
+
return _context3.abrupt("return", _context3.sent);
|
|
260
|
+
case 7:
|
|
255
261
|
case "end":
|
|
256
262
|
return _context3.stop();
|
|
257
263
|
}
|
|
@@ -290,13 +296,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
290
296
|
}, {
|
|
291
297
|
key: "loadScheduleAvailableDate",
|
|
292
298
|
value: function () {
|
|
293
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(
|
|
299
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
294
300
|
var _res$data$date_list;
|
|
295
301
|
var startDate, endDate, custom_page_id, dates, res;
|
|
296
302
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
297
303
|
while (1) switch (_context5.prev = _context5.next) {
|
|
298
304
|
case 0:
|
|
299
|
-
startDate =
|
|
305
|
+
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
|
|
300
306
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
301
307
|
if (dayjs(startDate).isBefore(dayjs())) {
|
|
302
308
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
@@ -354,13 +360,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
354
360
|
key: "storeProduct",
|
|
355
361
|
value: function () {
|
|
356
362
|
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
|
|
357
|
-
var activeAccount,
|
|
363
|
+
var activeAccount, _ref4, bundle, options, origin, product_variant_id, product, addCartItem;
|
|
358
364
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
359
365
|
while (1) switch (_context6.prev = _context6.next) {
|
|
360
366
|
case 0:
|
|
361
367
|
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
362
368
|
activeAccount = this.getActiveAccount();
|
|
363
|
-
|
|
369
|
+
_ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id;
|
|
364
370
|
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
365
371
|
product_variant_id: product_variant_id
|
|
366
372
|
});
|
|
@@ -608,18 +614,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
608
614
|
key: "getAvailableDate",
|
|
609
615
|
value: function () {
|
|
610
616
|
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
611
|
-
var _this3 = this
|
|
612
|
-
_this$otherParams3,
|
|
613
|
-
_this$otherParams4;
|
|
617
|
+
var _this3 = this;
|
|
614
618
|
var params,
|
|
615
619
|
products,
|
|
616
620
|
startDate,
|
|
617
621
|
endDate,
|
|
618
622
|
type,
|
|
619
623
|
tempProducts,
|
|
624
|
+
dateRange,
|
|
620
625
|
tempStartDate,
|
|
621
626
|
tempEndDate,
|
|
622
|
-
|
|
627
|
+
_ref5,
|
|
623
628
|
resourceIds,
|
|
624
629
|
rules,
|
|
625
630
|
resourcesMap,
|
|
@@ -651,18 +656,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
651
656
|
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
652
657
|
})];
|
|
653
658
|
}
|
|
654
|
-
|
|
655
|
-
|
|
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);
|
|
656
665
|
if (tempProducts.length) {
|
|
657
|
-
_context13.next =
|
|
666
|
+
_context13.next = 13;
|
|
658
667
|
break;
|
|
659
668
|
}
|
|
660
669
|
return _context13.abrupt("return", []);
|
|
661
|
-
case
|
|
670
|
+
case 13:
|
|
662
671
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
663
|
-
|
|
672
|
+
_ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
|
|
664
673
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
665
|
-
_context13.next =
|
|
674
|
+
_context13.next = 17;
|
|
666
675
|
return this.store.date.getResourceDates({
|
|
667
676
|
url: params.url,
|
|
668
677
|
query: {
|
|
@@ -673,10 +682,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
673
682
|
rules: rules,
|
|
674
683
|
type: type
|
|
675
684
|
});
|
|
676
|
-
case
|
|
685
|
+
case 17:
|
|
677
686
|
res = _context13.sent;
|
|
678
687
|
return _context13.abrupt("return", res);
|
|
679
|
-
case
|
|
688
|
+
case 19:
|
|
680
689
|
case "end":
|
|
681
690
|
return _context13.stop();
|
|
682
691
|
}
|
|
@@ -929,14 +938,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
929
938
|
key: "setOtherParams",
|
|
930
939
|
value: function () {
|
|
931
940
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
932
|
-
var
|
|
933
|
-
|
|
941
|
+
var _ref6,
|
|
942
|
+
_ref6$cover,
|
|
934
943
|
cover,
|
|
935
944
|
_args23 = arguments;
|
|
936
945
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
937
946
|
while (1) switch (_context23.prev = _context23.next) {
|
|
938
947
|
case 0:
|
|
939
|
-
|
|
948
|
+
_ref6 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
|
|
940
949
|
if (cover) {
|
|
941
950
|
this.otherParams = params;
|
|
942
951
|
} else {
|
|
@@ -1199,10 +1208,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1199
1208
|
// 通过资源列表和指定的资源 id,获取指定资源的时间切片
|
|
1200
1209
|
}, {
|
|
1201
1210
|
key: "getResourceTimeSlot",
|
|
1202
|
-
value: function getResourceTimeSlot(
|
|
1203
|
-
var product =
|
|
1204
|
-
resources =
|
|
1205
|
-
currentResourceId =
|
|
1211
|
+
value: function getResourceTimeSlot(_ref7) {
|
|
1212
|
+
var product = _ref7.product,
|
|
1213
|
+
resources = _ref7.resources,
|
|
1214
|
+
currentResourceId = _ref7.currentResourceId;
|
|
1206
1215
|
var dateRange = this.store.date.getDateRange();
|
|
1207
1216
|
var timeSlots = getTimeSlicesByResource({
|
|
1208
1217
|
resource: resources.find(function (n) {
|
|
@@ -1218,10 +1227,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1218
1227
|
// 自动分派可用的资源-单种资源类型——此方法目前未使用,未经验证
|
|
1219
1228
|
}, {
|
|
1220
1229
|
key: "autoSelectResource",
|
|
1221
|
-
value: function autoSelectResource(
|
|
1222
|
-
var resourceProductData =
|
|
1223
|
-
resources =
|
|
1224
|
-
timeSlots =
|
|
1230
|
+
value: function autoSelectResource(_ref8) {
|
|
1231
|
+
var resourceProductData = _ref8.resourceProductData,
|
|
1232
|
+
resources = _ref8.resources,
|
|
1233
|
+
timeSlots = _ref8.timeSlots;
|
|
1225
1234
|
var dateRange = this.store.date.getDateRange();
|
|
1226
1235
|
if (timeSlots) {
|
|
1227
1236
|
// 如果 start_time 存在,则直接根据 start_time 算出商品总共需要的时长,然后根据时长去匹配资源
|
|
@@ -1290,12 +1299,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1290
1299
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
1291
1300
|
}, {
|
|
1292
1301
|
key: "autoSelectAccountResources",
|
|
1293
|
-
value: function autoSelectAccountResources(
|
|
1294
|
-
var holder_id =
|
|
1295
|
-
resources_code =
|
|
1296
|
-
timeSlots =
|
|
1297
|
-
countMap =
|
|
1298
|
-
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;
|
|
1299
1308
|
var dateRange = this.store.date.getDateRange();
|
|
1300
1309
|
var cartItems = this.store.cart.getItems();
|
|
1301
1310
|
// 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
|
|
@@ -1422,9 +1431,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1422
1431
|
});
|
|
1423
1432
|
if (timeSlots) {
|
|
1424
1433
|
if (index !== 0 && recordTimeSlots) {
|
|
1425
|
-
var _item$_productOrigin$, _item$_productOrigin3,
|
|
1426
|
-
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, (
|
|
1427
|
-
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');
|
|
1428
1437
|
recordTimeSlots = {
|
|
1429
1438
|
start_time: start_at.format('HH:mm'),
|
|
1430
1439
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1581,9 +1590,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1581
1590
|
accountItems.forEach(function (item, index) {
|
|
1582
1591
|
var newResources = cloneDeep(item._origin.resources);
|
|
1583
1592
|
newResources.forEach(function (resource) {
|
|
1584
|
-
var _item$_productOrigin$4, _item$_productOrigin10,
|
|
1593
|
+
var _item$_productOrigin$4, _item$_productOrigin10, _ref12, _item$_productOrigin11;
|
|
1585
1594
|
resource.startTime = currentStartTime;
|
|
1586
|
-
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');
|
|
1587
1596
|
delete resource.times;
|
|
1588
1597
|
});
|
|
1589
1598
|
_this9.store.cart.updateItem({
|
|
@@ -1665,11 +1674,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1665
1674
|
}
|
|
1666
1675
|
}, {
|
|
1667
1676
|
key: "getTimeslotBySchedule",
|
|
1668
|
-
value: function getTimeslotBySchedule(
|
|
1677
|
+
value: function getTimeslotBySchedule(_ref13) {
|
|
1669
1678
|
var _this$store$currentPr2;
|
|
1670
|
-
var date =
|
|
1671
|
-
scheduleIds =
|
|
1672
|
-
resources =
|
|
1679
|
+
var date = _ref13.date,
|
|
1680
|
+
scheduleIds = _ref13.scheduleIds,
|
|
1681
|
+
resources = _ref13.resources;
|
|
1673
1682
|
var targetProduct = this.store.currentProduct;
|
|
1674
1683
|
var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
|
|
1675
1684
|
var targetSchedules = [];
|
|
@@ -1733,15 +1742,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1733
1742
|
}
|
|
1734
1743
|
}, {
|
|
1735
1744
|
key: "addProductToCart",
|
|
1736
|
-
value: function addProductToCart(
|
|
1737
|
-
var
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
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;
|
|
1745
1755
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1746
1756
|
product_variant_id: product_variant_id
|
|
1747
1757
|
});
|
|
@@ -1752,6 +1762,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1752
1762
|
bundle: bundle,
|
|
1753
1763
|
options: options
|
|
1754
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
|
+
}
|
|
1755
1777
|
}
|
|
1756
1778
|
}, {
|
|
1757
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,18 +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
|
-
this.
|
|
187
|
-
return await this.loadProducts({ schedule_ids: scheduleIds });
|
|
189
|
+
return await this.loadProducts({ schedule_ids: scheduleIds, product_ids });
|
|
188
190
|
}
|
|
189
191
|
// 加载当前店铺下所有 schedule
|
|
190
192
|
async loadAllSchedule() {
|
|
@@ -322,7 +324,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
322
324
|
}
|
|
323
325
|
// 获取商品/服务的可用日期
|
|
324
326
|
async getAvailableDate(params = {}) {
|
|
325
|
-
var _a, _b, _c, _d;
|
|
326
327
|
let { products, startDate, endDate, type } = params;
|
|
327
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)()))) {
|
|
328
329
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
@@ -344,8 +345,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
344
345
|
}
|
|
345
346
|
];
|
|
346
347
|
}
|
|
347
|
-
const
|
|
348
|
-
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);
|
|
349
351
|
if (!tempProducts.length) {
|
|
350
352
|
return [];
|
|
351
353
|
}
|
|
@@ -1119,6 +1121,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1119
1121
|
bundle,
|
|
1120
1122
|
options
|
|
1121
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
|
+
}
|
|
1122
1133
|
}
|
|
1123
1134
|
setOtherData(key, value) {
|
|
1124
1135
|
this.otherData[key] = value;
|