@pisell/pisellos 3.0.57 → 3.0.58
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/dist/core/index.js +1 -2
- package/dist/effects/index.d.ts +3 -4
- package/dist/effects/index.js +6 -15
- package/dist/modules/AccountList/index.d.ts +1 -7
- package/dist/modules/AccountList/index.js +14 -81
- package/dist/modules/AccountList/types.d.ts +0 -28
- package/dist/modules/AccountList/types.js +0 -8
- package/dist/modules/Cart/index.js +1 -1
- package/dist/modules/Payment/index.d.ts +9 -273
- package/dist/modules/Payment/index.js +109 -2525
- package/dist/modules/Payment/types.d.ts +30 -382
- package/dist/modules/Payment/types.js +14 -116
- package/dist/modules/ProductList/index.d.ts +1 -12
- package/dist/modules/ProductList/index.js +3 -27
- package/dist/modules/Rules/index.js +14 -27
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -1
- package/dist/plugins/window.d.ts +0 -1
- package/dist/solution/BookingByStep/index.js +1 -9
- package/dist/solution/ShopDiscount/index.js +2 -4
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/dist/types/index.d.ts +1 -3
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +3 -4
- package/lib/effects/index.js +1 -4
- package/lib/modules/AccountList/index.d.ts +1 -7
- package/lib/modules/AccountList/index.js +0 -27
- package/lib/modules/AccountList/types.d.ts +0 -28
- package/lib/modules/Cart/index.js +1 -1
- package/lib/modules/Payment/index.d.ts +9 -273
- package/lib/modules/Payment/index.js +50 -1285
- package/lib/modules/Payment/types.d.ts +30 -382
- package/lib/modules/Payment/types.js +6 -41
- package/lib/modules/ProductList/index.d.ts +1 -12
- package/lib/modules/ProductList/index.js +2 -29
- package/lib/modules/Rules/index.js +12 -20
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +0 -2
- package/lib/plugins/window.d.ts +0 -1
- package/lib/solution/BookingByStep/index.js +2 -1
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/lib/types/index.d.ts +1 -3
- package/package.json +2 -4
- package/dist/modules/Customer/constants.d.ts +0 -7
- package/dist/modules/Customer/constants.js +0 -12
- package/dist/modules/Customer/index.d.ts +0 -122
- package/dist/modules/Customer/index.js +0 -697
- package/dist/modules/Customer/types.d.ts +0 -146
- package/dist/modules/Customer/types.js +0 -41
- package/dist/modules/Payment/cash.d.ts +0 -11
- package/dist/modules/Payment/cash.js +0 -78
- package/dist/modules/Payment/eftpos.d.ts +0 -11
- package/dist/modules/Payment/eftpos.js +0 -80
- package/dist/modules/Payment/wallet.d.ts +0 -11
- package/dist/modules/Payment/wallet.js +0 -78
- package/dist/modules/Payment/walletpass.d.ts +0 -0
- package/dist/modules/Payment/walletpass.js +0 -0
- package/dist/plugins/app-types/app/app.d.ts +0 -83
- package/dist/plugins/app-types/app/const.d.ts +0 -4
- package/dist/plugins/app-types/app/index.d.ts +0 -14
- package/dist/plugins/app-types/applicationManager/application.d.ts +0 -50
- package/dist/plugins/app-types/applicationManager/index.d.ts +0 -13
- package/dist/plugins/app-types/config.d.ts +0 -3
- package/dist/plugins/app-types/cookie/index.d.ts +0 -13
- package/dist/plugins/app-types/data/index.d.ts +0 -8
- package/dist/plugins/app-types/history/config.d.ts +0 -24
- package/dist/plugins/app-types/history/index.d.ts +0 -20
- package/dist/plugins/app-types/history/type.d.ts +0 -2
- package/dist/plugins/app-types/hooks/index.d.ts +0 -12
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +0 -6
- package/dist/plugins/app-types/index.d.ts +0 -6
- package/dist/plugins/app-types/indexDB/index.d.ts +0 -178
- package/dist/plugins/app-types/locales/en.d.ts +0 -3
- package/dist/plugins/app-types/locales/index.d.ts +0 -37
- package/dist/plugins/app-types/locales/original.d.ts +0 -3
- package/dist/plugins/app-types/locales/type.d.ts +0 -19
- package/dist/plugins/app-types/locales/zh-CN.d.ts +0 -3
- package/dist/plugins/app-types/locales/zh-HK.d.ts +0 -3
- package/dist/plugins/app-types/logger/feishu.d.ts +0 -11
- package/dist/plugins/app-types/logger/index.d.ts +0 -122
- package/dist/plugins/app-types/menuManager/hooks.d.ts +0 -17
- package/dist/plugins/app-types/menuManager/index.d.ts +0 -28
- package/dist/plugins/app-types/models/global.d.ts +0 -32
- package/dist/plugins/app-types/models/index.d.ts +0 -45
- package/dist/plugins/app-types/models/type.d.ts +0 -2
- package/dist/plugins/app-types/package.json +0 -15
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +0 -5
- package/dist/plugins/app-types/pubsub/index.d.ts +0 -63
- package/dist/plugins/app-types/request/cache.d.ts +0 -46
- package/dist/plugins/app-types/request/cancelToken.d.ts +0 -38
- package/dist/plugins/app-types/request/config.d.ts +0 -3
- package/dist/plugins/app-types/request/constants.d.ts +0 -2
- package/dist/plugins/app-types/request/index.d.ts +0 -24
- package/dist/plugins/app-types/request/pisell2Request.d.ts +0 -6
- package/dist/plugins/app-types/request/type.d.ts +0 -41
- package/dist/plugins/app-types/request/utils.d.ts +0 -46
- package/dist/plugins/app-types/routes/config.d.ts +0 -7
- package/dist/plugins/app-types/routes/index.d.ts +0 -28
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
- package/dist/plugins/app-types/socket/components/index.d.ts +0 -2
- package/dist/plugins/app-types/socket/constants.d.ts +0 -33
- package/dist/plugins/app-types/socket/events.d.ts +0 -31
- package/dist/plugins/app-types/socket/heartbeat.d.ts +0 -66
- package/dist/plugins/app-types/socket/index.d.ts +0 -61
- package/dist/plugins/app-types/socket/monitor.d.ts +0 -169
- package/dist/plugins/app-types/socket/reconnect.d.ts +0 -61
- package/dist/plugins/app-types/socket/socket.d.ts +0 -129
- package/dist/plugins/app-types/socket/types.d.ts +0 -85
- package/dist/plugins/app-types/storage/index.d.ts +0 -17
- package/dist/plugins/app-types/tasks/index.d.ts +0 -77
- package/dist/plugins/app-types/tasks/type.d.ts +0 -62
- package/dist/plugins/app-types/tasks/useTasks.d.ts +0 -5
- package/dist/plugins/app-types/type.d.ts +0 -2
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
- package/dist/plugins/app-types/variables/config.d.ts +0 -3
- package/dist/plugins/app-types/variables/index.d.ts +0 -6
- package/dist/plugins/app-types/variables/type.d.ts +0 -2
- package/dist/plugins/app-types/website/index.d.ts +0 -6
- package/dist/plugins/app.d.ts +0 -8
- package/dist/plugins/app.js +0 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -172
- package/dist/solution/BookingTicket/index.js +0 -665
- package/dist/solution/BookingTicket/types.d.ts +0 -68
- package/dist/solution/BookingTicket/types.js +0 -43
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -174
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -81
- package/dist/solution/BookingTicket/utils/scan/index.js +0 -285
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/dist/solution/Checkout/index.d.ts +0 -181
- package/dist/solution/Checkout/index.js +0 -1596
- package/dist/solution/Checkout/types.d.ts +0 -550
- package/dist/solution/Checkout/types.js +0 -132
- package/dist/solution/Checkout/utils/index.d.ts +0 -73
- package/dist/solution/Checkout/utils/index.js +0 -371
- package/dist/utils/task.d.ts +0 -40
- package/dist/utils/task.js +0 -171
- package/dist/utils/watch.d.ts +0 -102
- package/dist/utils/watch.js +0 -294
- package/lib/modules/Customer/constants.d.ts +0 -7
- package/lib/modules/Customer/constants.js +0 -39
- package/lib/modules/Customer/index.d.ts +0 -122
- package/lib/modules/Customer/index.js +0 -440
- package/lib/modules/Customer/types.d.ts +0 -146
- package/lib/modules/Customer/types.js +0 -37
- package/lib/modules/Payment/cash.d.ts +0 -11
- package/lib/modules/Payment/cash.js +0 -51
- package/lib/modules/Payment/eftpos.d.ts +0 -11
- package/lib/modules/Payment/eftpos.js +0 -51
- package/lib/modules/Payment/wallet.d.ts +0 -11
- package/lib/modules/Payment/wallet.js +0 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -0
- package/lib/modules/Payment/walletpass.js +0 -0
- package/lib/plugins/app-types/app/app.d.ts +0 -83
- package/lib/plugins/app-types/app/const.d.ts +0 -4
- package/lib/plugins/app-types/app/index.d.ts +0 -14
- package/lib/plugins/app-types/applicationManager/application.d.ts +0 -50
- package/lib/plugins/app-types/applicationManager/index.d.ts +0 -13
- package/lib/plugins/app-types/config.d.ts +0 -3
- package/lib/plugins/app-types/cookie/index.d.ts +0 -13
- package/lib/plugins/app-types/data/index.d.ts +0 -8
- package/lib/plugins/app-types/history/config.d.ts +0 -24
- package/lib/plugins/app-types/history/index.d.ts +0 -20
- package/lib/plugins/app-types/history/type.d.ts +0 -2
- package/lib/plugins/app-types/hooks/index.d.ts +0 -12
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +0 -6
- package/lib/plugins/app-types/index.d.ts +0 -6
- package/lib/plugins/app-types/indexDB/index.d.ts +0 -178
- package/lib/plugins/app-types/locales/en.d.ts +0 -3
- package/lib/plugins/app-types/locales/index.d.ts +0 -37
- package/lib/plugins/app-types/locales/original.d.ts +0 -3
- package/lib/plugins/app-types/locales/type.d.ts +0 -19
- package/lib/plugins/app-types/locales/zh-CN.d.ts +0 -3
- package/lib/plugins/app-types/locales/zh-HK.d.ts +0 -3
- package/lib/plugins/app-types/logger/feishu.d.ts +0 -11
- package/lib/plugins/app-types/logger/index.d.ts +0 -122
- package/lib/plugins/app-types/menuManager/hooks.d.ts +0 -17
- package/lib/plugins/app-types/menuManager/index.d.ts +0 -28
- package/lib/plugins/app-types/models/global.d.ts +0 -32
- package/lib/plugins/app-types/models/index.d.ts +0 -45
- package/lib/plugins/app-types/models/type.d.ts +0 -2
- package/lib/plugins/app-types/package.json +0 -15
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +0 -5
- package/lib/plugins/app-types/pubsub/index.d.ts +0 -63
- package/lib/plugins/app-types/request/cache.d.ts +0 -46
- package/lib/plugins/app-types/request/cancelToken.d.ts +0 -38
- package/lib/plugins/app-types/request/config.d.ts +0 -3
- package/lib/plugins/app-types/request/constants.d.ts +0 -2
- package/lib/plugins/app-types/request/index.d.ts +0 -24
- package/lib/plugins/app-types/request/pisell2Request.d.ts +0 -6
- package/lib/plugins/app-types/request/type.d.ts +0 -41
- package/lib/plugins/app-types/request/utils.d.ts +0 -46
- package/lib/plugins/app-types/routes/config.d.ts +0 -7
- package/lib/plugins/app-types/routes/index.d.ts +0 -28
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
- package/lib/plugins/app-types/socket/components/index.d.ts +0 -2
- package/lib/plugins/app-types/socket/constants.d.ts +0 -33
- package/lib/plugins/app-types/socket/events.d.ts +0 -31
- package/lib/plugins/app-types/socket/heartbeat.d.ts +0 -66
- package/lib/plugins/app-types/socket/index.d.ts +0 -61
- package/lib/plugins/app-types/socket/monitor.d.ts +0 -169
- package/lib/plugins/app-types/socket/reconnect.d.ts +0 -61
- package/lib/plugins/app-types/socket/socket.d.ts +0 -129
- package/lib/plugins/app-types/socket/types.d.ts +0 -85
- package/lib/plugins/app-types/storage/index.d.ts +0 -17
- package/lib/plugins/app-types/tasks/index.d.ts +0 -77
- package/lib/plugins/app-types/tasks/type.d.ts +0 -62
- package/lib/plugins/app-types/tasks/useTasks.d.ts +0 -5
- package/lib/plugins/app-types/type.d.ts +0 -2
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
- package/lib/plugins/app-types/variables/config.d.ts +0 -3
- package/lib/plugins/app-types/variables/index.d.ts +0 -6
- package/lib/plugins/app-types/variables/type.d.ts +0 -2
- package/lib/plugins/app-types/website/index.d.ts +0 -6
- package/lib/plugins/app.d.ts +0 -8
- package/lib/plugins/app.js +0 -17
- package/lib/solution/BookingTicket/index.d.ts +0 -172
- package/lib/solution/BookingTicket/index.js +0 -399
- package/lib/solution/BookingTicket/types.d.ts +0 -68
- package/lib/solution/BookingTicket/types.js +0 -72
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -125
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +0 -210
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/index.d.ts +0 -181
- package/lib/solution/Checkout/index.js +0 -864
- package/lib/solution/Checkout/types.d.ts +0 -550
- package/lib/solution/Checkout/types.js +0 -75
- package/lib/solution/Checkout/utils/index.d.ts +0 -73
- package/lib/solution/Checkout/utils/index.js +0 -266
- package/lib/utils/task.d.ts +0 -40
- package/lib/utils/task.js +0 -109
- package/lib/utils/watch.d.ts +0 -102
- package/lib/utils/watch.js +0 -217
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/solution/Checkout/utils/index.ts
|
|
20
|
-
var utils_exports = {};
|
|
21
|
-
__export(utils_exports, {
|
|
22
|
-
calculateProgress: () => calculateProgress,
|
|
23
|
-
createCheckoutError: () => createCheckoutError,
|
|
24
|
-
debounce: () => debounce,
|
|
25
|
-
deepClone: () => deepClone,
|
|
26
|
-
formatAmount: () => formatAmount,
|
|
27
|
-
generateOrderId: () => generateOrderId,
|
|
28
|
-
getErrorMessage: () => getErrorMessage,
|
|
29
|
-
isEmpty: () => isEmpty,
|
|
30
|
-
isProduction: () => isProduction,
|
|
31
|
-
isValidPaymentMethodCode: () => isValidPaymentMethodCode,
|
|
32
|
-
logger: () => logger,
|
|
33
|
-
retry: () => retry,
|
|
34
|
-
safeJsonParse: () => safeJsonParse,
|
|
35
|
-
throttle: () => throttle,
|
|
36
|
-
validateAmount: () => validateAmount,
|
|
37
|
-
validateCheckoutData: () => validateCheckoutData
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(utils_exports);
|
|
40
|
-
var import_types = require("../types");
|
|
41
|
-
function validateCheckoutData(params) {
|
|
42
|
-
const errors = [];
|
|
43
|
-
if (!params.cartItems || params.cartItems.length === 0) {
|
|
44
|
-
errors.push("购物车不能为空");
|
|
45
|
-
}
|
|
46
|
-
if (params.cartItems) {
|
|
47
|
-
params.cartItems.forEach((item, index) => {
|
|
48
|
-
if (!item.id) {
|
|
49
|
-
errors.push(`购物车商品 ${index + 1} 缺少商品ID`);
|
|
50
|
-
}
|
|
51
|
-
if (!item.price || parseFloat(String(item.price)) < 0) {
|
|
52
|
-
errors.push(`购物车商品 ${index + 1} 价格无效`);
|
|
53
|
-
}
|
|
54
|
-
if (!item.num || item.num <= 0) {
|
|
55
|
-
errors.push(`购物车商品 ${index + 1} 数量无效`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (params.orderType && !["virtual", "appointment_booking"].includes(params.orderType)) {
|
|
60
|
-
errors.push("订单类型无效,必须是 virtual 或 appointment_booking");
|
|
61
|
-
}
|
|
62
|
-
if (params.platform && !["pc", "h5"].includes(params.platform)) {
|
|
63
|
-
errors.push("平台类型无效,必须是 pc 或 h5");
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
valid: errors.length === 0,
|
|
67
|
-
errors
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function createCheckoutError(type, message, details) {
|
|
71
|
-
return {
|
|
72
|
-
type,
|
|
73
|
-
message,
|
|
74
|
-
details,
|
|
75
|
-
timestamp: Date.now()
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function calculateProgress(status, step) {
|
|
79
|
-
let baseProgress = 0;
|
|
80
|
-
switch (status) {
|
|
81
|
-
case import_types.CheckoutStatus.Initializing:
|
|
82
|
-
baseProgress = 5;
|
|
83
|
-
break;
|
|
84
|
-
case import_types.CheckoutStatus.Ready:
|
|
85
|
-
baseProgress = 10;
|
|
86
|
-
break;
|
|
87
|
-
case import_types.CheckoutStatus.CreatingOrder:
|
|
88
|
-
baseProgress = 25;
|
|
89
|
-
break;
|
|
90
|
-
case import_types.CheckoutStatus.OrderCreated:
|
|
91
|
-
baseProgress = 40;
|
|
92
|
-
break;
|
|
93
|
-
case import_types.CheckoutStatus.ProcessingPayment:
|
|
94
|
-
baseProgress = 65;
|
|
95
|
-
break;
|
|
96
|
-
case import_types.CheckoutStatus.PaymentCompleted:
|
|
97
|
-
baseProgress = 85;
|
|
98
|
-
break;
|
|
99
|
-
case import_types.CheckoutStatus.Completed:
|
|
100
|
-
baseProgress = 100;
|
|
101
|
-
break;
|
|
102
|
-
case import_types.CheckoutStatus.Cancelled:
|
|
103
|
-
case import_types.CheckoutStatus.Error:
|
|
104
|
-
baseProgress = 0;
|
|
105
|
-
break;
|
|
106
|
-
default:
|
|
107
|
-
baseProgress = 0;
|
|
108
|
-
}
|
|
109
|
-
let stepProgress = 0;
|
|
110
|
-
switch (step) {
|
|
111
|
-
case import_types.CheckoutStep.OrderConfirmation:
|
|
112
|
-
stepProgress = 0;
|
|
113
|
-
break;
|
|
114
|
-
case import_types.CheckoutStep.PaymentMethod:
|
|
115
|
-
stepProgress = 10;
|
|
116
|
-
break;
|
|
117
|
-
case import_types.CheckoutStep.PaymentProcessing:
|
|
118
|
-
stepProgress = 15;
|
|
119
|
-
break;
|
|
120
|
-
case import_types.CheckoutStep.Complete:
|
|
121
|
-
stepProgress = 0;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
return Math.min(100, baseProgress + stepProgress);
|
|
125
|
-
}
|
|
126
|
-
function formatAmount(amount) {
|
|
127
|
-
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
128
|
-
if (isNaN(numAmount))
|
|
129
|
-
return "0.00";
|
|
130
|
-
return numAmount.toFixed(2);
|
|
131
|
-
}
|
|
132
|
-
function validateAmount(amount) {
|
|
133
|
-
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
134
|
-
return !isNaN(numAmount) && numAmount >= 0;
|
|
135
|
-
}
|
|
136
|
-
function generateOrderId(prefix = "order") {
|
|
137
|
-
const timestamp = Date.now();
|
|
138
|
-
const random = Math.floor(Math.random() * 1e4).toString().padStart(4, "0");
|
|
139
|
-
return `${prefix}_${timestamp}_${random}`;
|
|
140
|
-
}
|
|
141
|
-
function isValidPaymentMethodCode(code) {
|
|
142
|
-
return typeof code === "string" && code.length > 0 && /^[a-zA-Z0-9_-]+$/.test(code);
|
|
143
|
-
}
|
|
144
|
-
function safeJsonParse(jsonString, defaultValue) {
|
|
145
|
-
try {
|
|
146
|
-
return JSON.parse(jsonString);
|
|
147
|
-
} catch {
|
|
148
|
-
return defaultValue;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function deepClone(obj) {
|
|
152
|
-
if (obj === null || typeof obj !== "object") {
|
|
153
|
-
return obj;
|
|
154
|
-
}
|
|
155
|
-
if (obj instanceof Date) {
|
|
156
|
-
return new Date(obj.getTime());
|
|
157
|
-
}
|
|
158
|
-
if (obj instanceof Array) {
|
|
159
|
-
return obj.map((item) => deepClone(item));
|
|
160
|
-
}
|
|
161
|
-
if (typeof obj === "object") {
|
|
162
|
-
const clonedObj = {};
|
|
163
|
-
for (const key in obj) {
|
|
164
|
-
if (obj.hasOwnProperty(key)) {
|
|
165
|
-
clonedObj[key] = deepClone(obj[key]);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return clonedObj;
|
|
169
|
-
}
|
|
170
|
-
return obj;
|
|
171
|
-
}
|
|
172
|
-
function debounce(func, wait) {
|
|
173
|
-
let timeout = null;
|
|
174
|
-
return (...args) => {
|
|
175
|
-
if (timeout) {
|
|
176
|
-
clearTimeout(timeout);
|
|
177
|
-
}
|
|
178
|
-
timeout = setTimeout(() => {
|
|
179
|
-
func.apply(null, args);
|
|
180
|
-
}, wait);
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function throttle(func, wait) {
|
|
184
|
-
let lastTime = 0;
|
|
185
|
-
return (...args) => {
|
|
186
|
-
const now = Date.now();
|
|
187
|
-
if (now - lastTime >= wait) {
|
|
188
|
-
lastTime = now;
|
|
189
|
-
func.apply(null, args);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
async function retry(fn, maxAttempts = 3, delay = 1e3) {
|
|
194
|
-
let lastError;
|
|
195
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
196
|
-
try {
|
|
197
|
-
return await fn();
|
|
198
|
-
} catch (error) {
|
|
199
|
-
lastError = error;
|
|
200
|
-
if (attempt === maxAttempts) {
|
|
201
|
-
throw lastError;
|
|
202
|
-
}
|
|
203
|
-
await new Promise((resolve) => setTimeout(resolve, delay * attempt));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
throw lastError;
|
|
207
|
-
}
|
|
208
|
-
function isEmpty(obj) {
|
|
209
|
-
if (obj == null)
|
|
210
|
-
return true;
|
|
211
|
-
if (Array.isArray(obj) || typeof obj === "string")
|
|
212
|
-
return obj.length === 0;
|
|
213
|
-
if (typeof obj === "object")
|
|
214
|
-
return Object.keys(obj).length === 0;
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
function getErrorMessage(error) {
|
|
218
|
-
if (error instanceof Error) {
|
|
219
|
-
return error.message;
|
|
220
|
-
}
|
|
221
|
-
if (typeof error === "string") {
|
|
222
|
-
return error;
|
|
223
|
-
}
|
|
224
|
-
if (error && typeof error === "object" && "message" in error) {
|
|
225
|
-
return String(error.message);
|
|
226
|
-
}
|
|
227
|
-
return "未知错误";
|
|
228
|
-
}
|
|
229
|
-
function isProduction() {
|
|
230
|
-
return process.env.NODE_ENV === "production";
|
|
231
|
-
}
|
|
232
|
-
var logger = {
|
|
233
|
-
info: (message, ...args) => {
|
|
234
|
-
console.log(`[Checkout] ${message}`, ...args);
|
|
235
|
-
},
|
|
236
|
-
warn: (message, ...args) => {
|
|
237
|
-
console.warn(`[Checkout] ${message}`, ...args);
|
|
238
|
-
},
|
|
239
|
-
error: (message, ...args) => {
|
|
240
|
-
console.error(`[Checkout] ${message}`, ...args);
|
|
241
|
-
},
|
|
242
|
-
debug: (message, ...args) => {
|
|
243
|
-
if (!isProduction()) {
|
|
244
|
-
console.debug(`[Checkout] ${message}`, ...args);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
249
|
-
0 && (module.exports = {
|
|
250
|
-
calculateProgress,
|
|
251
|
-
createCheckoutError,
|
|
252
|
-
debounce,
|
|
253
|
-
deepClone,
|
|
254
|
-
formatAmount,
|
|
255
|
-
generateOrderId,
|
|
256
|
-
getErrorMessage,
|
|
257
|
-
isEmpty,
|
|
258
|
-
isProduction,
|
|
259
|
-
isValidPaymentMethodCode,
|
|
260
|
-
logger,
|
|
261
|
-
retry,
|
|
262
|
-
safeJsonParse,
|
|
263
|
-
throttle,
|
|
264
|
-
validateAmount,
|
|
265
|
-
validateCheckoutData
|
|
266
|
-
});
|
package/lib/utils/task.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
type Action = (...args: any[]) => Promise<any>;
|
|
2
|
-
type Task = {
|
|
3
|
-
uuid: string;
|
|
4
|
-
type: string;
|
|
5
|
-
actionParams?: Record<string, any>;
|
|
6
|
-
};
|
|
7
|
-
declare class Tasks {
|
|
8
|
-
private actions;
|
|
9
|
-
private taskQueue;
|
|
10
|
-
isRunning: boolean;
|
|
11
|
-
constructor(actions?: Map<string, Action>);
|
|
12
|
-
/**
|
|
13
|
-
* 清空所有任务
|
|
14
|
-
*/
|
|
15
|
-
clear(): void;
|
|
16
|
-
/**
|
|
17
|
-
* 清空任务执行队列
|
|
18
|
-
*/
|
|
19
|
-
clearTaskQueue(): void;
|
|
20
|
-
/**
|
|
21
|
-
* 添加action
|
|
22
|
-
* @param name action名称
|
|
23
|
-
* @param action action函数
|
|
24
|
-
*/
|
|
25
|
-
addAction(name: string, action: Action): void;
|
|
26
|
-
/**
|
|
27
|
-
* 添加任务
|
|
28
|
-
* @param task 任务
|
|
29
|
-
*/
|
|
30
|
-
addTask(task: Task): void;
|
|
31
|
-
/**
|
|
32
|
-
* 执行任务
|
|
33
|
-
*/
|
|
34
|
-
run(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* 判定当前的任务是否依然存在
|
|
37
|
-
*/
|
|
38
|
-
isTaskExist(uuid: string): boolean;
|
|
39
|
-
}
|
|
40
|
-
export default Tasks;
|
package/lib/utils/task.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/utils/task.ts
|
|
20
|
-
var task_exports = {};
|
|
21
|
-
__export(task_exports, {
|
|
22
|
-
default: () => task_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(task_exports);
|
|
25
|
-
var Tasks = class {
|
|
26
|
-
constructor(actions) {
|
|
27
|
-
this.actions = /* @__PURE__ */ new Map();
|
|
28
|
-
this.taskQueue = [];
|
|
29
|
-
this.isRunning = false;
|
|
30
|
-
if (actions) {
|
|
31
|
-
this.actions = actions;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 清空所有任务
|
|
36
|
-
*/
|
|
37
|
-
clear() {
|
|
38
|
-
this.actions.clear();
|
|
39
|
-
this.taskQueue = [];
|
|
40
|
-
this.isRunning = false;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 清空任务执行队列
|
|
44
|
-
*/
|
|
45
|
-
clearTaskQueue() {
|
|
46
|
-
this.taskQueue = [];
|
|
47
|
-
this.isRunning = false;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 添加action
|
|
51
|
-
* @param name action名称
|
|
52
|
-
* @param action action函数
|
|
53
|
-
*/
|
|
54
|
-
addAction(name, action) {
|
|
55
|
-
this.actions.set(name, action);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 添加任务
|
|
59
|
-
* @param task 任务
|
|
60
|
-
*/
|
|
61
|
-
addTask(task) {
|
|
62
|
-
this.taskQueue.push(task);
|
|
63
|
-
this.run();
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 执行任务
|
|
67
|
-
*/
|
|
68
|
-
async run() {
|
|
69
|
-
var _a;
|
|
70
|
-
if (this.isRunning) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (this.taskQueue.length === 0) {
|
|
74
|
-
this.isRunning = false;
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
this.isRunning = true;
|
|
78
|
-
while (this.taskQueue.length > 0) {
|
|
79
|
-
const task = (_a = this.taskQueue) == null ? void 0 : _a[0];
|
|
80
|
-
if (!task) {
|
|
81
|
-
this.isRunning = false;
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const action = this.actions.get(task.type);
|
|
85
|
-
if (action) {
|
|
86
|
-
try {
|
|
87
|
-
await action({ ...(task == null ? void 0 : task.actionParams) || {}, uuid: task == null ? void 0 : task.uuid });
|
|
88
|
-
console.log("task_success>>>>>>>", task);
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error("task_error>>>>>>>", error);
|
|
91
|
-
} finally {
|
|
92
|
-
const _task = this.taskQueue.shift();
|
|
93
|
-
console.log("task_shift>>>>>>>", _task);
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
const _task = this.taskQueue.shift();
|
|
97
|
-
console.log("task_action_not_found>>>>>>>", _task);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
this.isRunning = false;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* 判定当前的任务是否依然存在
|
|
104
|
-
*/
|
|
105
|
-
isTaskExist(uuid) {
|
|
106
|
-
return this.taskQueue.some((task) => (task == null ? void 0 : task.uuid) === uuid);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var task_default = Tasks;
|
package/lib/utils/watch.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 监听模块
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export type WatchEventCallback = (...args: any[]) => void;
|
|
6
|
-
export type WatchEventItem = {
|
|
7
|
-
key: string;
|
|
8
|
-
callback: WatchEventCallback;
|
|
9
|
-
};
|
|
10
|
-
export interface WatchEventSubscription {
|
|
11
|
-
unsubscribe: () => void;
|
|
12
|
-
}
|
|
13
|
-
declare class Watch {
|
|
14
|
-
private events;
|
|
15
|
-
private enableListMap;
|
|
16
|
-
/**
|
|
17
|
-
* 订阅事件
|
|
18
|
-
* @param event 事件名称
|
|
19
|
-
* @param callback 回调函数
|
|
20
|
-
* @returns 订阅对象,可用于取消订阅
|
|
21
|
-
*/
|
|
22
|
-
subscribe(watchKey: string, event: WatchEventItem): WatchEventSubscription;
|
|
23
|
-
/**
|
|
24
|
-
* 启用事件
|
|
25
|
-
* @param watchKey 监听的key
|
|
26
|
-
* @param event 事件名称
|
|
27
|
-
*/
|
|
28
|
-
enableEvent(watchKey: string, eventKey: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* 禁用某个事件
|
|
31
|
-
* @param watchKey 监听的key
|
|
32
|
-
* @param eventKey 事件名称
|
|
33
|
-
*/
|
|
34
|
-
disableEvent(watchKey: string, eventKey: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* 冻结某个监听下的所有事件
|
|
37
|
-
* @param watchKey 监听的key
|
|
38
|
-
*/
|
|
39
|
-
disabledAllEventByWatchKey(watchKey: string): void;
|
|
40
|
-
/**
|
|
41
|
-
* 启用某个监听下的所有事件
|
|
42
|
-
* @param watchKey 监听的key
|
|
43
|
-
*/
|
|
44
|
-
enableAllEventByWatchKey(watchKey: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* 取消订阅事件
|
|
47
|
-
* @param event 事件名称
|
|
48
|
-
* @param callback 回调函数
|
|
49
|
-
* @returns 是否成功取消订阅
|
|
50
|
-
*/
|
|
51
|
-
unsubscribe(watchKey: string, event: WatchEventItem): void;
|
|
52
|
-
/**
|
|
53
|
-
* 发布事件
|
|
54
|
-
* @param event 事件名称
|
|
55
|
-
* @param args 事件参数
|
|
56
|
-
*/
|
|
57
|
-
publish(watchKey: string, ...args: any[]): void;
|
|
58
|
-
/**
|
|
59
|
-
* 根据事件名称发布事件
|
|
60
|
-
* @param watchKey 监听的key
|
|
61
|
-
* @param eventKey 事件名称
|
|
62
|
-
* @param args 事件参数
|
|
63
|
-
*/
|
|
64
|
-
publishByEventKey(watchKey: string, eventKey: string, ...args: any[]): void;
|
|
65
|
-
/**
|
|
66
|
-
* 获取最后一个启用的事件
|
|
67
|
-
* @param watchKey 监听的key
|
|
68
|
-
* @returns 最后一个启用的事件
|
|
69
|
-
*/
|
|
70
|
-
getLastEnableEventKey(watchKey: string): WatchEventItem['key'] | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* 移除某个事件的所有订阅
|
|
73
|
-
* @param event 事件名称
|
|
74
|
-
* @returns 是否成功移除
|
|
75
|
-
*/
|
|
76
|
-
clearEvent(watchKey: string): void;
|
|
77
|
-
/**
|
|
78
|
-
* 移除所有事件订阅
|
|
79
|
-
*/
|
|
80
|
-
clearAllEvents(): void;
|
|
81
|
-
/**
|
|
82
|
-
* 获取事件的订阅数量
|
|
83
|
-
* @param event 事件名称
|
|
84
|
-
* @returns 订阅数量
|
|
85
|
-
*/
|
|
86
|
-
getSubscriberCount(event: string): number;
|
|
87
|
-
/**
|
|
88
|
-
* 检查事件是否有订阅者
|
|
89
|
-
* @param event 事件名称
|
|
90
|
-
* @returns 是否有订阅者
|
|
91
|
-
*/
|
|
92
|
-
hasSubscribers(event: string): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* 一次性订阅事件,事件触发后自动取消订阅
|
|
95
|
-
* @param event 事件名称
|
|
96
|
-
* @param callback 回调函数
|
|
97
|
-
* @returns 订阅对象,可用于取消订阅
|
|
98
|
-
*/
|
|
99
|
-
once(watchKey: string, event: WatchEventItem): WatchEventSubscription;
|
|
100
|
-
}
|
|
101
|
-
declare const watch: Watch;
|
|
102
|
-
export default watch;
|