@pisell/private-materials 3.4.8 → 3.4.9
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +3 -3
- package/build/lowcode/view.js +3 -3
- package/es/components/booking/components/customSelect/index.js +1 -0
- package/es/components/booking/hooks/useClearCart.js +11 -8
- package/es/components/booking/hooks/useQuotation.js +1 -1
- package/es/components/booking/info/client/index.js +3 -2
- package/es/components/booking/info/dateRange/index.d.ts +1 -0
- package/es/components/booking/info/hooks/useInfoHolder.js +16 -9
- package/es/components/booking/info/service/Lists.js +36 -26
- package/es/components/booking/info/service2/utils.js +20 -21
- package/es/components/booking/info2/index.js +1 -0
- package/es/components/booking/info2/service/addService/utils.js +6 -3
- package/es/components/booking/info2/service/addTimeModal/index.js +3 -0
- package/es/components/booking/info2/service/editService/Resources/index.js +5 -0
- package/es/components/booking/info2/service/editService/index.js +266 -170
- package/es/components/booking/info2/service/index.js +19 -15
- package/es/components/booking/materiels/duration/index.js +9 -2
- package/es/components/shoppingCart/components/Cart/Product.js +48 -41
- package/es/components/shoppingCart/components/Cart/index.js +21 -18
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +249 -158
- package/es/components/ticketBooking/components/timeBar/index.js +78 -71
- package/es/components/ticketBooking/utils/index.d.ts +2 -0
- package/es/components/ticketBooking/utils/index.js +18 -1
- package/lib/components/booking/components/customSelect/index.js +1 -0
- package/lib/components/booking/hooks/useClearCart.js +16 -13
- package/lib/components/booking/hooks/useQuotation.js +1 -1
- package/lib/components/booking/info/client/index.js +5 -4
- package/lib/components/booking/info/dateRange/index.d.ts +1 -0
- package/lib/components/booking/info/hooks/useInfoHolder.js +10 -9
- package/lib/components/booking/info/service/Lists.js +35 -23
- package/lib/components/booking/info/service2/utils.js +17 -17
- package/lib/components/booking/info2/service/addService/utils.js +4 -2
- package/lib/components/booking/info2/service/addTimeModal/index.js +3 -0
- package/lib/components/booking/info2/service/editService/Resources/index.js +2 -0
- package/lib/components/booking/info2/service/editService/index.js +139 -74
- package/lib/components/booking/info2/service/index.js +13 -9
- package/lib/components/booking/materiels/duration/index.js +7 -2
- package/lib/components/shoppingCart/components/Cart/Product.js +31 -21
- package/lib/components/shoppingCart/components/Cart/index.js +18 -15
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +196 -127
- package/lib/components/ticketBooking/components/timeBar/index.js +95 -88
- package/lib/components/ticketBooking/utils/index.d.ts +2 -0
- package/lib/components/ticketBooking/utils/index.js +22 -0
- package/package.json +4 -4
|
@@ -20,6 +20,9 @@ var Duration = function Duration(props) {
|
|
|
20
20
|
startDate = props.startDate,
|
|
21
21
|
timeObj = props.timeObj,
|
|
22
22
|
resetProps = _objectWithoutProperties(props, _excluded);
|
|
23
|
+
var startDateStr = useMemo(function () {
|
|
24
|
+
return dayjs(startDate).format('YYYY-MM-DD HH:mm:ss');
|
|
25
|
+
}, [startDate]);
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* @title: 时间切片
|
|
@@ -57,7 +60,7 @@ var Duration = function Duration(props) {
|
|
|
57
60
|
});
|
|
58
61
|
}
|
|
59
62
|
return durationSlicesBasedOnTime;
|
|
60
|
-
}, [timeObj, slice, locale, duration,
|
|
63
|
+
}, [timeObj.durationSlicesBasedOnTime, slice, locale, duration, startDateStr, usableTime === null || usableTime === void 0 ? void 0 : usableTime.end_at]);
|
|
61
64
|
useEffect(function () {
|
|
62
65
|
timeObjChange === null || timeObjChange === void 0 || timeObjChange(times);
|
|
63
66
|
}, [times]);
|
|
@@ -72,6 +75,10 @@ var Duration = function Duration(props) {
|
|
|
72
75
|
}, d[label]);
|
|
73
76
|
});
|
|
74
77
|
}, []);
|
|
75
|
-
|
|
78
|
+
var options = useMemo(function () {
|
|
79
|
+
console.log('render form options');
|
|
80
|
+
return renderOptions(times);
|
|
81
|
+
}, [times]);
|
|
82
|
+
return /*#__PURE__*/React.createElement(Select, _extends({}, selectProps, resetProps), options);
|
|
76
83
|
};
|
|
77
84
|
export default Duration;
|
|
@@ -5,6 +5,7 @@ import { ProductCard } from '@pisell/materials';
|
|
|
5
5
|
import useClearCart from "../../hooks/useClearCart";
|
|
6
6
|
import { useContext } from "../../hooks/useContext";
|
|
7
7
|
import useAddService from "../../hooks/useAddService";
|
|
8
|
+
import { useMemoizedFn, useTrackedEffect } from "ahooks";
|
|
8
9
|
var Product = function Product(props) {
|
|
9
10
|
var id = props.id,
|
|
10
11
|
lists = props.lists,
|
|
@@ -35,10 +36,10 @@ var Product = function Product(props) {
|
|
|
35
36
|
* @Author: WangHan
|
|
36
37
|
* @Date: 2024-11-28 22:02
|
|
37
38
|
*/
|
|
38
|
-
var handleChange = function
|
|
39
|
+
var handleChange = useMemoizedFn(function (item, type, other) {
|
|
39
40
|
if (disabledEdit && !(other !== null && other !== void 0 && other.disabled)) return;
|
|
40
41
|
onChange(item, type, other);
|
|
41
|
-
};
|
|
42
|
+
});
|
|
42
43
|
var productParams = useMemo(function () {
|
|
43
44
|
return {
|
|
44
45
|
isShowNote: isShowNote,
|
|
@@ -52,44 +53,50 @@ var Product = function Product(props) {
|
|
|
52
53
|
isShowEditProduct: isShowEditProduct
|
|
53
54
|
};
|
|
54
55
|
}, [isShowNote, isShowPackageNote, disabledEdit, isShowChangeResource, isShowDelete, isShowHolder, isShowAddHolderButton, isShowChangeHolder, isShowEditProduct]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, clearCart, lists
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
56
|
+
useTrackedEffect(function (changes) {
|
|
57
|
+
console.log('Index of changed dependencies: ', changes);
|
|
58
|
+
}, [clearCart, lists, productParams, hideAddBtn, isAdd, platform]);
|
|
59
|
+
return useMemo(function () {
|
|
60
|
+
console.log('render cart');
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: "pisell-lowcode__shopping-cart-content"
|
|
63
|
+
}, clearCart, lists === null || lists === void 0 ? void 0 : lists.map(function (item) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(ProductCard, _extends({
|
|
65
|
+
key: item._id,
|
|
66
|
+
dataSource: item,
|
|
67
|
+
onAction: function onAction(e) {
|
|
68
|
+
return _onAction === null || _onAction === void 0 ? void 0 : _onAction(e);
|
|
69
|
+
},
|
|
70
|
+
onDelete: function onDelete(e) {
|
|
71
|
+
return handleChange(e, 'delete', item);
|
|
72
|
+
},
|
|
73
|
+
onNote: function onNote(e) {
|
|
74
|
+
return handleChange(e, 'note', {
|
|
75
|
+
note: e.note
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
onLike: function onLike(e) {
|
|
79
|
+
return handleChange(e, 'like', {
|
|
80
|
+
like_status: e.like_status
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
onEditProduct: function onEditProduct(e) {
|
|
84
|
+
return handleChange === null || handleChange === void 0 ? void 0 : handleChange(e, 'edit_product');
|
|
85
|
+
},
|
|
86
|
+
onCard: function onCard(e) {
|
|
87
|
+
return handleChange === null || handleChange === void 0 ? void 0 : handleChange(e, 'view');
|
|
88
|
+
},
|
|
89
|
+
onChangeResource: function onChangeResource(e) {
|
|
90
|
+
return handleChange(item, 'change_resource', e);
|
|
91
|
+
},
|
|
92
|
+
onChangeHolder: function onChangeHolder(e) {
|
|
93
|
+
return handleChange(item, 'change_holder', e);
|
|
94
|
+
},
|
|
95
|
+
onAddHolder: function onAddHolder(e) {
|
|
96
|
+
return handleChange(item, 'add_holder', e);
|
|
97
|
+
}
|
|
98
|
+
}, productParams));
|
|
99
|
+
}), !hideAddBtn && platform !== 'h5' && isAdd ? useAddService(id, 'more') : null);
|
|
100
|
+
}, [clearCart, lists, productParams, hideAddBtn, isAdd, platform]);
|
|
94
101
|
};
|
|
95
102
|
export default Product;
|
|
@@ -51,23 +51,26 @@ var Cart = function Cart() {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
}, [carts, platform]);
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
return useMemo(function () {
|
|
55
|
+
console.log('render cart 22222');
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: classNames('pisell-lowcode__shopping-cart')
|
|
58
|
+
}, isProductList ? /*#__PURE__*/React.createElement(Product, {
|
|
59
|
+
id: undefined,
|
|
60
|
+
lists: state === null || state === void 0 ? void 0 : state.products
|
|
61
|
+
}) : /*#__PURE__*/React.createElement(Collapse, _extends({
|
|
62
|
+
items: cartsMap,
|
|
63
|
+
showHeader: true,
|
|
64
|
+
panelBackground: "#ffffff",
|
|
65
|
+
collapsible: platform !== 'shop' ? 'disabled' : '-',
|
|
66
|
+
accordion: platform === 'shop',
|
|
67
|
+
onChange: function onChange(key) {
|
|
68
|
+
updateState({
|
|
69
|
+
activeKey: key
|
|
70
|
+
});
|
|
71
|
+
onActiveKey(key);
|
|
72
|
+
}
|
|
73
|
+
}, collapseParams)));
|
|
74
|
+
}, [isProductList, cartsMap, platform, collapseParams, state === null || state === void 0 ? void 0 : state.products]);
|
|
72
75
|
};
|
|
73
76
|
export default Cart;
|
|
@@ -29,11 +29,11 @@ import { getProductDetail } from "../../../booking/info/service/serve";
|
|
|
29
29
|
import { useService } from "../../../booking/info/service/serviceManager";
|
|
30
30
|
import ProductSelect from "../../../productSelect";
|
|
31
31
|
import "./index.less";
|
|
32
|
-
import { addService, addServiceScroll, genServiceKey, getIsShowNumber } from "../../utils";
|
|
32
|
+
import { addService, addServiceScroll, createSimpleCacheItem, genServiceKey, getIsShowNumber, isSameProduct } from "../../utils";
|
|
33
33
|
import NotAvailable from "../notAvailable";
|
|
34
34
|
import dayjs from 'dayjs';
|
|
35
35
|
var AddSerivce = function AddSerivce(props) {
|
|
36
|
-
var _context$appHelper, _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _state$bookingConfig2, _state$client2, _state$service3
|
|
36
|
+
var _context$appHelper, _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _state$bookingConfig2, _state$client2, _state$service3;
|
|
37
37
|
var onEdit = props.onEdit,
|
|
38
38
|
state = props.state,
|
|
39
39
|
dispatch = props.dispatch,
|
|
@@ -63,6 +63,21 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
63
63
|
setCurrentProduct = _useState4[1];
|
|
64
64
|
var stateRef = useRef(state);
|
|
65
65
|
stateRef.current = state;
|
|
66
|
+
|
|
67
|
+
// 组件卸载时清理所有定时器
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
return function () {
|
|
70
|
+
Object.values(debounceTimersRef.current).forEach(function (timer) {
|
|
71
|
+
if (timer) clearTimeout(timer);
|
|
72
|
+
});
|
|
73
|
+
debounceTimersRef.current = {};
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
// 防抖相关的 refs
|
|
78
|
+
var pendingCacheValuesRef = useRef({});
|
|
79
|
+
var clickCountRef = useRef({});
|
|
80
|
+
var debounceTimersRef = useRef({});
|
|
66
81
|
var menuList = useMemo(function () {
|
|
67
82
|
var _state$bookingConfig;
|
|
68
83
|
return (state === null || state === void 0 || (_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.config) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.menu_list_tab) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.menu_list) || [];
|
|
@@ -257,6 +272,35 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
257
272
|
return _ref2.apply(this, arguments);
|
|
258
273
|
};
|
|
259
274
|
}();
|
|
275
|
+
var executeCacheValues = useMemoizedFn(function (productId, originalCacheValues, item, originalCallback) {
|
|
276
|
+
var clickCount = clickCountRef.current[productId] || 1;
|
|
277
|
+
|
|
278
|
+
// 更新 quantity 为累积的点击次数
|
|
279
|
+
var finalCacheValues = _objectSpread(_objectSpread({}, originalCacheValues), {}, {
|
|
280
|
+
quantity: clickCount
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// 清理当前商品的缓存数据
|
|
284
|
+
delete pendingCacheValuesRef.current[productId];
|
|
285
|
+
delete clickCountRef.current[productId];
|
|
286
|
+
delete debounceTimersRef.current[productId];
|
|
287
|
+
|
|
288
|
+
// 执行原始的回调函数
|
|
289
|
+
originalCallback(finalCacheValues, '', item, true);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// 为每个商品单独创建防抖函数
|
|
293
|
+
var debouncedExecuteCacheValues = useMemoizedFn(function (productId, cacheValues, item, callback) {
|
|
294
|
+
// 清除该商品的旧定时器
|
|
295
|
+
if (debounceTimersRef.current[productId]) {
|
|
296
|
+
clearTimeout(debounceTimersRef.current[productId]);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 创建新的防抖定时器
|
|
300
|
+
debounceTimersRef.current[productId] = setTimeout(function () {
|
|
301
|
+
executeCacheValues(productId, cacheValues, item, callback);
|
|
302
|
+
}, 0);
|
|
303
|
+
});
|
|
260
304
|
var handleSelectProduct = useMemoizedFn(function (item) {
|
|
261
305
|
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
|
|
262
306
|
var isSession = isSessionProduct(item);
|
|
@@ -264,10 +308,211 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
264
308
|
var isEject = getIsEject(item, type);
|
|
265
309
|
var isOnlySession = getIsOnlySession(item);
|
|
266
310
|
var lock = false;
|
|
311
|
+
// 对于不需要打开弹窗的商品, 直接模拟数据, 不走弹窗
|
|
312
|
+
var cacheValues = null;
|
|
267
313
|
if (isEject) {
|
|
268
314
|
setCurrentProduct(item);
|
|
269
315
|
} else {
|
|
270
316
|
setCurrentProduct(null);
|
|
317
|
+
if (!isSession && isNormalProductByDurationSchedule(item)) {
|
|
318
|
+
cacheValues = {
|
|
319
|
+
bundle: [],
|
|
320
|
+
key: item.id,
|
|
321
|
+
option: [],
|
|
322
|
+
product_id: item.id,
|
|
323
|
+
product_variant_id: 0,
|
|
324
|
+
quantity: 1,
|
|
325
|
+
rowKey: item.id,
|
|
326
|
+
session: null,
|
|
327
|
+
unique: '08974625397',
|
|
328
|
+
_originalItem: item // 保存原始商品信息
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
var callback = /*#__PURE__*/function () {
|
|
333
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e, extension_type, detail, notShowToast) {
|
|
334
|
+
var data, _detail, other, cacheItem, _total, _isEdit, _state$service$cacheI, _addService, _list, quantity, _Toast$success, _context$appHelper$ut4, _context$appHelper$ut5, val, sendData;
|
|
335
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
336
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
337
|
+
case 0:
|
|
338
|
+
setCurrentProduct(null);
|
|
339
|
+
// 防止选择商品弹窗多次触发callback
|
|
340
|
+
if (!lock) {
|
|
341
|
+
_context3.next = 3;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
return _context3.abrupt("return");
|
|
345
|
+
case 3:
|
|
346
|
+
lock = true;
|
|
347
|
+
|
|
348
|
+
// 2秒后解除
|
|
349
|
+
setTimeout(function () {
|
|
350
|
+
lock = false;
|
|
351
|
+
}, 2000);
|
|
352
|
+
if (isBooking4) {
|
|
353
|
+
_context3.next = 11;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
_context3.next = 8;
|
|
357
|
+
return createBookingData({
|
|
358
|
+
product: _objectSpread(_objectSpread({}, detail || item), {}, {
|
|
359
|
+
_params: e
|
|
360
|
+
})
|
|
361
|
+
});
|
|
362
|
+
case 8:
|
|
363
|
+
data = _context3.sent;
|
|
364
|
+
// 创建预约
|
|
365
|
+
createBooking({
|
|
366
|
+
booking: data
|
|
367
|
+
});
|
|
368
|
+
return _context3.abrupt("return");
|
|
369
|
+
case 11:
|
|
370
|
+
// info2 addService 逻辑
|
|
371
|
+
_detail = detail || item;
|
|
372
|
+
other = JSON.parse(JSON.stringify(e));
|
|
373
|
+
other.session = e.session;
|
|
374
|
+
cacheItem = _objectSpread(_objectSpread({}, _detail), {}, {
|
|
375
|
+
product_id: item.id,
|
|
376
|
+
_id: getUniqueId(),
|
|
377
|
+
_key: e.key,
|
|
378
|
+
_extend: {
|
|
379
|
+
start_date: state.date.value,
|
|
380
|
+
quantity: (e === null || e === void 0 ? void 0 : e.quantity) || 1,
|
|
381
|
+
price: _detail.price,
|
|
382
|
+
product_name: item.title,
|
|
383
|
+
other: other
|
|
384
|
+
},
|
|
385
|
+
new: 1
|
|
386
|
+
});
|
|
387
|
+
_total = getProductTotalPrice(cacheItem); // 用于折扣 可修改
|
|
388
|
+
cacheItem._extend.total = _total;
|
|
389
|
+
// 用于储存原价
|
|
390
|
+
cacheItem._extend.origin_total = _total;
|
|
391
|
+
_isEdit = !!state.service.cacheItem;
|
|
392
|
+
if (_isEdit) {
|
|
393
|
+
cacheItem._id = (_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._id;
|
|
394
|
+
cacheItem.new = 0;
|
|
395
|
+
}
|
|
396
|
+
// 渲染到当前位置模式时,默认无资源 时间默认取顶部设置的时间
|
|
397
|
+
if (renderMode === 'current') {
|
|
398
|
+
// cacheItem._extend.resource = 0;
|
|
399
|
+
cacheItem.currentDefaultTime = state.date.value.format('HH:mm');
|
|
400
|
+
}
|
|
401
|
+
cacheItem = getProductExtend({
|
|
402
|
+
cacheItem: cacheItem,
|
|
403
|
+
state: state,
|
|
404
|
+
isDisabledTime: true
|
|
405
|
+
});
|
|
406
|
+
if (state.renderType === 'eventBooking') {
|
|
407
|
+
cacheItem.autoClose = false;
|
|
408
|
+
}
|
|
409
|
+
if (cacheItem.autoClose) {
|
|
410
|
+
cacheItem.autoClose = false;
|
|
411
|
+
cacheItem._serviceKey = genServiceKey(cacheItem);
|
|
412
|
+
_addService = addService(_toConsumableArray(state.service.value), cacheItem, state), _list = _addService.list, quantity = _addService.quantity;
|
|
413
|
+
if (!notShowToast) {
|
|
414
|
+
Toast === null || Toast === void 0 || (_Toast$success = Toast.success) === null || _Toast$success === void 0 || _Toast$success.call(Toast, /*#__PURE__*/React.createElement("div", {
|
|
415
|
+
className: "add-toast-wrap"
|
|
416
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
417
|
+
className: "add-toast-title"
|
|
418
|
+
}, cacheItem.title), /*#__PURE__*/React.createElement("div", {
|
|
419
|
+
className: "add-toast-quantity"
|
|
420
|
+
}, locales.getText('pisell2.ticket-booking.in-cart')(quantity || 1))));
|
|
421
|
+
}
|
|
422
|
+
addServiceScroll(e.rowKey, cacheItem);
|
|
423
|
+
try {
|
|
424
|
+
if (((_context$appHelper$ut4 = context.appHelper.utils.store) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut4.getState) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.call(_context$appHelper$ut4)) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.global) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.globalConfig) === null || _context$appHelper$ut5 === void 0 ? void 0 : _context$appHelper$ut5.id) === 2155) {
|
|
425
|
+
val = _list === null || _list === void 0 ? void 0 : _list.map(function (s) {
|
|
426
|
+
return {
|
|
427
|
+
product_id: s === null || s === void 0 ? void 0 : s.product_id,
|
|
428
|
+
detailId: s === null || s === void 0 ? void 0 : s.id,
|
|
429
|
+
detailProductId: s === null || s === void 0 ? void 0 : s.product_id,
|
|
430
|
+
product_name: s === null || s === void 0 ? void 0 : s.title,
|
|
431
|
+
price: s === null || s === void 0 ? void 0 : s.price,
|
|
432
|
+
_id: s === null || s === void 0 ? void 0 : s._id,
|
|
433
|
+
_key: s === null || s === void 0 ? void 0 : s._key,
|
|
434
|
+
_serviceKey: s === null || s === void 0 ? void 0 : s._serviceKey
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
sendData = {
|
|
438
|
+
product_id: item === null || item === void 0 ? void 0 : item.id,
|
|
439
|
+
detailId: _detail === null || _detail === void 0 ? void 0 : _detail.id,
|
|
440
|
+
detailProductId: _detail === null || _detail === void 0 ? void 0 : _detail.product_id,
|
|
441
|
+
product_name: item === null || item === void 0 ? void 0 : item.title,
|
|
442
|
+
price: _detail === null || _detail === void 0 ? void 0 : _detail.price,
|
|
443
|
+
serviceVal: val
|
|
444
|
+
};
|
|
445
|
+
sendWarningLog({
|
|
446
|
+
title: 'addService',
|
|
447
|
+
content: [{
|
|
448
|
+
key: '添加数据',
|
|
449
|
+
value: JSON.stringify(sendData)
|
|
450
|
+
}, {
|
|
451
|
+
key: '日期',
|
|
452
|
+
value: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
453
|
+
}]
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
} catch (error) {}
|
|
457
|
+
dispatch({
|
|
458
|
+
type: 'setService',
|
|
459
|
+
payload: {
|
|
460
|
+
addModal: false,
|
|
461
|
+
value: _list,
|
|
462
|
+
edit: true,
|
|
463
|
+
changeService: false
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
} else {
|
|
467
|
+
dispatch({
|
|
468
|
+
type: 'setService',
|
|
469
|
+
payload: {
|
|
470
|
+
editModal: true,
|
|
471
|
+
cacheItem: cacheItem,
|
|
472
|
+
addModal: !cacheItem.autoClose,
|
|
473
|
+
changeService: false
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
onEdit === null || onEdit === void 0 || onEdit(cacheItem);
|
|
477
|
+
}
|
|
478
|
+
case 24:
|
|
479
|
+
case "end":
|
|
480
|
+
return _context3.stop();
|
|
481
|
+
}
|
|
482
|
+
}, _callee3);
|
|
483
|
+
}));
|
|
484
|
+
return function callback(_x3, _x4, _x5, _x6) {
|
|
485
|
+
return _ref3.apply(this, arguments);
|
|
486
|
+
};
|
|
487
|
+
}();
|
|
488
|
+
|
|
489
|
+
// 如果不需要打开弹窗, 直接添加数据
|
|
490
|
+
if (cacheValues) {
|
|
491
|
+
var _state$service$value, _detail$_extend, _Toast$success2;
|
|
492
|
+
var productId = item.id.toString();
|
|
493
|
+
|
|
494
|
+
// 如果已经有pending的同商品,增加点击次数
|
|
495
|
+
if (pendingCacheValuesRef.current[productId]) {
|
|
496
|
+
clickCountRef.current[productId] = (clickCountRef.current[productId] || 1) + 1;
|
|
497
|
+
} else {
|
|
498
|
+
// 第一次点击,初始化数据
|
|
499
|
+
pendingCacheValuesRef.current[productId] = cacheValues;
|
|
500
|
+
clickCountRef.current[productId] = 1;
|
|
501
|
+
}
|
|
502
|
+
var cacheItem = createSimpleCacheItem(item, cacheValues, state);
|
|
503
|
+
var detail = (_state$service$value = state.service.value) === null || _state$service$value === void 0 ? void 0 : _state$service$value.find(function (val) {
|
|
504
|
+
return isSameProduct(val, cacheItem);
|
|
505
|
+
});
|
|
506
|
+
var originalQuantity = (detail === null || detail === void 0 || (_detail$_extend = detail._extend) === null || _detail$_extend === void 0 ? void 0 : _detail$_extend.quantity) || 0;
|
|
507
|
+
Toast === null || Toast === void 0 || (_Toast$success2 = Toast.success) === null || _Toast$success2 === void 0 || _Toast$success2.call(Toast, /*#__PURE__*/React.createElement("div", {
|
|
508
|
+
className: "add-toast-wrap"
|
|
509
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
510
|
+
className: "add-toast-title"
|
|
511
|
+
}, item.title), /*#__PURE__*/React.createElement("div", {
|
|
512
|
+
className: "add-toast-quantity"
|
|
513
|
+
}, locales.getText('pisell2.ticket-booking.in-cart')((clickCountRef.current[productId] || 1) + originalQuantity))));
|
|
514
|
+
debouncedExecuteCacheValues(productId, cacheValues, item, callback);
|
|
515
|
+
return;
|
|
271
516
|
}
|
|
272
517
|
state.action({
|
|
273
518
|
type: 'pisell1.handleOpenProductModal',
|
|
@@ -289,161 +534,7 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
289
534
|
onCancel: function onCancel() {
|
|
290
535
|
setCurrentProduct(null);
|
|
291
536
|
},
|
|
292
|
-
callback:
|
|
293
|
-
var _callback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e, extension_type, detail) {
|
|
294
|
-
var data, _detail, other, cacheItem, _total, _isEdit, _state$service$cacheI, _Toast$success, _addService, _list, quantity, _context$appHelper$ut4, _context$appHelper$ut5, val, sendData;
|
|
295
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
296
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
297
|
-
case 0:
|
|
298
|
-
setCurrentProduct(null);
|
|
299
|
-
// 防止选择商品弹窗多次触发callback
|
|
300
|
-
if (!lock) {
|
|
301
|
-
_context3.next = 3;
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
return _context3.abrupt("return");
|
|
305
|
-
case 3:
|
|
306
|
-
lock = true;
|
|
307
|
-
|
|
308
|
-
// 2秒后解除
|
|
309
|
-
setTimeout(function () {
|
|
310
|
-
lock = false;
|
|
311
|
-
}, 2000);
|
|
312
|
-
if (isBooking4) {
|
|
313
|
-
_context3.next = 11;
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
_context3.next = 8;
|
|
317
|
-
return createBookingData({
|
|
318
|
-
product: _objectSpread(_objectSpread({}, detail || item), {}, {
|
|
319
|
-
_params: e
|
|
320
|
-
})
|
|
321
|
-
});
|
|
322
|
-
case 8:
|
|
323
|
-
data = _context3.sent;
|
|
324
|
-
// 创建预约
|
|
325
|
-
createBooking({
|
|
326
|
-
booking: data
|
|
327
|
-
});
|
|
328
|
-
return _context3.abrupt("return");
|
|
329
|
-
case 11:
|
|
330
|
-
// info2 addService 逻辑
|
|
331
|
-
_detail = detail || item;
|
|
332
|
-
other = JSON.parse(JSON.stringify(e));
|
|
333
|
-
other.session = e.session;
|
|
334
|
-
cacheItem = _objectSpread(_objectSpread({}, _detail), {}, {
|
|
335
|
-
product_id: item.id,
|
|
336
|
-
_id: getUniqueId(),
|
|
337
|
-
_key: e.key,
|
|
338
|
-
_extend: {
|
|
339
|
-
start_date: state.date.value,
|
|
340
|
-
quantity: (e === null || e === void 0 ? void 0 : e.quantity) || 1,
|
|
341
|
-
price: _detail.price,
|
|
342
|
-
product_name: item.title,
|
|
343
|
-
other: other
|
|
344
|
-
},
|
|
345
|
-
new: 1
|
|
346
|
-
});
|
|
347
|
-
_total = getProductTotalPrice(cacheItem); // 用于折扣 可修改
|
|
348
|
-
cacheItem._extend.total = _total;
|
|
349
|
-
// 用于储存原价
|
|
350
|
-
cacheItem._extend.origin_total = _total;
|
|
351
|
-
_isEdit = !!state.service.cacheItem;
|
|
352
|
-
if (_isEdit) {
|
|
353
|
-
cacheItem._id = (_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._id;
|
|
354
|
-
cacheItem.new = 0;
|
|
355
|
-
}
|
|
356
|
-
// 渲染到当前位置模式时,默认无资源 时间默认取顶部设置的时间
|
|
357
|
-
if (renderMode === 'current') {
|
|
358
|
-
// cacheItem._extend.resource = 0;
|
|
359
|
-
cacheItem.currentDefaultTime = state.date.value.format('HH:mm');
|
|
360
|
-
}
|
|
361
|
-
cacheItem = getProductExtend({
|
|
362
|
-
cacheItem: cacheItem,
|
|
363
|
-
state: state,
|
|
364
|
-
isDisabledTime: true
|
|
365
|
-
});
|
|
366
|
-
if (state.renderType === 'eventBooking') {
|
|
367
|
-
cacheItem.autoClose = false;
|
|
368
|
-
}
|
|
369
|
-
if (cacheItem.autoClose) {
|
|
370
|
-
cacheItem.autoClose = false;
|
|
371
|
-
cacheItem._serviceKey = genServiceKey(cacheItem);
|
|
372
|
-
_addService = addService(_toConsumableArray(state.service.value), cacheItem, state), _list = _addService.list, quantity = _addService.quantity;
|
|
373
|
-
Toast === null || Toast === void 0 || (_Toast$success = Toast.success) === null || _Toast$success === void 0 || _Toast$success.call(Toast, /*#__PURE__*/React.createElement("div", {
|
|
374
|
-
className: "add-toast-wrap"
|
|
375
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
376
|
-
className: "add-toast-title"
|
|
377
|
-
}, cacheItem.title), /*#__PURE__*/React.createElement("div", {
|
|
378
|
-
className: "add-toast-quantity"
|
|
379
|
-
}, locales.getText('pisell2.ticket-booking.in-cart')(quantity || 1))));
|
|
380
|
-
addServiceScroll(e.rowKey, cacheItem);
|
|
381
|
-
try {
|
|
382
|
-
if (((_context$appHelper$ut4 = context.appHelper.utils.store) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut4.getState) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.call(_context$appHelper$ut4)) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.global) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.globalConfig) === null || _context$appHelper$ut5 === void 0 ? void 0 : _context$appHelper$ut5.id) === 2155) {
|
|
383
|
-
val = _list === null || _list === void 0 ? void 0 : _list.map(function (s) {
|
|
384
|
-
return {
|
|
385
|
-
product_id: s === null || s === void 0 ? void 0 : s.product_id,
|
|
386
|
-
detailId: s === null || s === void 0 ? void 0 : s.id,
|
|
387
|
-
detailProductId: s === null || s === void 0 ? void 0 : s.product_id,
|
|
388
|
-
product_name: s === null || s === void 0 ? void 0 : s.title,
|
|
389
|
-
price: s === null || s === void 0 ? void 0 : s.price,
|
|
390
|
-
_id: s === null || s === void 0 ? void 0 : s._id,
|
|
391
|
-
_key: s === null || s === void 0 ? void 0 : s._key,
|
|
392
|
-
_serviceKey: s === null || s === void 0 ? void 0 : s._serviceKey
|
|
393
|
-
};
|
|
394
|
-
});
|
|
395
|
-
sendData = {
|
|
396
|
-
product_id: item === null || item === void 0 ? void 0 : item.id,
|
|
397
|
-
detailId: _detail === null || _detail === void 0 ? void 0 : _detail.id,
|
|
398
|
-
detailProductId: _detail === null || _detail === void 0 ? void 0 : _detail.product_id,
|
|
399
|
-
product_name: item === null || item === void 0 ? void 0 : item.title,
|
|
400
|
-
price: _detail === null || _detail === void 0 ? void 0 : _detail.price,
|
|
401
|
-
serviceVal: val
|
|
402
|
-
};
|
|
403
|
-
sendWarningLog({
|
|
404
|
-
title: 'addService',
|
|
405
|
-
content: [{
|
|
406
|
-
key: '添加数据',
|
|
407
|
-
value: JSON.stringify(sendData)
|
|
408
|
-
}, {
|
|
409
|
-
key: '日期',
|
|
410
|
-
value: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
411
|
-
}]
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
} catch (error) {}
|
|
415
|
-
dispatch({
|
|
416
|
-
type: 'setService',
|
|
417
|
-
payload: {
|
|
418
|
-
addModal: false,
|
|
419
|
-
value: _list,
|
|
420
|
-
edit: true,
|
|
421
|
-
changeService: false
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
} else {
|
|
425
|
-
dispatch({
|
|
426
|
-
type: 'setService',
|
|
427
|
-
payload: {
|
|
428
|
-
editModal: true,
|
|
429
|
-
cacheItem: cacheItem,
|
|
430
|
-
addModal: !cacheItem.autoClose,
|
|
431
|
-
changeService: false
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
onEdit === null || onEdit === void 0 || onEdit(cacheItem);
|
|
435
|
-
}
|
|
436
|
-
case 24:
|
|
437
|
-
case "end":
|
|
438
|
-
return _context3.stop();
|
|
439
|
-
}
|
|
440
|
-
}, _callee3);
|
|
441
|
-
}));
|
|
442
|
-
function callback(_x3, _x4, _x5) {
|
|
443
|
-
return _callback.apply(this, arguments);
|
|
444
|
-
}
|
|
445
|
-
return callback;
|
|
446
|
-
}()
|
|
537
|
+
callback: callback
|
|
447
538
|
});
|
|
448
539
|
});
|
|
449
540
|
var renderList = useMemo(function () {
|
|
@@ -501,6 +592,6 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
501
592
|
}));
|
|
502
593
|
}
|
|
503
594
|
return null;
|
|
504
|
-
}, [
|
|
595
|
+
}, [state.service.addModal, locales, renderList, state.amountSymbol, state.renderType, state === null || state === void 0 ? void 0 : state.activeCartId, holderId(state), loading, currentProduct, isBooking4]);
|
|
505
596
|
};
|
|
506
597
|
export default AddSerivce;
|