@pisell/private-materials 6.8.89 → 6.8.90

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.
@@ -695,40 +695,38 @@ var Footer = function Footer(props) {
695
695
  console.log('Payment result:', paymentResult);
696
696
  setIsPaymentModalOpen(false);
697
697
  if ((paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.status) === 'success' || (paymentResult === null || paymentResult === void 0 || (_paymentResult$respon = paymentResult.response) === null || _paymentResult$respon === void 0 || (_paymentResult$respon = _paymentResult$respon.data) === null || _paymentResult$respon === void 0 ? void 0 : _paymentResult$respon.payment_status) === 'paid') {
698
- var _window3;
699
698
  console.log('Payment completed successfully');
700
- logger.addLog({
701
- title: 'Footer: setPaymentCallback success 调用清空购物车',
702
- metadata: {
703
- paymentResult: paymentResult
704
- }
705
- });
706
- (_window3 = window) === null || _window3 === void 0 || (_window3 = _window3.shopApi) === null || _window3 === void 0 || (_window3 = _window3.bookingTicket) === null || _window3 === void 0 || _window3.clearAllCart();
699
+ // logger.addLog({
700
+ // title: 'Footer: setPaymentCallback success 调用清空购物车',
701
+ // metadata: {
702
+ // paymentResult
703
+ // },
704
+ // });
705
+ // (window as any)?.shopApi?.bookingTicket?.clearAllCart();
707
706
  // 支付成功后关闭弹窗
708
707
  setPaymentModalData(null);
709
708
  setPaymentCallback(null);
710
709
  } else if ((paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.status) === 'cancelled') {
711
710
  console.log('Payment cancelled');
712
711
  if (res !== null && res !== void 0 && res.order_id) {
713
- var _window4;
714
- (_window4 = window) === null || _window4 === void 0 || (_window4 = _window4.shopApi) === null || _window4 === void 0 || (_window4 = _window4.booking) === null || _window4 === void 0 || _window4.voidBooking(res.order_id);
712
+ var _window3;
713
+ (_window3 = window) === null || _window3 === void 0 || (_window3 = _window3.shopApi) === null || _window3 === void 0 || (_window3 = _window3.booking) === null || _window3 === void 0 || _window3.voidBooking(res.order_id);
715
714
  }
716
715
  // 支付取消后关闭弹窗
717
716
  setPaymentModalData(null);
718
717
  setPaymentCallback(null);
719
718
  } else {
720
- var _window5;
721
719
  console.log('Payment status:', paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.status);
722
720
  // 其他状态也关闭弹窗
723
721
  setPaymentModalData(null);
724
722
  setPaymentCallback(null);
725
- logger.addLog({
726
- title: "Footer: setPaymentCallback ".concat(paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.status, " \u8C03\u7528\u6E05\u7A7A\u8D2D\u7269\u8F66"),
727
- metadata: {
728
- paymentResult: paymentResult
729
- }
730
- });
731
- (_window5 = window) === null || _window5 === void 0 || (_window5 = _window5.shopApi) === null || _window5 === void 0 || (_window5 = _window5.bookingTicket) === null || _window5 === void 0 || _window5.clearAllCart();
723
+ // logger.addLog({
724
+ // title: `Footer: setPaymentCallback ${paymentResult?.status} 调用清空购物车`,
725
+ // metadata: {
726
+ // paymentResult
727
+ // },
728
+ // });
729
+ // (window as any)?.shopApi?.bookingTicket?.clearAllCart();
732
730
  }
733
731
  };
734
732
  });
