@pisell/private-materials 6.12.169 → 6.12.170
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.css +1 -1
- package/build/lowcode/render/default/view.js +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +10 -10
- package/es/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/es/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/es/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/es/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/es/components/HDLKiosk/index.js +10 -2
- package/es/components/HDLKiosk/index.less +7 -2
- package/es/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/es/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/es/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/es/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +0 -1
- package/es/components/bigSale/components/TimeBar/index.js +0 -1
- package/es/components/bigSale/dialog.js +0 -1
- package/es/components/bigSale/hooks/useBigSaleContext.js +0 -1
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +0 -1
- package/es/components/bigSale/index.js +0 -1
- package/es/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/createHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/es/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +187 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +160 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +124 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +2 -2
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +41 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +122 -0
- package/es/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/es/components/bigSale/templates/HDLKiosk/index.js +40 -146
- package/es/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +15 -59
- package/es/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/es/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/es/components/bigSale/templates/Kiosk/index.js +0 -1
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +0 -1
- package/es/index.js +0 -2
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/saleDetail/Base.js +0 -1
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +0 -1
- package/es/plus/saleDetail/components/DetailActions/index.js +0 -1
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +0 -1
- package/es/plus/saleDetail/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/index.js +0 -1
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +1 -2
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/lib/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/lib/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/lib/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/lib/components/HDLKiosk/index.js +10 -2
- package/lib/components/HDLKiosk/index.less +7 -2
- package/lib/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/lib/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/lib/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/createHost.js +9 -9
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +189 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +162 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +126 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +42 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/lib/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +124 -0
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/lib/components/bigSale/templates/HDLKiosk/index.js +41 -147
- package/lib/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +14 -59
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/lib/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/package.json +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -710
- package/es/plus/pisellReservation/index.js +0 -17
- package/es/plus/salesSdk/index.js +0 -52
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -712
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
+
const require_usePickSaleDetailContext = require("../../../hooks/usePickSaleDetailContext.js");
|
|
4
|
+
const require_useOrderNoteModal = require("../../../../../plus/saleDetail/hooks/useOrderNoteModal.js");
|
|
5
|
+
const require_adapters = require("../../../../../plus/saleDetail/components/PromotionWalletPanels/adapters.js");
|
|
6
|
+
const require_useSaleWalletAssets = require("../../../../../plus/saleDetail/components/PromotionWalletPanels/useSaleWalletAssets.js");
|
|
7
|
+
const require_Base = require("../../../../../plus/saleDetail/Base.js");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
react = require_runtime.__toESM(react);
|
|
10
|
+
//#region src/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.tsx
|
|
11
|
+
/**
|
|
12
|
+
* 文件角色:封装 HDLKiosk 复用 SaleDetail 时的购物车展示、备注和优惠券配置。
|
|
13
|
+
* 边界:只负责 Cart Overlay 的 BigSale UI 接入,不创建 Host 或执行 Workflow。
|
|
14
|
+
*/
|
|
15
|
+
const HIDDEN_MODULES = [
|
|
16
|
+
"overview",
|
|
17
|
+
"customer",
|
|
18
|
+
"contact",
|
|
19
|
+
"cartActions",
|
|
20
|
+
"orderActions",
|
|
21
|
+
"promotionAlert"
|
|
22
|
+
];
|
|
23
|
+
const CART_ITEM_PRESENTATION = {
|
|
24
|
+
density: "comfortable",
|
|
25
|
+
optionColumns: 2,
|
|
26
|
+
mediaFit: "cover",
|
|
27
|
+
contentAlign: "center",
|
|
28
|
+
tokens: {
|
|
29
|
+
background: "#ffffff",
|
|
30
|
+
borderColor: "#e4e7ec",
|
|
31
|
+
borderRadius: "18px",
|
|
32
|
+
minHeight: "164px",
|
|
33
|
+
mediaWidth: "228px",
|
|
34
|
+
actionRailWidth: "174px",
|
|
35
|
+
contentPadding: "20px 22px",
|
|
36
|
+
actionRailPadding: "18px 20px",
|
|
37
|
+
accentColor: "#b20d12",
|
|
38
|
+
titleColor: "#101828",
|
|
39
|
+
titleFontSize: "32px",
|
|
40
|
+
titleFontWeight: 800,
|
|
41
|
+
priceColor: "#b20d12",
|
|
42
|
+
priceFontSize: "30px",
|
|
43
|
+
optionBackground: "#f5f6f8",
|
|
44
|
+
optionLabelColor: "#667085",
|
|
45
|
+
optionValueColor: "#101828",
|
|
46
|
+
optionGap: "6px",
|
|
47
|
+
shadow: "0 12px 28px rgba(16, 24, 40, 0.08)"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function useBigSaleHDLKioskCart({ context, onOrderComplete, primaryWeightedProductId, saleDetailModuleConfig, variant }) {
|
|
51
|
+
var _note, _ref, _context$sales$tempOr, _context$sales$bookin, _context$sales$bookin2;
|
|
52
|
+
const walletAssetsCleanupCoordinatorRef = (0, react.useRef)(require_useSaleWalletAssets.createSaleWalletAssetsCleanupCoordinator());
|
|
53
|
+
const saleDetailContext = require_usePickSaleDetailContext.usePickSaleDetailContext(context, onOrderComplete);
|
|
54
|
+
const { openOrderNoteModal, orderNoteModal } = require_useOrderNoteModal.useOrderNoteModal({
|
|
55
|
+
context: saleDetailContext,
|
|
56
|
+
modalClassName: "pisell-kiosk-modal pisell-kiosk-note-modal"
|
|
57
|
+
});
|
|
58
|
+
const hasOrderNote = Boolean(String((_note = (_ref = (_context$sales$tempOr = context.sales.tempOrder) !== null && _context$sales$tempOr !== void 0 ? _context$sales$tempOr : (_context$sales$bookin = context.sales.bookingTicket) === null || _context$sales$bookin === void 0 || (_context$sales$bookin2 = _context$sales$bookin.getTempOrder) === null || _context$sales$bookin2 === void 0 ? void 0 : _context$sales$bookin2.call(_context$sales$bookin)) === null || _ref === void 0 ? void 0 : _ref.note) !== null && _note !== void 0 ? _note : "").trim());
|
|
59
|
+
const selectedPromotionCount = (0, react.useMemo)(() => require_adapters.buildVoucherViews(context.cart.discountList || []).filter((voucher) => voucher.selected).length, [context.cart.discountList]);
|
|
60
|
+
const cartOverlayActions = (0, react.useMemo)(() => ({
|
|
61
|
+
hasNote: hasOrderNote,
|
|
62
|
+
onAddNote: openOrderNoteModal,
|
|
63
|
+
promotionAppliedCount: selectedPromotionCount
|
|
64
|
+
}), [
|
|
65
|
+
hasOrderNote,
|
|
66
|
+
openOrderNoteModal,
|
|
67
|
+
selectedPromotionCount
|
|
68
|
+
]);
|
|
69
|
+
const moduleConfig = (0, react.useMemo)(() => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, saleDetailModuleConfig), {}, {
|
|
70
|
+
hidden: HIDDEN_MODULES,
|
|
71
|
+
cartItems: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, saleDetailModuleConfig === null || saleDetailModuleConfig === void 0 ? void 0 : saleDetailModuleConfig.cartItems), {}, {
|
|
72
|
+
rightActionsDisplay: "inline",
|
|
73
|
+
bookingQuantityMode: "hidden",
|
|
74
|
+
lineNoteEditingEnabled: true,
|
|
75
|
+
showInlineRemoveButton: false,
|
|
76
|
+
showQuantityBadge: false,
|
|
77
|
+
showRemoveButton: true,
|
|
78
|
+
clearSelectedQuantityOnDelete: true,
|
|
79
|
+
productLineItemType: "a12",
|
|
80
|
+
productLineItemPresentation: CART_ITEM_PRESENTATION
|
|
81
|
+
}),
|
|
82
|
+
amountDetails: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, saleDetailModuleConfig === null || saleDetailModuleConfig === void 0 ? void 0 : saleDetailModuleConfig.amountDetails), {}, { defaultExpanded: true }),
|
|
83
|
+
promotionWalletPanels: typeof (saleDetailModuleConfig === null || saleDetailModuleConfig === void 0 ? void 0 : saleDetailModuleConfig.promotionWalletPanels) === "object" ? saleDetailModuleConfig.promotionWalletPanels : void 0,
|
|
84
|
+
promotionWalletPanelsAppearance: "light",
|
|
85
|
+
promotionWalletPanelsBehavior: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, saleDetailModuleConfig === null || saleDetailModuleConfig === void 0 ? void 0 : saleDetailModuleConfig.promotionWalletPanelsBehavior), {}, {
|
|
86
|
+
walletAssetsCleanupCoordinator: walletAssetsCleanupCoordinatorRef.current,
|
|
87
|
+
enableManualPromotionCode: true,
|
|
88
|
+
enablePromotionBanner: true,
|
|
89
|
+
enableVoucherProductAdd: true,
|
|
90
|
+
enableWalletAssets: true,
|
|
91
|
+
preserveWalletAssetsWhileRefreshing: true
|
|
92
|
+
})
|
|
93
|
+
}), [saleDetailModuleConfig]);
|
|
94
|
+
const isPrimaryProductLine = (0, react.useCallback)((item) => {
|
|
95
|
+
var _ref2, _item$_extend$product, _item$_extend;
|
|
96
|
+
return String((_ref2 = (_item$_extend$product = item === null || item === void 0 || (_item$_extend = item._extend) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend.product) === null || _item$_extend === void 0 ? void 0 : _item$_extend.product_id) !== null && _item$_extend$product !== void 0 ? _item$_extend$product : item === null || item === void 0 ? void 0 : item.product_id) !== null && _ref2 !== void 0 ? _ref2 : "") === String(primaryWeightedProductId !== null && primaryWeightedProductId !== void 0 ? primaryWeightedProductId : "");
|
|
97
|
+
}, [primaryWeightedProductId]);
|
|
98
|
+
return {
|
|
99
|
+
cartOverlayActions,
|
|
100
|
+
orderNoteModal,
|
|
101
|
+
renderCartContent: (0, react.useCallback)(({ promotionsVisible, onEditPrimaryProduct }) => /* @__PURE__ */ react.default.createElement(require_Base.default, {
|
|
102
|
+
className: "hdl-kiosk-voucher-wallet",
|
|
103
|
+
context: saleDetailContext,
|
|
104
|
+
mobilePresentation: "inline",
|
|
105
|
+
moduleConfig: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, moduleConfig), {}, {
|
|
106
|
+
hidden: [...HIDDEN_MODULES, ...promotionsVisible ? [] : ["promotionWalletPanels"]],
|
|
107
|
+
cartItems: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, moduleConfig.cartItems), {}, {
|
|
108
|
+
isProductLineItemEditable: isPrimaryProductLine,
|
|
109
|
+
onProductLineItemEdit: onEditPrimaryProduct ? () => onEditPrimaryProduct() : void 0
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
renderType: "current",
|
|
113
|
+
template: "A",
|
|
114
|
+
variant
|
|
115
|
+
}), [
|
|
116
|
+
isPrimaryProductLine,
|
|
117
|
+
moduleConfig,
|
|
118
|
+
saleDetailContext,
|
|
119
|
+
variant
|
|
120
|
+
])
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
exports.useBigSaleHDLKioskCart = useBigSaleHDLKioskCart;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require("../../../../../_virtual/_rolldown/runtime.js");
|
|
2
2
|
let react = require("react");
|
|
3
|
-
//#region src/components/bigSale/templates/HDLKiosk/
|
|
3
|
+
//#region src/components/bigSale/templates/HDLKiosk/hooks/useHDLKioskEntryPreparationToast.ts
|
|
4
|
+
/** React 层入口准备提示;不属于 BigSale Host/Port 适配。 */
|
|
4
5
|
function useHDLKioskEntryPreparationToast({ active, message, preparing, toast }) {
|
|
5
6
|
(0, react.useEffect)(() => {
|
|
6
7
|
if (!active || !preparing || !(toast === null || toast === void 0 ? void 0 : toast.loading)) return;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
|
|
2
2
|
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
3
|
const require_useEngineContext = require("../../../../hooks/useEngineContext.js");
|
|
4
|
-
const require_usePickSaleDetailContext = require("../../hooks/usePickSaleDetailContext.js");
|
|
5
|
-
const require_useOrderNoteModal = require("../../../../plus/saleDetail/hooks/useOrderNoteModal.js");
|
|
6
|
-
const require_adapters = require("../../../../plus/saleDetail/components/PromotionWalletPanels/adapters.js");
|
|
7
|
-
const require_useSaleWalletAssets = require("../../../../plus/saleDetail/components/PromotionWalletPanels/useSaleWalletAssets.js");
|
|
8
|
-
const require_Base = require("../../../../plus/saleDetail/Base.js");
|
|
9
4
|
const require_locales = require("../../../HDLKiosk/locales.js");
|
|
10
|
-
const require_scaleStore = require("../../../HDLKiosk/runtime/devices/scaleStore.js");
|
|
11
5
|
const require_index = require("../../../HDLKiosk/index.js");
|
|
12
6
|
const require_config = require("../../../HDLKiosk/app/contracts/config.js");
|
|
13
|
-
const
|
|
14
|
-
const require_useHDLKioskEntryPreparationToast = require("./
|
|
15
|
-
const require_HDLKioskPaymentRuntime = require("./
|
|
16
|
-
const require_fulfillment = require("./adapter/fulfillment.js");
|
|
7
|
+
const require_useBigSaleHDLKioskAdapter = require("./adapter/useBigSaleHDLKioskAdapter.js");
|
|
8
|
+
const require_useHDLKioskEntryPreparationToast = require("./hooks/useHDLKioskEntryPreparationToast.js");
|
|
9
|
+
const require_HDLKioskPaymentRuntime = require("./runtime/HDLKioskPaymentRuntime.js");
|
|
17
10
|
const require_HDLKioskIdentityAuthPanel = require("./auth/HDLKioskIdentityAuthPanel.js");
|
|
18
11
|
const require_useHDLKioskH5AuthModule = require("./auth/useHDLKioskH5AuthModule.js");
|
|
19
|
-
const
|
|
12
|
+
const require_BigSaleScaleRuntimeOwner = require("./runtime/BigSaleScaleRuntimeOwner.js");
|
|
20
13
|
const require_primaryWeightedProduct = require("./primaryWeightedProduct.js");
|
|
14
|
+
const require_useBigSaleHDLKioskCart = require("./cart/useBigSaleHDLKioskCart.js");
|
|
21
15
|
let react = require("react");
|
|
22
16
|
react = require_runtime.__toESM(react);
|
|
23
17
|
let _pisell_utils = require("@pisell/utils");
|
|
@@ -28,41 +22,6 @@ let _pisell_utils = require("@pisell/utils");
|
|
|
28
22
|
* NativeScale owner,再将独立 HDLKiosk 作为物料渲染。
|
|
29
23
|
* 边界:兼容代码限制在本目录,不修改 HDLKiosk Core,也不要求 BigSale 上层传专用 props。
|
|
30
24
|
*/
|
|
31
|
-
const HDL_KIOSK_CART_HIDDEN_MODULES = [
|
|
32
|
-
"overview",
|
|
33
|
-
"customer",
|
|
34
|
-
"contact",
|
|
35
|
-
"cartActions",
|
|
36
|
-
"orderActions",
|
|
37
|
-
"promotionAlert"
|
|
38
|
-
];
|
|
39
|
-
const HDL_KIOSK_A12_PRESENTATION = {
|
|
40
|
-
density: "comfortable",
|
|
41
|
-
optionColumns: 2,
|
|
42
|
-
mediaFit: "cover",
|
|
43
|
-
contentAlign: "center",
|
|
44
|
-
tokens: {
|
|
45
|
-
background: "#ffffff",
|
|
46
|
-
borderColor: "#e4e7ec",
|
|
47
|
-
borderRadius: "18px",
|
|
48
|
-
minHeight: "164px",
|
|
49
|
-
mediaWidth: "228px",
|
|
50
|
-
actionRailWidth: "174px",
|
|
51
|
-
contentPadding: "20px 22px",
|
|
52
|
-
actionRailPadding: "18px 20px",
|
|
53
|
-
accentColor: "#b20d12",
|
|
54
|
-
titleColor: "#101828",
|
|
55
|
-
titleFontSize: "32px",
|
|
56
|
-
titleFontWeight: 800,
|
|
57
|
-
priceColor: "#b20d12",
|
|
58
|
-
priceFontSize: "30px",
|
|
59
|
-
optionBackground: "#f5f6f8",
|
|
60
|
-
optionLabelColor: "#667085",
|
|
61
|
-
optionValueColor: "#101828",
|
|
62
|
-
optionGap: "6px",
|
|
63
|
-
shadow: "0 12px 28px rgba(16, 24, 40, 0.08)"
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
25
|
function resolveHDLKioskBigSaleConfig(primaryWeightedProductId) {
|
|
67
26
|
return require_config.resolveHDLKioskConfig({ primaryWeightedProductId });
|
|
68
27
|
}
|
|
@@ -71,7 +30,7 @@ function resolveHDLKioskBigSaleConfig(primaryWeightedProductId) {
|
|
|
71
30
|
* 仅负责装配 Host 和配置,不承载流程或页面语义。
|
|
72
31
|
*/
|
|
73
32
|
function HDLKioskBigSaleTemplate({ isActive = true, context, businessCode, locale, productLoadParams, productCatalogSessionKey, productCatalogReady = true, saleDetailModuleConfig, onOrderComplete, variant }) {
|
|
74
|
-
var _engineContext$appHel, _engineContext$appHel2, _engineContext$appHel4, _engineContext$
|
|
33
|
+
var _engineContext$appHel, _engineContext$appHel2, _engineContext$appHel4, _engineContext$appHel9, _engineContext$appHel10, _engineContext$appHel11, _engineContext$appHel12, _context$sales$bookin, _context$sales$bookin2, _context$sales$bookin3, _productLoadParams$me, _context$sales$defaul, _context$sales$tempOr, _context$sales$tempOr2, _context$sales$tempOr3, _context$sales$tempOr4, _ref;
|
|
75
34
|
const entryDataPreparing = !productCatalogReady || context.products.loading || context.sales.catalogState === "pending";
|
|
76
35
|
const primaryWeightedProductId = !entryDataPreparing && !context.products.error && context.sales.catalogState === "ready" ? require_primaryWeightedProduct.resolvePrimaryWeightedProductId(context.products.products) : void 0;
|
|
77
36
|
const config = (0, react.useMemo)(() => resolveHDLKioskBigSaleConfig(primaryWeightedProductId), [primaryWeightedProductId]);
|
|
@@ -92,113 +51,49 @@ function HDLKioskBigSaleTemplate({ isActive = true, context, businessCode, local
|
|
|
92
51
|
const app = engineContext === null || engineContext === void 0 || (_engineContext$appHel3 = engineContext.appHelper) === null || _engineContext$appHel3 === void 0 || (_engineContext$appHel3 = _engineContext$appHel3.utils) === null || _engineContext$appHel3 === void 0 ? void 0 : _engineContext$appHel3.getApp();
|
|
93
52
|
app === null || app === void 0 || (_app$history = app.history) === null || _app$history === void 0 || _app$history.push("/admin-entry");
|
|
94
53
|
}, [engineContext === null || engineContext === void 0 || (_engineContext$appHel4 = engineContext.appHelper) === null || _engineContext$appHel4 === void 0 ? void 0 : _engineContext$appHel4.utils]);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const scaleRuntimeOwnerId = (0, react.useMemo)(() => `hdl-kiosk-scale-runtime:${Date.now()}`, []);
|
|
102
|
-
const nativeScaleTools = engineContext === null || engineContext === void 0 || (_engineContext$appHel5 = engineContext.appHelper) === null || _engineContext$appHel5 === void 0 || (_engineContext$appHel5 = _engineContext$appHel5.utils) === null || _engineContext$appHel5 === void 0 || (_engineContext$appHel6 = _engineContext$appHel5.getApp) === null || _engineContext$appHel6 === void 0 || (_engineContext$appHel6 = _engineContext$appHel6.call(_engineContext$appHel5)) === null || _engineContext$appHel6 === void 0 || (_engineContext$appHel6 = _engineContext$appHel6.plugins) === null || _engineContext$appHel6 === void 0 || (_engineContext$appHel7 = _engineContext$appHel6.get) === null || _engineContext$appHel7 === void 0 ? void 0 : _engineContext$appHel7.call(_engineContext$appHel6, "nativeScaleTools");
|
|
103
|
-
const nativeScaleSourceAvailable = typeof (nativeScaleTools === null || nativeScaleTools === void 0 ? void 0 : nativeScaleTools.useNativeScale) === "function";
|
|
104
|
-
const fulfillmentWriter = (0, react.useMemo)(() => require_fulfillment.createHDLKioskFulfillmentWriter(context.sales.bookingTicket), [context.sales.bookingTicket]);
|
|
105
|
-
const host = require_useBigSaleHDLKioskHost.useBigSaleHDLKioskHost(context, businessCode, (0, react.useMemo)(() => ({
|
|
106
|
-
writeFulfillment: fulfillmentWriter,
|
|
107
|
-
getPaymentController: () => paymentControllerRef.current,
|
|
108
|
-
subscribeWeightChange: scaleTriggerHub.subscribeWeightChange,
|
|
109
|
-
subscribeScaleConnection: scaleTriggerHub.subscribeConnection,
|
|
110
|
-
getAuthenticatedCustomer: (customerId) => {
|
|
111
|
-
const customer = authenticatedCustomerRef.current;
|
|
112
|
-
return customer && String(customer.id) === customerId ? customer : void 0;
|
|
54
|
+
const publishCollaborationStatus = (0, react.useCallback)((status) => {
|
|
55
|
+
try {
|
|
56
|
+
var _engineContext$appHel5, _engineContext$appHel6, _engineContext$appHel7, _engineContext$appHel8;
|
|
57
|
+
engineContext === null || engineContext === void 0 || (_engineContext$appHel5 = engineContext.appHelper) === null || _engineContext$appHel5 === void 0 || (_engineContext$appHel5 = _engineContext$appHel5.utils) === null || _engineContext$appHel5 === void 0 || (_engineContext$appHel6 = _engineContext$appHel5.getApp) === null || _engineContext$appHel6 === void 0 || (_engineContext$appHel6 = _engineContext$appHel6.call(_engineContext$appHel5)) === null || _engineContext$appHel6 === void 0 || (_engineContext$appHel6 = _engineContext$appHel6.applicationManager) === null || _engineContext$appHel6 === void 0 || (_engineContext$appHel7 = _engineContext$appHel6.get) === null || _engineContext$appHel7 === void 0 || (_engineContext$appHel7 = _engineContext$appHel7.call(_engineContext$appHel6, "kioskCollaborationPreview")) === null || _engineContext$appHel7 === void 0 || (_engineContext$appHel8 = _engineContext$appHel7.runFunction) === null || _engineContext$appHel8 === void 0 || _engineContext$appHel8.call(_engineContext$appHel7, "publishStatus", { status });
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.warn("[HDLKiosk] 协同预览状态上报失败,不影响销售流程", error);
|
|
113
60
|
}
|
|
114
|
-
}
|
|
61
|
+
}, [engineContext === null || engineContext === void 0 || (_engineContext$appHel9 = engineContext.appHelper) === null || _engineContext$appHel9 === void 0 ? void 0 : _engineContext$appHel9.utils]);
|
|
62
|
+
const h5AuthModuleName = require_useHDLKioskH5AuthModule.useHDLKioskH5AuthModule(engineContext, context.sales);
|
|
63
|
+
const nativeScaleTools = engineContext === null || engineContext === void 0 || (_engineContext$appHel10 = engineContext.appHelper) === null || _engineContext$appHel10 === void 0 || (_engineContext$appHel10 = _engineContext$appHel10.utils) === null || _engineContext$appHel10 === void 0 || (_engineContext$appHel11 = _engineContext$appHel10.getApp) === null || _engineContext$appHel11 === void 0 || (_engineContext$appHel11 = _engineContext$appHel11.call(_engineContext$appHel10)) === null || _engineContext$appHel11 === void 0 || (_engineContext$appHel11 = _engineContext$appHel11.plugins) === null || _engineContext$appHel11 === void 0 || (_engineContext$appHel12 = _engineContext$appHel11.get) === null || _engineContext$appHel12 === void 0 ? void 0 : _engineContext$appHel12.call(_engineContext$appHel11, "nativeScaleTools");
|
|
64
|
+
const { host, paymentControllerRef, rememberAuthenticatedCustomer, scaleBridge } = require_useBigSaleHDLKioskAdapter.useBigSaleHDLKioskAdapter({
|
|
65
|
+
context,
|
|
66
|
+
businessCode,
|
|
67
|
+
isActive,
|
|
68
|
+
nativeScaleSourceAvailable: typeof (nativeScaleTools === null || nativeScaleTools === void 0 ? void 0 : nativeScaleTools.useNativeScale) === "function"
|
|
69
|
+
});
|
|
115
70
|
const catalogLoadAttemptRef = (0, react.useRef)(void 0);
|
|
116
71
|
const renderIdentityAuth = (0, react.useCallback)((props) => /* @__PURE__ */ react.default.createElement(require_HDLKioskIdentityAuthPanel.HDLKioskIdentityAuthPanel, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, {
|
|
117
72
|
context,
|
|
118
73
|
registerAndLoginModuleName: h5AuthModuleName,
|
|
119
|
-
onCustomerResolved:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const { openOrderNoteModal, orderNoteModal } = require_useOrderNoteModal.useOrderNoteModal({
|
|
125
|
-
context: saleDetailContext,
|
|
126
|
-
modalClassName: "pisell-kiosk-modal pisell-kiosk-note-modal"
|
|
127
|
-
});
|
|
128
|
-
const hasOrderNote = Boolean(String((_note = (_ref = (_context$sales$tempOr = context.sales.tempOrder) !== null && _context$sales$tempOr !== void 0 ? _context$sales$tempOr : (_context$sales$bookin = context.sales.bookingTicket) === null || _context$sales$bookin === void 0 || (_context$sales$bookin2 = _context$sales$bookin.getTempOrder) === null || _context$sales$bookin2 === void 0 ? void 0 : _context$sales$bookin2.call(_context$sales$bookin)) === null || _ref === void 0 ? void 0 : _ref.note) !== null && _note !== void 0 ? _note : "").trim());
|
|
129
|
-
const selectedPromotionCount = (0, react.useMemo)(() => require_adapters.buildVoucherViews(context.cart.discountList || []).filter((voucher) => voucher.selected).length, [context.cart.discountList]);
|
|
130
|
-
const cartOverlayActions = (0, react.useMemo)(() => ({
|
|
131
|
-
hasNote: hasOrderNote,
|
|
132
|
-
onAddNote: openOrderNoteModal,
|
|
133
|
-
promotionAppliedCount: selectedPromotionCount
|
|
134
|
-
}), [
|
|
135
|
-
hasOrderNote,
|
|
136
|
-
openOrderNoteModal,
|
|
137
|
-
selectedPromotionCount
|
|
74
|
+
onCustomerResolved: rememberAuthenticatedCustomer
|
|
75
|
+
})), [
|
|
76
|
+
context,
|
|
77
|
+
h5AuthModuleName,
|
|
78
|
+
rememberAuthenticatedCustomer
|
|
138
79
|
]);
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
lineNoteEditingEnabled: true,
|
|
145
|
-
showInlineRemoveButton: false,
|
|
146
|
-
showQuantityBadge: false,
|
|
147
|
-
showRemoveButton: true,
|
|
148
|
-
clearSelectedQuantityOnDelete: true,
|
|
149
|
-
productLineItemType: "a12",
|
|
150
|
-
productLineItemPresentation: HDL_KIOSK_A12_PRESENTATION
|
|
151
|
-
}),
|
|
152
|
-
amountDetails: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, saleDetailModuleConfig === null || saleDetailModuleConfig === void 0 ? void 0 : saleDetailModuleConfig.amountDetails), {}, { defaultExpanded: true }),
|
|
153
|
-
promotionWalletPanels: typeof (saleDetailModuleConfig === null || saleDetailModuleConfig === void 0 ? void 0 : saleDetailModuleConfig.promotionWalletPanels) === "object" ? saleDetailModuleConfig.promotionWalletPanels : void 0,
|
|
154
|
-
promotionWalletPanelsAppearance: "light",
|
|
155
|
-
promotionWalletPanelsBehavior: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, saleDetailModuleConfig === null || saleDetailModuleConfig === void 0 ? void 0 : saleDetailModuleConfig.promotionWalletPanelsBehavior), {}, {
|
|
156
|
-
walletAssetsCleanupCoordinator: walletAssetsCleanupCoordinatorRef.current,
|
|
157
|
-
enableManualPromotionCode: true,
|
|
158
|
-
enablePromotionBanner: true,
|
|
159
|
-
enableVoucherProductAdd: true,
|
|
160
|
-
enableWalletAssets: true,
|
|
161
|
-
preserveWalletAssetsWhileRefreshing: true
|
|
162
|
-
})
|
|
163
|
-
}), [saleDetailModuleConfig]);
|
|
164
|
-
const isPrimaryProductLine = (0, react.useCallback)((item) => {
|
|
165
|
-
var _ref2, _item$_extend$product, _item$_extend, _config$primaryWeight;
|
|
166
|
-
return String((_ref2 = (_item$_extend$product = item === null || item === void 0 || (_item$_extend = item._extend) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend.product) === null || _item$_extend === void 0 ? void 0 : _item$_extend.product_id) !== null && _item$_extend$product !== void 0 ? _item$_extend$product : item === null || item === void 0 ? void 0 : item.product_id) !== null && _ref2 !== void 0 ? _ref2 : "") === String((_config$primaryWeight = config.primaryWeightedProductId) !== null && _config$primaryWeight !== void 0 ? _config$primaryWeight : "");
|
|
167
|
-
}, [config.primaryWeightedProductId]);
|
|
168
|
-
const renderCartContent = (0, react.useCallback)(({ promotionsVisible, onEditPrimaryProduct }) => /* @__PURE__ */ react.default.createElement(require_Base.default, {
|
|
169
|
-
className: "hdl-kiosk-voucher-wallet",
|
|
170
|
-
context: saleDetailContext,
|
|
171
|
-
mobilePresentation: "inline",
|
|
172
|
-
moduleConfig: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, voucherWalletModuleConfig), {}, {
|
|
173
|
-
hidden: [...HDL_KIOSK_CART_HIDDEN_MODULES, ...promotionsVisible ? [] : ["promotionWalletPanels"]],
|
|
174
|
-
cartItems: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, voucherWalletModuleConfig.cartItems), {}, {
|
|
175
|
-
isProductLineItemEditable: isPrimaryProductLine,
|
|
176
|
-
onProductLineItemEdit: onEditPrimaryProduct ? () => onEditPrimaryProduct() : void 0
|
|
177
|
-
})
|
|
178
|
-
}),
|
|
179
|
-
renderType: "current",
|
|
180
|
-
template: "A",
|
|
80
|
+
const { cartOverlayActions, orderNoteModal, renderCartContent } = require_useBigSaleHDLKioskCart.useBigSaleHDLKioskCart({
|
|
81
|
+
context,
|
|
82
|
+
onOrderComplete,
|
|
83
|
+
primaryWeightedProductId: config.primaryWeightedProductId,
|
|
84
|
+
saleDetailModuleConfig,
|
|
181
85
|
variant
|
|
182
|
-
})
|
|
183
|
-
isPrimaryProductLine,
|
|
184
|
-
saleDetailContext,
|
|
185
|
-
variant,
|
|
186
|
-
voucherWalletModuleConfig
|
|
187
|
-
]);
|
|
188
|
-
const selectedCustomerId = (_context$customer$sel = context.customer.selected) === null || _context$customer$sel === void 0 ? void 0 : _context$customer$sel.id;
|
|
189
|
-
(0, react.useEffect)(() => {
|
|
190
|
-
if (!isActive || selectedCustomerId == null) authenticatedCustomerRef.current = void 0;
|
|
191
|
-
}, [isActive, selectedCustomerId]);
|
|
86
|
+
});
|
|
192
87
|
const catalogProductCount = context.products.products.length;
|
|
193
|
-
const osCatalogProductCount = (_context$sales$
|
|
88
|
+
const osCatalogProductCount = (_context$sales$bookin = (_context$sales$bookin2 = context.sales.bookingTicket) === null || _context$sales$bookin2 === void 0 || (_context$sales$bookin3 = _context$sales$bookin2.getProductCatalog) === null || _context$sales$bookin3 === void 0 || (_context$sales$bookin3 = _context$sales$bookin3.call(_context$sales$bookin2)) === null || _context$sales$bookin3 === void 0 || (_context$sales$bookin3 = _context$sales$bookin3.products) === null || _context$sales$bookin3 === void 0 ? void 0 : _context$sales$bookin3.length) !== null && _context$sales$bookin !== void 0 ? _context$sales$bookin : 0;
|
|
194
89
|
const menuListIds = (_productLoadParams$me = productLoadParams === null || productLoadParams === void 0 ? void 0 : productLoadParams.menu_list_ids) !== null && _productLoadParams$me !== void 0 ? _productLoadParams$me : (_context$sales$defaul = context.sales.defaultProductLoadParams) === null || _context$sales$defaul === void 0 ? void 0 : _context$sales$defaul.menu_list_ids;
|
|
195
90
|
const hasCatalogSource = catalogProductCount > 0 || osCatalogProductCount > 0 || Array.isArray(menuListIds) && menuListIds.length > 0;
|
|
196
91
|
const skipsCatalogLoad = typeof productCatalogSessionKey === "string" && /-p0$/.test(productCatalogSessionKey);
|
|
197
92
|
const catalogLoadKey = JSON.stringify({
|
|
198
93
|
sessionKey: productCatalogSessionKey !== null && productCatalogSessionKey !== void 0 ? productCatalogSessionKey : "",
|
|
199
|
-
orderId: (_context$sales$
|
|
200
|
-
customerId: (_context$sales$
|
|
201
|
-
params: (
|
|
94
|
+
orderId: (_context$sales$tempOr = (_context$sales$tempOr2 = context.sales.tempOrder) === null || _context$sales$tempOr2 === void 0 ? void 0 : _context$sales$tempOr2.order_id) !== null && _context$sales$tempOr !== void 0 ? _context$sales$tempOr : null,
|
|
95
|
+
customerId: (_context$sales$tempOr3 = (_context$sales$tempOr4 = context.sales.tempOrder) === null || _context$sales$tempOr4 === void 0 ? void 0 : _context$sales$tempOr4.customer_id) !== null && _context$sales$tempOr3 !== void 0 ? _context$sales$tempOr3 : null,
|
|
96
|
+
params: (_ref = productLoadParams !== null && productLoadParams !== void 0 ? productLoadParams : context.sales.defaultProductLoadParams) !== null && _ref !== void 0 ? _ref : {}
|
|
202
97
|
});
|
|
203
98
|
(0, react.useEffect)(() => {
|
|
204
99
|
if (!isActive || !productCatalogReady || skipsCatalogLoad || !context.sales.isReady || context.sales.catalogState !== "ready" || !context.sales.bookingTicket || !hasCatalogSource || catalogLoadAttemptRef.current === catalogLoadKey) return;
|
|
@@ -220,13 +115,11 @@ function HDLKioskBigSaleTemplate({ isActive = true, context, businessCode, local
|
|
|
220
115
|
productLoadParams,
|
|
221
116
|
skipsCatalogLoad
|
|
222
117
|
]);
|
|
223
|
-
return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(
|
|
118
|
+
return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(require_BigSaleScaleRuntimeOwner.BigSaleScaleRuntimeOwner, {
|
|
224
119
|
active: isActive && (config.enabledEntries.includes("scale") || config.enabledEntries.includes("quick") || config.enabledEntries.includes("barcode")) && Boolean(config.primaryWeightedProductId),
|
|
225
|
-
|
|
120
|
+
bridge: scaleBridge,
|
|
226
121
|
nativeScaleTools,
|
|
227
|
-
minimumWeightKg: config.scaleTriggerMinimumWeightKg
|
|
228
|
-
ownerId: scaleRuntimeOwnerId,
|
|
229
|
-
runtime: scaleRuntime
|
|
122
|
+
minimumWeightKg: config.scaleTriggerMinimumWeightKg
|
|
230
123
|
}), /* @__PURE__ */ react.default.createElement(require_index.default, {
|
|
231
124
|
host,
|
|
232
125
|
config,
|
|
@@ -234,8 +127,9 @@ function HDLKioskBigSaleTemplate({ isActive = true, context, businessCode, local
|
|
|
234
127
|
isActive,
|
|
235
128
|
locale,
|
|
236
129
|
onTechnicalSupportClick: handleTechnicalSupportClick,
|
|
130
|
+
onCollaborationStatusChange: publishCollaborationStatus,
|
|
237
131
|
onLocaleChange: typeof updateLocaleRuntime === "function" ? handleLocaleChange : void 0,
|
|
238
|
-
scaleRuntime,
|
|
132
|
+
scaleRuntime: scaleBridge.runtime,
|
|
239
133
|
renderIdentityAuth: h5AuthModuleName ? renderIdentityAuth : void 0,
|
|
240
134
|
renderCartContent,
|
|
241
135
|
cartOverlayActions
|
|
@@ -3,51 +3,13 @@ const require_defineProperty = require("../../../../../_virtual/_@oxc-project_ru
|
|
|
3
3
|
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_runtime.__toESM(react);
|
|
6
|
-
//#region src/components/bigSale/templates/HDLKiosk/
|
|
6
|
+
//#region src/components/bigSale/templates/HDLKiosk/runtime/BigSaleScaleRuntimeOwner.tsx
|
|
7
7
|
/**
|
|
8
8
|
* 文件角色:拥有 BigSale 的 useNativeScale Hook,并桥接到 HDLKiosk 全局 Scale Runtime。
|
|
9
|
-
* 运行机制:顶层 owner 在整个物料生命周期持续监听真秤/Web
|
|
10
|
-
*
|
|
9
|
+
* 运行机制:顶层 owner 在整个物料生命周期持续监听真秤/Web 模拟器,将读数统一发布给
|
|
10
|
+
* ScaleBridge;Screen 读取 Snapshot,入口消费离散设备事件。
|
|
11
11
|
* 边界:不复用旧 Weighing UI,不在本文件决定进入流程或更新购物车。
|
|
12
12
|
*/
|
|
13
|
-
function createScaleTriggerHub() {
|
|
14
|
-
const weightListeners = /* @__PURE__ */ new Set();
|
|
15
|
-
const connectionListeners = /* @__PURE__ */ new Set();
|
|
16
|
-
const activityListeners = /* @__PURE__ */ new Set();
|
|
17
|
-
let lastConnection;
|
|
18
|
-
const notifyActivity = () => activityListeners.forEach((listener) => listener());
|
|
19
|
-
return {
|
|
20
|
-
subscribeWeightChange: (listener) => {
|
|
21
|
-
weightListeners.add(listener);
|
|
22
|
-
notifyActivity();
|
|
23
|
-
return () => {
|
|
24
|
-
weightListeners.delete(listener);
|
|
25
|
-
notifyActivity();
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
subscribeConnection: (listener) => {
|
|
29
|
-
connectionListeners.add(listener);
|
|
30
|
-
if (lastConnection) listener(lastConnection);
|
|
31
|
-
notifyActivity();
|
|
32
|
-
return () => {
|
|
33
|
-
connectionListeners.delete(listener);
|
|
34
|
-
notifyActivity();
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
publishWeightChange: (payload) => weightListeners.forEach((listener) => listener(payload)),
|
|
38
|
-
publishConnection: (payload) => {
|
|
39
|
-
lastConnection = payload;
|
|
40
|
-
connectionListeners.forEach((listener) => listener(payload));
|
|
41
|
-
},
|
|
42
|
-
hasSubscribers: () => weightListeners.size > 0 || connectionListeners.size > 0,
|
|
43
|
-
subscribeActivity: (listener) => {
|
|
44
|
-
activityListeners.add(listener);
|
|
45
|
-
return () => {
|
|
46
|
-
activityListeners.delete(listener);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
13
|
function inspectScaleEntrySnapshot(scale, minimumWeightKg) {
|
|
52
14
|
var _ref, _scale$connectionStat, _scale$rawData;
|
|
53
15
|
const nativeConnectionState = (_ref = (_scale$connectionStat = scale.connectionState) !== null && _scale$connectionStat !== void 0 ? _scale$connectionStat : (_scale$rawData = scale.rawData) === null || _scale$rawData === void 0 ? void 0 : _scale$rawData.connectionState) !== null && _ref !== void 0 ? _ref : null;
|
|
@@ -78,13 +40,13 @@ function BigSaleScaleRuntimeOwner(props) {
|
|
|
78
40
|
var _props$nativeScaleToo;
|
|
79
41
|
const useNativeScale = (_props$nativeScaleToo = props.nativeScaleTools) === null || _props$nativeScaleToo === void 0 ? void 0 : _props$nativeScaleToo.useNativeScale;
|
|
80
42
|
if (!props.active || typeof useNativeScale !== "function") return null;
|
|
81
|
-
return /* @__PURE__ */ react.default.createElement(MonitorBoundary, { onError: () => props.
|
|
43
|
+
return /* @__PURE__ */ react.default.createElement(MonitorBoundary, { onError: () => props.bridge.publishConnection({
|
|
82
44
|
connected: false,
|
|
83
45
|
state: "error",
|
|
84
46
|
occurredAt: Date.now()
|
|
85
47
|
}) }, /* @__PURE__ */ react.default.createElement(ActiveScaleRuntimeOwner, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, { useNativeScale })));
|
|
86
48
|
}
|
|
87
|
-
function ActiveScaleRuntimeOwner({ active,
|
|
49
|
+
function ActiveScaleRuntimeOwner({ active, bridge, minimumWeightKg, useNativeScale }) {
|
|
88
50
|
const consumedReadingRef = (0, react.useRef)(false);
|
|
89
51
|
const lastConnectionStateRef = (0, react.useRef)();
|
|
90
52
|
const eventSequenceRef = (0, react.useRef)(0);
|
|
@@ -107,15 +69,11 @@ function ActiveScaleRuntimeOwner({ active, hub, minimumWeightKg, ownerId, runtim
|
|
|
107
69
|
const inspection = inspectScaleEntrySnapshot(scale, minimumWeightKg);
|
|
108
70
|
(0, react.useEffect)(() => {
|
|
109
71
|
if (!active) return void 0;
|
|
110
|
-
return runtime.activate(ownerId);
|
|
111
|
-
}, [
|
|
112
|
-
active,
|
|
113
|
-
ownerId,
|
|
114
|
-
runtime
|
|
115
|
-
]);
|
|
72
|
+
return bridge.runtime.activate(bridge.ownerId);
|
|
73
|
+
}, [active, bridge]);
|
|
116
74
|
(0, react.useEffect)(() => {
|
|
117
75
|
if (!active) return;
|
|
118
|
-
runtime.publish(ownerId, {
|
|
76
|
+
bridge.runtime.publish(bridge.ownerId, {
|
|
119
77
|
grossWeightKg: scale.grossWeight,
|
|
120
78
|
status: scale.status,
|
|
121
79
|
connectionState: scale.connectionState,
|
|
@@ -126,8 +84,7 @@ function ActiveScaleRuntimeOwner({ active, hub, minimumWeightKg, ownerId, runtim
|
|
|
126
84
|
});
|
|
127
85
|
}, [
|
|
128
86
|
active,
|
|
129
|
-
|
|
130
|
-
runtime,
|
|
87
|
+
bridge,
|
|
131
88
|
scale.connectionState,
|
|
132
89
|
scale.error,
|
|
133
90
|
scale.grossWeight,
|
|
@@ -144,7 +101,7 @@ function ActiveScaleRuntimeOwner({ active, hub, minimumWeightKg, ownerId, runtim
|
|
|
144
101
|
const state = inspection.connectionState;
|
|
145
102
|
if (lastConnectionStateRef.current !== state) {
|
|
146
103
|
lastConnectionStateRef.current = state;
|
|
147
|
-
|
|
104
|
+
bridge.publishConnection({
|
|
148
105
|
connected: state === "connected",
|
|
149
106
|
state,
|
|
150
107
|
occurredAt: Date.now()
|
|
@@ -152,7 +109,7 @@ function ActiveScaleRuntimeOwner({ active, hub, minimumWeightKg, ownerId, runtim
|
|
|
152
109
|
}
|
|
153
110
|
}, [
|
|
154
111
|
active,
|
|
155
|
-
|
|
112
|
+
bridge,
|
|
156
113
|
inspection.connectionState
|
|
157
114
|
]);
|
|
158
115
|
(0, react.useEffect)(() => {
|
|
@@ -162,13 +119,13 @@ function ActiveScaleRuntimeOwner({ active, hub, minimumWeightKg, ownerId, runtim
|
|
|
162
119
|
return;
|
|
163
120
|
}
|
|
164
121
|
if (consumedReadingRef.current) return;
|
|
165
|
-
if (!runtime.getSnapshot().hasLiveSample) return;
|
|
122
|
+
if (!bridge.runtime.getSnapshot().hasLiveSample) return;
|
|
166
123
|
const grossWeight = inspection.validGrossWeightKg;
|
|
167
124
|
if (grossWeight === void 0) return;
|
|
168
125
|
consumedReadingRef.current = true;
|
|
169
126
|
eventSequenceRef.current += 1;
|
|
170
127
|
const occurredAt = sample.receivedAt || Date.now();
|
|
171
|
-
|
|
128
|
+
bridge.publishWeightChange({
|
|
172
129
|
eventId: `native-scale-change:${occurredAt}:${eventSequenceRef.current}`,
|
|
173
130
|
occurredAt,
|
|
174
131
|
weight: {
|
|
@@ -180,10 +137,9 @@ function ActiveScaleRuntimeOwner({ active, hub, minimumWeightKg, ownerId, runtim
|
|
|
180
137
|
});
|
|
181
138
|
}, [
|
|
182
139
|
active,
|
|
183
|
-
|
|
140
|
+
bridge,
|
|
184
141
|
inspection.belowTriggerThreshold,
|
|
185
142
|
inspection.validGrossWeightKg,
|
|
186
|
-
runtime,
|
|
187
143
|
sample.receivedAt,
|
|
188
144
|
scale.status
|
|
189
145
|
]);
|
|
@@ -191,4 +147,3 @@ function ActiveScaleRuntimeOwner({ active, hub, minimumWeightKg, ownerId, runtim
|
|
|
191
147
|
}
|
|
192
148
|
//#endregion
|
|
193
149
|
exports.BigSaleScaleRuntimeOwner = BigSaleScaleRuntimeOwner;
|
|
194
|
-
exports.createScaleTriggerHub = createScaleTriggerHub;
|
package/lib/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js
RENAMED
|
@@ -6,10 +6,10 @@ const require_constants = require("../../../../checkout/constants.js");
|
|
|
6
6
|
const require_PaymentMethodRuntime = require("../../../../checkout/paymentRuntime/PaymentMethodRuntime.js");
|
|
7
7
|
const require_pendingEftposLifecycle = require("../../../../checkout/paymentRuntime/pendingEftposLifecycle.js");
|
|
8
8
|
const require_utils = require("../../../../checkout/utils.js");
|
|
9
|
-
const require_normalize = require("
|
|
9
|
+
const require_normalize = require("../adapter/normalize.js");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
react = require_runtime.__toESM(react);
|
|
12
|
-
//#region src/components/bigSale/templates/HDLKiosk/
|
|
12
|
+
//#region src/components/bigSale/templates/HDLKiosk/runtime/HDLKioskPaymentRuntime.tsx
|
|
13
13
|
/**
|
|
14
14
|
* BigSale 模板内的 Kiosk 支付桥。它持有需要 React/设备 UI 的 PaymentMethodRuntime,
|
|
15
15
|
* 再把窄命令交给独立 HDLKiosk Host;Core 不感知 BigSale、PiPayment 或 window.app。
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const require_scaleStore = require("../../../../HDLKiosk/runtime/devices/scaleStore.js");
|
|
2
|
+
//#region src/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.ts
|
|
3
|
+
function createBigSaleScaleBridge({ now = Date.now } = {}) {
|
|
4
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
const runtime = require_scaleStore.createHDLScaleRuntime();
|
|
6
|
+
const ownerId = `hdl-kiosk-scale-runtime:${now()}`;
|
|
7
|
+
let eventSequence = 0;
|
|
8
|
+
let lastConnection;
|
|
9
|
+
const emit = (event) => {
|
|
10
|
+
listeners.forEach((listener) => listener(event));
|
|
11
|
+
};
|
|
12
|
+
return Object.freeze({
|
|
13
|
+
ownerId,
|
|
14
|
+
runtime,
|
|
15
|
+
subscribeDeviceEvents: (listener) => {
|
|
16
|
+
listeners.add(listener);
|
|
17
|
+
if (lastConnection) listener(lastConnection);
|
|
18
|
+
return () => {
|
|
19
|
+
listeners.delete(listener);
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
publishWeightChange: ({ weight, eventId, occurredAt = now() }) => {
|
|
23
|
+
eventSequence += 1;
|
|
24
|
+
emit({
|
|
25
|
+
type: "weightChanged",
|
|
26
|
+
eventId: eventId !== null && eventId !== void 0 ? eventId : `big-sale-scale:${occurredAt}:${eventSequence}`,
|
|
27
|
+
weight,
|
|
28
|
+
occurredAt
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
publishConnection: ({ connected, state, occurredAt = now() }) => {
|
|
32
|
+
lastConnection = {
|
|
33
|
+
type: "connectionChanged",
|
|
34
|
+
device: "scale",
|
|
35
|
+
connected,
|
|
36
|
+
state,
|
|
37
|
+
occurredAt
|
|
38
|
+
};
|
|
39
|
+
emit(lastConnection);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.createBigSaleScaleBridge = createBigSaleScaleBridge;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.170",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"styled-components": "^6.0.0-rc.3",
|
|
71
71
|
"use-sync-external-store": "^1.6.0",
|
|
72
72
|
"@pisell/pi-payment-sdk": "0.0.3",
|
|
73
|
-
"@pisell/materials": "6.12.50",
|
|
74
73
|
"@pisell/utils": "3.0.4",
|
|
74
|
+
"@pisell/date-picker": "3.0.10",
|
|
75
75
|
"@pisell/icon": "0.0.11",
|
|
76
|
-
"@pisell/
|
|
76
|
+
"@pisell/materials": "6.12.50"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"react": "^18.0.0",
|