@pisell/pisellos 0.0.321 → 0.0.324
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/effects/index.d.ts +2 -2
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Payment/types.d.ts +7 -7
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +27 -28
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +3 -7
- package/lib/modules/Account/index.js +9 -10
- package/lib/modules/AccountList/index.js +14 -11
- package/lib/modules/BaseModule.js +6 -3
- package/lib/modules/Cart/index.js +14 -9
- package/lib/modules/Cart/utils/cartProduct.js +3 -6
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +18 -15
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +10 -6
- package/lib/modules/Date/types.js +1 -0
- package/lib/modules/Discount/index.js +11 -6
- package/lib/modules/Guests/index.js +10 -15
- package/lib/modules/Order/index.js +11 -9
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +80 -69
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +3 -6
- package/lib/modules/Payment/walletpass.js +31 -31
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +6 -5
- package/lib/modules/ProductList/index.js +7 -4
- package/lib/modules/Resource/index.js +8 -12
- package/lib/modules/Rules/index.js +12 -17
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +8 -5
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +2 -4
- package/lib/modules/Step/index.js +7 -4
- package/lib/modules/Summary/index.js +9 -4
- package/lib/plugins/request.js +34 -33
- package/lib/plugins/window.js +101 -113
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +70 -104
- package/lib/solution/BookingByStep/utils/capacity.js +10 -15
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +4 -8
- package/lib/solution/BookingByStep/utils/stock.js +3 -6
- package/lib/solution/BookingByStep/utils/timeslots.js +24 -27
- package/lib/solution/BookingTicket/index.js +19 -14
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +3 -1
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/Checkout/index.js +206 -199
- package/lib/solution/Checkout/utils/index.js +18 -22
- package/lib/solution/ShopDiscount/index.js +15 -11
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +5 -7
- package/package.json +1 -1
package/lib/plugins/request.js
CHANGED
|
@@ -24,6 +24,9 @@ __export(request_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(request_exports);
|
|
26
26
|
var RequestError = class extends Error {
|
|
27
|
+
response;
|
|
28
|
+
request;
|
|
29
|
+
config;
|
|
27
30
|
constructor(message, config, request, response) {
|
|
28
31
|
super(message);
|
|
29
32
|
this.name = "RequestError";
|
|
@@ -33,38 +36,36 @@ var RequestError = class extends Error {
|
|
|
33
36
|
}
|
|
34
37
|
};
|
|
35
38
|
var RequestPluginImpl = class {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
}
|
|
39
|
+
name = "request";
|
|
40
|
+
version = "1.0.0";
|
|
41
|
+
core = null;
|
|
42
|
+
/**
|
|
43
|
+
* 默认请求选项
|
|
44
|
+
*/
|
|
45
|
+
defaultOptions = {
|
|
46
|
+
method: "GET",
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-Type": "application/json"
|
|
49
|
+
},
|
|
50
|
+
timeout: 3e4,
|
|
51
|
+
responseType: "json"
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 全局拦截器
|
|
55
|
+
*/
|
|
56
|
+
interceptors = {
|
|
57
|
+
request: [],
|
|
58
|
+
response: [],
|
|
59
|
+
error: []
|
|
60
|
+
};
|
|
60
61
|
// 初始化方法
|
|
61
62
|
initialize() {
|
|
62
63
|
this.core = globalThis.pisellOS;
|
|
63
|
-
console.log("[RequestPlugin]
|
|
64
|
+
console.log("[RequestPlugin] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
64
65
|
}
|
|
65
66
|
// 销毁方法
|
|
66
67
|
destroy() {
|
|
67
|
-
console.log("[RequestPlugin]
|
|
68
|
+
console.log("[RequestPlugin] \u5DF2\u9500\u6BC1");
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* 添加请求拦截器
|
|
@@ -149,7 +150,7 @@ var RequestPluginImpl = class {
|
|
|
149
150
|
config = await Promise.resolve(interceptor(config));
|
|
150
151
|
} catch (error) {
|
|
151
152
|
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
152
|
-
error instanceof Error ? error.message : "
|
|
153
|
+
error instanceof Error ? error.message : "\u8BF7\u6C42\u62E6\u622A\u5668\u9519\u8BEF",
|
|
153
154
|
config
|
|
154
155
|
);
|
|
155
156
|
let processedError = requestError;
|
|
@@ -174,7 +175,7 @@ var RequestPluginImpl = class {
|
|
|
174
175
|
);
|
|
175
176
|
} catch (error) {
|
|
176
177
|
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
177
|
-
error instanceof Error ? error.message : "
|
|
178
|
+
error instanceof Error ? error.message : "\u54CD\u5E94\u62E6\u622A\u5668\u9519\u8BEF",
|
|
178
179
|
config,
|
|
179
180
|
null,
|
|
180
181
|
response
|
|
@@ -194,7 +195,7 @@ var RequestPluginImpl = class {
|
|
|
194
195
|
return processedResponse.data;
|
|
195
196
|
} catch (error) {
|
|
196
197
|
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
197
|
-
error instanceof Error ? error.message : "
|
|
198
|
+
error instanceof Error ? error.message : "\u8BF7\u6C42\u9519\u8BEF",
|
|
198
199
|
config
|
|
199
200
|
);
|
|
200
201
|
let processedError = requestError;
|
|
@@ -225,7 +226,7 @@ var RequestPluginImpl = class {
|
|
|
225
226
|
withCredentials
|
|
226
227
|
} = config;
|
|
227
228
|
if (!url) {
|
|
228
|
-
throw new RequestError("URL
|
|
229
|
+
throw new RequestError("URL\u4E0D\u80FD\u4E3A\u7A7A", config);
|
|
229
230
|
}
|
|
230
231
|
let fullUrl = url;
|
|
231
232
|
if (params && Object.keys(params).length > 0) {
|
|
@@ -255,13 +256,13 @@ var RequestPluginImpl = class {
|
|
|
255
256
|
const timeoutPromise = new Promise((_, reject) => {
|
|
256
257
|
if (timeout) {
|
|
257
258
|
timeoutId = setTimeout(() => {
|
|
258
|
-
reject(new RequestError(
|
|
259
|
+
reject(new RequestError(`\u8BF7\u6C42\u8D85\u65F6: ${timeout}ms`, config));
|
|
259
260
|
}, timeout);
|
|
260
261
|
}
|
|
261
262
|
});
|
|
262
263
|
try {
|
|
263
264
|
const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(
|
|
264
|
-
new RequestError("
|
|
265
|
+
new RequestError("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301 fetch API", config)
|
|
265
266
|
);
|
|
266
267
|
const response = await Promise.race([fetchPromise, timeoutPromise]);
|
|
267
268
|
const responseHeaders = {};
|
|
@@ -297,7 +298,7 @@ var RequestPluginImpl = class {
|
|
|
297
298
|
};
|
|
298
299
|
if (!response.ok) {
|
|
299
300
|
throw new RequestError(
|
|
300
|
-
|
|
301
|
+
`\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${response.status}`,
|
|
301
302
|
config,
|
|
302
303
|
fetchOptions,
|
|
303
304
|
result
|
package/lib/plugins/window.js
CHANGED
|
@@ -23,9 +23,7 @@ __export(window_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(window_exports);
|
|
25
25
|
var SimpleStorage = class {
|
|
26
|
-
|
|
27
|
-
this.items = {};
|
|
28
|
-
}
|
|
26
|
+
items = {};
|
|
29
27
|
get length() {
|
|
30
28
|
return Object.keys(this.items).length;
|
|
31
29
|
}
|
|
@@ -47,18 +45,16 @@ var SimpleStorage = class {
|
|
|
47
45
|
}
|
|
48
46
|
};
|
|
49
47
|
var SimpleLocation = class {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.ancestorOrigins = {};
|
|
61
|
-
}
|
|
48
|
+
hash = "";
|
|
49
|
+
host = "localhost";
|
|
50
|
+
hostname = "localhost";
|
|
51
|
+
href = "https://localhost";
|
|
52
|
+
origin = "https://localhost";
|
|
53
|
+
pathname = "/";
|
|
54
|
+
port = "";
|
|
55
|
+
protocol = "https:";
|
|
56
|
+
search = "";
|
|
57
|
+
ancestorOrigins = {};
|
|
62
58
|
assign(url) {
|
|
63
59
|
}
|
|
64
60
|
reload() {
|
|
@@ -70,29 +66,25 @@ var SimpleLocation = class {
|
|
|
70
66
|
}
|
|
71
67
|
};
|
|
72
68
|
var SimpleNavigator = class {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.product = "PisellOS";
|
|
85
|
-
}
|
|
69
|
+
userAgent = "PisellOS/1.0";
|
|
70
|
+
language = "zh-CN";
|
|
71
|
+
languages = ["zh-CN", "en-US"];
|
|
72
|
+
onLine = true;
|
|
73
|
+
cookieEnabled = true;
|
|
74
|
+
// 以下属性只提供必要实现
|
|
75
|
+
appCodeName = "PisellOS";
|
|
76
|
+
appName = "PisellOS";
|
|
77
|
+
appVersion = "1.0";
|
|
78
|
+
platform = "PisellOS";
|
|
79
|
+
product = "PisellOS";
|
|
86
80
|
javaEnabled() {
|
|
87
81
|
return false;
|
|
88
82
|
}
|
|
89
83
|
};
|
|
90
84
|
var SimpleHistory = class {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.state = null;
|
|
95
|
-
}
|
|
85
|
+
length = 0;
|
|
86
|
+
scrollRestoration = "auto";
|
|
87
|
+
state = null;
|
|
96
88
|
back() {
|
|
97
89
|
}
|
|
98
90
|
forward() {
|
|
@@ -105,17 +97,8 @@ var SimpleHistory = class {
|
|
|
105
97
|
}
|
|
106
98
|
};
|
|
107
99
|
var SimpleDocument = class {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.elements = {};
|
|
111
|
-
// Document 接口的必要属性
|
|
112
|
-
this.URL = "https://localhost";
|
|
113
|
-
this.documentURI = "https://localhost";
|
|
114
|
-
this.origin = "https://localhost";
|
|
115
|
-
this.characterSet = "UTF-8";
|
|
116
|
-
this.contentType = "text/html";
|
|
117
|
-
this.compatMode = "CSS1Compat";
|
|
118
|
-
}
|
|
100
|
+
// 仅实现基本功能
|
|
101
|
+
elements = {};
|
|
119
102
|
createElement(tagName) {
|
|
120
103
|
const element = {
|
|
121
104
|
tagName: tagName.toUpperCase(),
|
|
@@ -155,6 +138,13 @@ var SimpleDocument = class {
|
|
|
155
138
|
getElementById(id) {
|
|
156
139
|
return this.elements[id] || null;
|
|
157
140
|
}
|
|
141
|
+
// Document 接口的必要属性
|
|
142
|
+
URL = "https://localhost";
|
|
143
|
+
documentURI = "https://localhost";
|
|
144
|
+
origin = "https://localhost";
|
|
145
|
+
characterSet = "UTF-8";
|
|
146
|
+
contentType = "text/html";
|
|
147
|
+
compatMode = "CSS1Compat";
|
|
158
148
|
querySelector() {
|
|
159
149
|
return null;
|
|
160
150
|
}
|
|
@@ -169,84 +159,82 @@ var SimpleDocument = class {
|
|
|
169
159
|
}
|
|
170
160
|
};
|
|
171
161
|
var WindowPluginImpl = class {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return globalThis.setTimeout(handler, timeout, ...args);
|
|
180
|
-
}
|
|
181
|
-
const timeoutId = Date.now();
|
|
182
|
-
Promise.resolve().then(() => {
|
|
183
|
-
setTimeout(() => {
|
|
184
|
-
if (typeof handler === "function") {
|
|
185
|
-
handler(...args);
|
|
186
|
-
} else {
|
|
187
|
-
eval(handler);
|
|
188
|
-
}
|
|
189
|
-
}, timeout || 0);
|
|
190
|
-
});
|
|
191
|
-
return timeoutId;
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
__promisify__: function(delay, value) {
|
|
195
|
-
return new Promise((resolve) => setTimeout(resolve, delay, value));
|
|
196
|
-
}
|
|
162
|
+
name = "window";
|
|
163
|
+
version = "1.0.0";
|
|
164
|
+
// 定时器相关
|
|
165
|
+
setTimeout = Object.assign(
|
|
166
|
+
function(handler, timeout, ...args) {
|
|
167
|
+
if (typeof globalThis !== "undefined" && globalThis.setTimeout) {
|
|
168
|
+
return globalThis.setTimeout(handler, timeout, ...args);
|
|
197
169
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
170
|
+
const timeoutId = Date.now();
|
|
171
|
+
Promise.resolve().then(() => {
|
|
172
|
+
setTimeout(() => {
|
|
173
|
+
if (typeof handler === "function") {
|
|
174
|
+
handler(...args);
|
|
175
|
+
} else {
|
|
176
|
+
eval(handler);
|
|
177
|
+
}
|
|
178
|
+
}, timeout || 0);
|
|
179
|
+
});
|
|
180
|
+
return timeoutId;
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
__promisify__: function(delay, value) {
|
|
184
|
+
return new Promise((resolve) => setTimeout(resolve, delay, value));
|
|
202
185
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
} else {
|
|
215
|
-
eval(handler);
|
|
216
|
-
}
|
|
217
|
-
recursiveTimeout();
|
|
218
|
-
}, timeout || 0);
|
|
219
|
-
};
|
|
220
|
-
recursiveTimeout();
|
|
221
|
-
return intervalId;
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
__promisify__: function(delay, value) {
|
|
225
|
-
return new Promise((resolve) => setInterval(resolve, delay, value));
|
|
226
|
-
}
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
clearTimeout = function(timeout2) {
|
|
189
|
+
if (typeof globalThis !== "undefined" && globalThis.clearTimeout) {
|
|
190
|
+
globalThis.clearTimeout(timeout2);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
setInterval = Object.assign(
|
|
194
|
+
function(handler, timeout, ...args) {
|
|
195
|
+
if (typeof globalThis !== "undefined" && globalThis.setInterval) {
|
|
196
|
+
return globalThis.setInterval(handler, timeout, ...args);
|
|
227
197
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
198
|
+
const intervalId = Date.now();
|
|
199
|
+
const recursiveTimeout = () => {
|
|
200
|
+
this.setTimeout(() => {
|
|
201
|
+
if (typeof handler === "function") {
|
|
202
|
+
handler(...args);
|
|
203
|
+
} else {
|
|
204
|
+
eval(handler);
|
|
205
|
+
}
|
|
206
|
+
recursiveTimeout();
|
|
207
|
+
}, timeout || 0);
|
|
208
|
+
};
|
|
209
|
+
recursiveTimeout();
|
|
210
|
+
return intervalId;
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
__promisify__: function(delay, value) {
|
|
214
|
+
return new Promise((resolve) => setInterval(resolve, delay, value));
|
|
232
215
|
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
clearInterval = function(timeout2) {
|
|
219
|
+
if (typeof globalThis !== "undefined" && globalThis.clearInterval) {
|
|
220
|
+
globalThis.clearInterval(timeout2);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
// 存储相关
|
|
224
|
+
localStorage = new SimpleStorage();
|
|
225
|
+
sessionStorage = new SimpleStorage();
|
|
226
|
+
// 浏览器环境对象
|
|
227
|
+
location = new SimpleLocation();
|
|
228
|
+
navigator = new SimpleNavigator();
|
|
229
|
+
document = new SimpleDocument();
|
|
230
|
+
history = new SimpleHistory();
|
|
243
231
|
// 初始化方法
|
|
244
232
|
initialize() {
|
|
245
|
-
console.log("[WindowPlugin]
|
|
233
|
+
console.log("[WindowPlugin] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
246
234
|
}
|
|
247
235
|
// 销毁方法
|
|
248
236
|
destroy() {
|
|
249
|
-
console.log("[WindowPlugin]
|
|
237
|
+
console.log("[WindowPlugin] \u5DF2\u9500\u6BC1");
|
|
250
238
|
}
|
|
251
239
|
};
|
|
252
240
|
var window_default = new WindowPluginImpl();
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
};
|
|
327
327
|
setOtherData(key: string, value: any): void;
|
|
328
328
|
getOtherData(key: string): any;
|
|
329
|
-
getProductTypeById(id: number): Promise<"
|
|
329
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
330
330
|
/**
|
|
331
331
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
332
332
|
*
|