@@ -881,7 +879,7 @@ var Footer = function Footer(props) {
881
879
  var handleSave = /*#__PURE__*/function () {
882
880
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref6) {
883
881
  var _state$bookingConfig6, _state$service$value2, _state$client3;
884
- var type, _ref6$messageShow, messageShow, _ref6$noSubmit, noSubmit, isToastMode, isHasDayProducts, hasUnspecifiedHolderProduct, _setLoading, _getApis, createBooking, editBooking, editApi, createApi, saveOtherValue, _state$onSave, _store$getState, _window6, callbackData, values, checkout, subtotal_info, res, isNeedDeposit, api;
882
+ var type, _ref6$messageShow, messageShow, _ref6$noSubmit, noSubmit, isToastMode, isHasDayProducts, hasUnspecifiedHolderProduct, _setLoading, _getApis, createBooking, editBooking, editApi, createApi, saveOtherValue, _state$onSave, _store$getState, _window4, callbackData, values, checkout, subtotal_info, res, isNeedDeposit, api;
885
883
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
886
884
  while (1) switch (_context6.prev = _context6.next) {
887
885
  case 0:
@@ -1016,7 +1014,7 @@ var Footer = function Footer(props) {
1016
1014
  value: store === null || store === void 0 || (_store$getState = store.getState) === null || _store$getState === void 0 || (_store$getState = _store$getState.call(store)) === null || _store$getState === void 0 || (_store$getState = _store$getState.global) === null || _store$getState === void 0 || (_store$getState = _store$getState.globalConfig) === null || _store$getState === void 0 ? void 0 : _store$getState.id
1017
1015
  }, {
1018
1016
  key: 'shopApi',
1019
- value: JSON.stringify((_window6 = window) === null || _window6 === void 0 ? void 0 : _window6.shopApi, function (key, value) {
1017
+ value: JSON.stringify((_window4 = window) === null || _window4 === void 0 ? void 0 : _window4.shopApi, function (key, value) {
1020
1018
  if (typeof value === 'function') {
1021
1019
  return 'function';
1022
1020
  }
@@ -1815,7 +1813,7 @@ var Footer = function Footer(props) {
1815
1813
  clearAllScanListenersTaskQueue = _useScanManager2.clearAllScanListenersTaskQueue;
1816
1814
  // 清空所有内容并重置购物车
1817
1815
  var handleClearAllAndReset = function handleClearAllAndReset() {
1818
- var _window7;
1816
+ var _window5;
1819
1817
  logger.addLog({
1820
1818
  title: 'Footer: PaymentOnClose reset 清空所有内容并重置购物车',
1821
1819
  metadata: {}
@@ -1885,7 +1883,7 @@ var Footer = function Footer(props) {
1885
1883
  // }, 100);
1886
1884
  // }
1887
1885
  clearAllScanListenersTaskQueue();
1888
- (_window7 = window) === null || _window7 === void 0 || (_window7 = _window7.shopApi) === null || _window7 === void 0 || (_window7 = _window7.bookingTicket) === null || _window7 === void 0 || _window7.clearAllCart();
1886
+ (_window5 = window) === null || _window5 === void 0 || (_window5 = _window5.shopApi) === null || _window5 === void 0 || (_window5 = _window5.bookingTicket) === null || _window5 === void 0 || _window5.clearAllCart();
1889
1887
  };
1890
1888
 
1891
1889
  // 购物车进入编辑状态
@@ -1531,7 +1531,7 @@ var PaymentModal = function PaymentModal(_ref19) {
1531
1531
  // 重试处理函数(逻辑由用户自己实现)
1532
1532
  var handleRetry = /*#__PURE__*/function () {
1533
1533
  var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1534
- var checkoutModule, res;
1534
+ var checkoutModule, res, _res$response;
1535
1535
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1536
1536
  while (1) switch (_context15.prev = _context15.next) {
1537
1537
  case 0:
@@ -1551,13 +1551,20 @@ var PaymentModal = function PaymentModal(_ref19) {
1551
1551
  res = _context15.sent;
1552
1552
  console.log(res);
1553
1553
  if (!res.success) {
1554
- _context15.next = 9;
1554
+ _context15.next = 10;
1555
1555
  break;
1556
1556
  }
1557
1557
  setShowRetryModal(false);
1558
1558
  _context15.next = 9;
1559
1559
  return showSuccessToast === null || showSuccessToast === void 0 ? void 0 : showSuccessToast(res);
1560
1560
  case 9:
1561
+ // 如果是整单支付,则调用 onClose 让外面清空购物车
1562
+ if ((res === null || res === void 0 || (_res$response = res.response) === null || _res$response === void 0 || (_res$response = _res$response.data) === null || _res$response === void 0 ? void 0 : _res$response.payment_status) === 'paid') {
1563
+ onClose === null || onClose === void 0 || onClose(true);
1564
+ }
1565
+ // if (res.data.payment_status)
1566
+ // setShowRetryModal(false);
1567
+ case 10:
1561
1568
  case "end":
1562
1569
  return _context15.stop();
1563
1570
  }
@@ -158,9 +158,11 @@ var PaymentResultToast = /*#__PURE__*/memo(function (props) {
158
158
  }
159
159
  };
160
160
  document.addEventListener('mousedown', handleClickOutside);
161
+ document.addEventListener('pointerup', handleClickOutside);
161
162
  // 清理函数
162
163
  return function () {
163
164
  document.removeEventListener('mousedown', handleClickOutside);
165
+ document.removeEventListener('pointerup', handleClickOutside);
164
166
  };
165
167
  }, [clickOutsideToClose, visible, clearCountdown]);
166
168
 
@@ -46,8 +46,14 @@ var CardWrapper = function CardWrapper(props) {
46
46
  }, [style, paddingX, paddingY, borderWidth, borderColor, isBorderVisible, radius, background, marginX, marginY]);
47
47
  return /*#__PURE__*/React.createElement("div", {
48
48
  className: classNames("".concat(PREFIX, "__card-wrapper"), (skuStatusOverlayConfig === null || skuStatusOverlayConfig === void 0 ? void 0 : skuStatusOverlayConfig.isOpen) && "".concat(PREFIX, "__card-wrapper-overlay"), className),
49
- onClick: function onClick() {
50
- onCardClick === null || onCardClick === void 0 || onCardClick(dataSource);
49
+ onPointerUp: function onPointerUp() {
50
+ // 使用onClick 会有点击300ms延迟问题
51
+ // 使用onPointerUp的话 会触发到点击位置弹窗内 onClick 所以增加两次 requestAnimationFrame解决该问题
52
+ requestAnimationFrame(function () {
53
+ return requestAnimationFrame(function () {
54
+ return onCardClick === null || onCardClick === void 0 ? void 0 : onCardClick(dataSource);
55
+ });
56
+ });
51
57
  }
52
58
  }, /*#__PURE__*/React.createElement(CardPro, {
53
59
  isMedia: false,
@@ -120,7 +120,13 @@ export var ProductCard = /*#__PURE__*/memo(function (_ref) {
120
120
  selected: isSelected
121
121
  }),
122
122
  onPointerUp: function onPointerUp() {
123
- onSelect === null || onSelect === void 0 || onSelect(item);
123
+ // 使用onClick 会有点击300ms延迟问题
124
+ // 使用onPointerUp的话 会触发到点击位置弹窗内 onClick 所以增加两次 requestAnimationFrame解决该问题
125
+ requestAnimationFrame(function () {
126
+ return requestAnimationFrame(function () {
127
+ return onSelect === null || onSelect === void 0 ? void 0 : onSelect(item);
128
+ });
129
+ });
124
130
  },
125
131
  "data-index": index,
126
132
  "data-item-index": index
@@ -131,7 +137,13 @@ export var ProductCard = /*#__PURE__*/memo(function (_ref) {
131
137
  height: imgHeight || 'auto'
132
138
  },
133
139
  onPointerUp: function onPointerUp() {
134
- onSelectCover === null || onSelectCover === void 0 || onSelectCover(item);
140
+ // 使用onClick 会有点击300ms延迟问题
141
+ // 使用onPointerUp的话 会触发到点击位置弹窗内 onClick 所以增加两次 requestAnimationFrame解决该问题
142
+ requestAnimationFrame(function () {
143
+ return requestAnimationFrame(function () {
144
+ return onSelectCover === null || onSelectCover === void 0 ? void 0 : onSelectCover(item);
145
+ });
146
+ });
135
147
  }
136
148
  }, item.cover ? /*#__PURE__*/React.createElement("img", {
137
149
  loading: "lazy",
@@ -148,7 +160,13 @@ export var ProductCard = /*#__PURE__*/memo(function (_ref) {
148
160
  }, getTextCover(item.title))) : null, /*#__PURE__*/React.createElement("div", {
149
161
  className: "card-right",
150
162
  onPointerUp: function onPointerUp() {
151
- onSelectInfo === null || onSelectInfo === void 0 || onSelectInfo(item);
163
+ // 使用onClick 会有点击300ms延迟问题
164
+ // 使用onPointerUp的话 会触发到点击位置弹窗内 onClick 所以增加两次 requestAnimationFrame解决该问题
165
+ requestAnimationFrame(function () {
166
+ return requestAnimationFrame(function () {
167
+ return onSelectInfo === null || onSelectInfo === void 0 ? void 0 : onSelectInfo(item);
168
+ });
169
+ });
152
170
  }
153
171
  }, !!isTitle ? /*#__PURE__*/React.createElement("div", {
154
172
  className: "title"
@@ -501,24 +501,17 @@ var Footer = (props) => {
501
501
  setIsPaymentModalOpen(true);
502
502
  setCheckoutLoading(false);
503
503
  setPaymentCallback(() => (paymentResult) => {
504
- var _a3, _b3, _c3, _d2, _e2, _f2, _g2, _h2;
504
+ var _a3, _b3, _c3, _d2;
505
505
  console.log("Payment result:", paymentResult);
506
506
  setIsPaymentModalOpen(false);
507
507
  if ((paymentResult == null ? void 0 : paymentResult.status) === "success" || ((_b3 = (_a3 = paymentResult == null ? void 0 : paymentResult.response) == null ? void 0 : _a3.data) == null ? void 0 : _b3.payment_status) === "paid") {
508
508
  console.log("Payment completed successfully");
509
- logger.addLog({
510
- title: "Footer: setPaymentCallback success 调用清空购物车",
511
- metadata: {
512
- paymentResult
513
- }
514
- });
515
- (_d2 = (_c3 = window == null ? void 0 : window.shopApi) == null ? void 0 : _c3.bookingTicket) == null ? void 0 : _d2.clearAllCart();
516
509
  setPaymentModalData(null);
517
510
  setPaymentCallback(null);
518
511
  } else if ((paymentResult == null ? void 0 : paymentResult.status) === "cancelled") {
519
512
  console.log("Payment cancelled");
520
513
  if (res == null ? void 0 : res.order_id) {
521
- (_f2 = (_e2 = window == null ? void 0 : window.shopApi) == null ? void 0 : _e2.booking) == null ? void 0 : _f2.voidBooking(res.order_id);
514
+ (_d2 = (_c3 = window == null ? void 0 : window.shopApi) == null ? void 0 : _c3.booking) == null ? void 0 : _d2.voidBooking(res.order_id);
522
515
  }
523
516
  setPaymentModalData(null);
524
517
  setPaymentCallback(null);
@@ -526,13 +519,6 @@ var Footer = (props) => {
526
519
  console.log("Payment status:", paymentResult == null ? void 0 : paymentResult.status);
527
520
  setPaymentModalData(null);
528
521
  setPaymentCallback(null);
529
- logger.addLog({
530
- title: `Footer: setPaymentCallback ${paymentResult == null ? void 0 : paymentResult.status} 调用清空购物车`,
531
- metadata: {
532
- paymentResult
533
- }
534
- });
535
- (_h2 = (_g2 = window == null ? void 0 : window.shopApi) == null ? void 0 : _g2.bookingTicket) == null ? void 0 : _h2.clearAllCart();
536
522
  }
537
523
  });
538
524
  } else {
@@ -1156,12 +1156,16 @@ var PaymentModal = ({
1156
1156
  const Toast = (0, import_materials.useToast)();
1157
1157
  const { nativePrint } = (0, import_printer.default)();
1158
1158
  const handleRetry = async () => {
1159
+ var _a2, _b2;
1159
1160
  const checkoutModule = pisellos == null ? void 0 : pisellos.getModule("checkout");
1160
1161
  const res = await (checkoutModule == null ? void 0 : checkoutModule.manualSyncOrderAsync());
1161
1162
  console.log(res);
1162
1163
  if (res.success) {
1163
1164
  setShowRetryModal(false);
1164
1165
  await (showSuccessToast == null ? void 0 : showSuccessToast(res));
1166
+ if (((_b2 = (_a2 = res == null ? void 0 : res.response) == null ? void 0 : _a2.data) == null ? void 0 : _b2.payment_status) === "paid") {
1167
+ onClose == null ? void 0 : onClose(true);
1168
+ }
1165
1169
  }
1166
1170
  };
1167
1171
  (0, import_react.useEffect)(() => {
@@ -153,8 +153,10 @@ var PaymentResultToast = (0, import_react.memo)((props) => {
153
153
  }
154
154
  };
155
155
  document.addEventListener("mousedown", handleClickOutside);
156
+ document.addEventListener("pointerup", handleClickOutside);
156
157
  return () => {
157
158
  document.removeEventListener("mousedown", handleClickOutside);
159
+ document.removeEventListener("pointerup", handleClickOutside);
158
160
  };
159
161
  }, [clickOutsideToClose, visible, clearCountdown]);
160
162
  const handleClose = (0, import_react.useCallback)(() => {
@@ -94,8 +94,8 @@ var CardWrapper = (props) => {
94
94
  (skuStatusOverlayConfig == null ? void 0 : skuStatusOverlayConfig.isOpen) && `${import_status.PREFIX}__card-wrapper-overlay`,
95
95
  className
96
96
  ),
97
- onClick: () => {
98
- onCardClick == null ? void 0 : onCardClick(dataSource);
97
+ onPointerUp: () => {
98
+ requestAnimationFrame(() => requestAnimationFrame(() => onCardClick == null ? void 0 : onCardClick(dataSource)));
99
99
  }
100
100
  },
101
101
  /* @__PURE__ */ import_react.default.createElement(
@@ -132,7 +132,7 @@ var ProductCard = (0, import_react.memo)(
132
132
  selected: isSelected
133
133
  }),
134
134
  onPointerUp: () => {
135
- onSelect == null ? void 0 : onSelect(item);
135
+ requestAnimationFrame(() => requestAnimationFrame(() => onSelect == null ? void 0 : onSelect(item)));
136
136
  },
137
137
  "data-index": index,
138
138
  "data-item-index": index
@@ -146,7 +146,7 @@ var ProductCard = (0, import_react.memo)(
146
146
  height: imgHeight || "auto"
147
147
  },
148
148
  onPointerUp: () => {
149
- onSelectCover == null ? void 0 : onSelectCover(item);
149
+ requestAnimationFrame(() => requestAnimationFrame(() => onSelectCover == null ? void 0 : onSelectCover(item)));
150
150
  }
151
151
  },
152
152
  item.cover ? /* @__PURE__ */ import_react.default.createElement(
@@ -164,7 +164,7 @@ var ProductCard = (0, import_react.memo)(
164
164
  {
165
165
  className: "card-right",
166
166
  onPointerUp: () => {
167
- onSelectInfo == null ? void 0 : onSelectInfo(item);
167
+ requestAnimationFrame(() => requestAnimationFrame(() => onSelectInfo == null ? void 0 : onSelectInfo(item)));
168
168
  }
169
169
  },
170
170
  !!isTitle ? /* @__PURE__ */ import_react.default.createElement("div", { className: "title" }, item.title) : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.8.89",
3
+ "version": "6.8.90",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { SkuDetailModalProps, SkuDetailModalRef } from './types';
3
- import './index.less';
4
- declare const _default: React.ForwardRefExoticComponent<SkuDetailModalProps & React.RefAttributes<SkuDetailModalRef>>;
5
- export default _default;
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { SkuDetailModalProps, SkuDetailModalRef } from './types';
3
- import './index.less';
4
- declare const _default: React.ForwardRefExoticComponent<SkuDetailModalProps & React.RefAttributes<SkuDetailModalRef>>;
5
- export default _default;