@pisell/pisellos 0.0.5
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/README.md +180 -0
- package/dist/core/index.d.ts +30 -0
- package/dist/core/index.js +360 -0
- package/dist/effects/index.d.ts +17 -0
- package/dist/effects/index.js +162 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +17 -0
- package/dist/modules/Account/index.d.ts +21 -0
- package/dist/modules/Account/index.js +212 -0
- package/dist/modules/Account/types.d.ts +41 -0
- package/dist/modules/Account/types.js +19 -0
- package/dist/modules/BaseModule.d.ts +11 -0
- package/dist/modules/BaseModule.js +27 -0
- package/dist/modules/Cart/index.d.ts +33 -0
- package/dist/modules/Cart/index.js +242 -0
- package/dist/modules/Cart/types.d.ts +35 -0
- package/dist/modules/Cart/types.js +19 -0
- package/dist/modules/Date/index.d.ts +17 -0
- package/dist/modules/Date/index.js +133 -0
- package/dist/modules/Date/types.d.ts +32 -0
- package/dist/modules/Date/types.js +17 -0
- package/dist/modules/Guests/index.d.ts +17 -0
- package/dist/modules/Guests/index.js +259 -0
- package/dist/modules/Guests/types.d.ts +43 -0
- package/dist/modules/Guests/types.js +23 -0
- package/dist/modules/Order/index.d.ts +17 -0
- package/dist/modules/Order/index.js +228 -0
- package/dist/modules/Order/types.d.ts +57 -0
- package/dist/modules/Order/types.js +29 -0
- package/dist/modules/Payment/index.d.ts +18 -0
- package/dist/modules/Payment/index.js +243 -0
- package/dist/modules/Payment/types.d.ts +49 -0
- package/dist/modules/Payment/types.js +31 -0
- package/dist/modules/Product/index.d.ts +39 -0
- package/dist/modules/Product/index.js +118 -0
- package/dist/modules/Product/types.d.ts +387 -0
- package/dist/modules/Product/types.js +1 -0
- package/dist/modules/ProductList/index.d.ts +16 -0
- package/dist/modules/ProductList/index.js +158 -0
- package/dist/modules/ProductList/types.d.ts +9 -0
- package/dist/modules/ProductList/types.js +5 -0
- package/dist/modules/Resource/index.d.ts +15 -0
- package/dist/modules/Resource/index.js +219 -0
- package/dist/modules/Resource/types.d.ts +44 -0
- package/dist/modules/Resource/types.js +22 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +3 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/request.d.ts +127 -0
- package/dist/plugins/request.js +592 -0
- package/dist/plugins/window.d.ts +115 -0
- package/dist/plugins/window.js +328 -0
- package/dist/solution/BookingByStep/index.d.ts +12 -0
- package/dist/solution/BookingByStep/index.js +77 -0
- package/dist/solution/BookingByStep/types.d.ts +27 -0
- package/dist/solution/BookingByStep/types.js +10 -0
- package/dist/solution/BuyTickets/index.d.ts +26 -0
- package/dist/solution/BuyTickets/index.js +339 -0
- package/dist/solution/BuyTickets/types.d.ts +24 -0
- package/dist/solution/BuyTickets/types.js +19 -0
- package/dist/solution/PlaceOrder/index.d.ts +0 -0
- package/dist/solution/PlaceOrder/index.js +54 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +1 -0
- package/dist/store/createStore.d.ts +3 -0
- package/dist/store/createStore.js +43 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/index.js +1 -0
- package/lib/core/index.d.ts +30 -0
- package/lib/core/index.js +212 -0
- package/lib/effects/index.d.ts +17 -0
- package/lib/effects/index.js +78 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +51 -0
- package/lib/modules/Account/index.d.ts +21 -0
- package/lib/modules/Account/index.js +93 -0
- package/lib/modules/Account/types.d.ts +41 -0
- package/lib/modules/Account/types.js +35 -0
- package/lib/modules/BaseModule.d.ts +11 -0
- package/lib/modules/BaseModule.js +40 -0
- package/lib/modules/Cart/index.d.ts +33 -0
- package/lib/modules/Cart/index.js +104 -0
- package/lib/modules/Cart/types.d.ts +35 -0
- package/lib/modules/Cart/types.js +35 -0
- package/lib/modules/Date/index.d.ts +17 -0
- package/lib/modules/Date/index.js +75 -0
- package/lib/modules/Date/types.d.ts +32 -0
- package/lib/modules/Date/types.js +33 -0
- package/lib/modules/Guests/index.d.ts +17 -0
- package/lib/modules/Guests/index.js +95 -0
- package/lib/modules/Guests/types.d.ts +43 -0
- package/lib/modules/Guests/types.js +35 -0
- package/lib/modules/Order/index.d.ts +17 -0
- package/lib/modules/Order/index.js +95 -0
- package/lib/modules/Order/types.d.ts +57 -0
- package/lib/modules/Order/types.js +35 -0
- package/lib/modules/Payment/index.d.ts +18 -0
- package/lib/modules/Payment/index.js +103 -0
- package/lib/modules/Payment/types.d.ts +49 -0
- package/lib/modules/Payment/types.js +35 -0
- package/lib/modules/Product/index.d.ts +39 -0
- package/lib/modules/Product/index.js +87 -0
- package/lib/modules/Product/types.d.ts +387 -0
- package/lib/modules/Product/types.js +17 -0
- package/lib/modules/ProductList/index.d.ts +16 -0
- package/lib/modules/ProductList/index.js +71 -0
- package/lib/modules/ProductList/types.d.ts +9 -0
- package/lib/modules/ProductList/types.js +33 -0
- package/lib/modules/Resource/index.d.ts +15 -0
- package/lib/modules/Resource/index.js +91 -0
- package/lib/modules/Resource/types.d.ts +44 -0
- package/lib/modules/Resource/types.js +34 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +27 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +25 -0
- package/lib/plugins/request.d.ts +127 -0
- package/lib/plugins/request.js +297 -0
- package/lib/plugins/window.d.ts +115 -0
- package/lib/plugins/window.js +252 -0
- package/lib/solution/BookingByStep/index.d.ts +12 -0
- package/lib/solution/BookingByStep/index.js +53 -0
- package/lib/solution/BookingByStep/types.d.ts +27 -0
- package/lib/solution/BookingByStep/types.js +38 -0
- package/lib/solution/BuyTickets/index.d.ts +26 -0
- package/lib/solution/BuyTickets/index.js +122 -0
- package/lib/solution/BuyTickets/types.d.ts +24 -0
- package/lib/solution/BuyTickets/types.js +40 -0
- package/lib/solution/PlaceOrder/index.d.ts +0 -0
- package/lib/solution/PlaceOrder/index.js +0 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +23 -0
- package/lib/store/createStore.d.ts +3 -0
- package/lib/store/createStore.js +46 -0
- package/lib/types/index.d.ts +85 -0
- package/lib/types/index.js +17 -0
- package/package.json +65 -0
|
@@ -0,0 +1,252 @@
|
|
|
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/plugins/window.ts
|
|
20
|
+
var window_exports = {};
|
|
21
|
+
__export(window_exports, {
|
|
22
|
+
default: () => window_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(window_exports);
|
|
25
|
+
var SimpleStorage = class {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.items = {};
|
|
28
|
+
}
|
|
29
|
+
get length() {
|
|
30
|
+
return Object.keys(this.items).length;
|
|
31
|
+
}
|
|
32
|
+
key(index) {
|
|
33
|
+
const keys = Object.keys(this.items);
|
|
34
|
+
return index >= 0 && index < keys.length ? keys[index] : null;
|
|
35
|
+
}
|
|
36
|
+
getItem(key) {
|
|
37
|
+
return key in this.items ? this.items[key] : null;
|
|
38
|
+
}
|
|
39
|
+
setItem(key, value) {
|
|
40
|
+
this.items[key] = value;
|
|
41
|
+
}
|
|
42
|
+
removeItem(key) {
|
|
43
|
+
delete this.items[key];
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.items = {};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var SimpleLocation = class {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.hash = "";
|
|
52
|
+
this.host = "localhost";
|
|
53
|
+
this.hostname = "localhost";
|
|
54
|
+
this.href = "https://localhost";
|
|
55
|
+
this.origin = "https://localhost";
|
|
56
|
+
this.pathname = "/";
|
|
57
|
+
this.port = "";
|
|
58
|
+
this.protocol = "https:";
|
|
59
|
+
this.search = "";
|
|
60
|
+
this.ancestorOrigins = {};
|
|
61
|
+
}
|
|
62
|
+
assign(url) {
|
|
63
|
+
}
|
|
64
|
+
reload() {
|
|
65
|
+
}
|
|
66
|
+
replace(url) {
|
|
67
|
+
}
|
|
68
|
+
toString() {
|
|
69
|
+
return this.href;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var SimpleNavigator = class {
|
|
73
|
+
constructor() {
|
|
74
|
+
this.userAgent = "PisellOS/1.0";
|
|
75
|
+
this.language = "zh-CN";
|
|
76
|
+
this.languages = ["zh-CN", "en-US"];
|
|
77
|
+
this.onLine = true;
|
|
78
|
+
this.cookieEnabled = true;
|
|
79
|
+
// 以下属性只提供必要实现
|
|
80
|
+
this.appCodeName = "PisellOS";
|
|
81
|
+
this.appName = "PisellOS";
|
|
82
|
+
this.appVersion = "1.0";
|
|
83
|
+
this.platform = "PisellOS";
|
|
84
|
+
this.product = "PisellOS";
|
|
85
|
+
}
|
|
86
|
+
javaEnabled() {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var SimpleHistory = class {
|
|
91
|
+
constructor() {
|
|
92
|
+
this.length = 0;
|
|
93
|
+
this.scrollRestoration = "auto";
|
|
94
|
+
this.state = null;
|
|
95
|
+
}
|
|
96
|
+
back() {
|
|
97
|
+
}
|
|
98
|
+
forward() {
|
|
99
|
+
}
|
|
100
|
+
go() {
|
|
101
|
+
}
|
|
102
|
+
pushState() {
|
|
103
|
+
}
|
|
104
|
+
replaceState() {
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var SimpleDocument = class {
|
|
108
|
+
constructor() {
|
|
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
|
+
}
|
|
119
|
+
createElement(tagName) {
|
|
120
|
+
const element = {
|
|
121
|
+
tagName: tagName.toUpperCase(),
|
|
122
|
+
id: "",
|
|
123
|
+
className: "",
|
|
124
|
+
innerHTML: "",
|
|
125
|
+
style: {},
|
|
126
|
+
dataset: {},
|
|
127
|
+
attributes: {},
|
|
128
|
+
children: [],
|
|
129
|
+
parentElement: null,
|
|
130
|
+
addEventListener: () => {
|
|
131
|
+
},
|
|
132
|
+
removeEventListener: () => {
|
|
133
|
+
},
|
|
134
|
+
getAttribute: (name) => element.attributes[name],
|
|
135
|
+
setAttribute: (name, value) => {
|
|
136
|
+
element.attributes[name] = value;
|
|
137
|
+
},
|
|
138
|
+
removeAttribute: (name) => {
|
|
139
|
+
delete element.attributes[name];
|
|
140
|
+
},
|
|
141
|
+
appendChild: (child) => {
|
|
142
|
+
element.children.push(child);
|
|
143
|
+
return child;
|
|
144
|
+
},
|
|
145
|
+
removeChild: (child) => {
|
|
146
|
+
const index = element.children.indexOf(child);
|
|
147
|
+
if (index !== -1) {
|
|
148
|
+
element.children.splice(index, 1);
|
|
149
|
+
}
|
|
150
|
+
return child;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return element;
|
|
154
|
+
}
|
|
155
|
+
getElementById(id) {
|
|
156
|
+
return this.elements[id] || null;
|
|
157
|
+
}
|
|
158
|
+
querySelector() {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
querySelectorAll() {
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
getElementsByTagName() {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
getElementsByClassName() {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var WindowPluginImpl = class {
|
|
172
|
+
constructor() {
|
|
173
|
+
this.name = "window";
|
|
174
|
+
this.version = "1.0.0";
|
|
175
|
+
// 定时器相关
|
|
176
|
+
this.setTimeout = Object.assign(
|
|
177
|
+
function(handler, timeout, ...args) {
|
|
178
|
+
if (typeof globalThis !== "undefined" && globalThis.setTimeout) {
|
|
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
|
+
}
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
this.clearTimeout = function(timeout2) {
|
|
200
|
+
if (typeof globalThis !== "undefined" && globalThis.clearTimeout) {
|
|
201
|
+
globalThis.clearTimeout(timeout2);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
this.setInterval = Object.assign(
|
|
205
|
+
function(handler, timeout, ...args) {
|
|
206
|
+
if (typeof globalThis !== "undefined" && globalThis.setInterval) {
|
|
207
|
+
return globalThis.setInterval(handler, timeout, ...args);
|
|
208
|
+
}
|
|
209
|
+
const intervalId = Date.now();
|
|
210
|
+
const recursiveTimeout = () => {
|
|
211
|
+
this.setTimeout(() => {
|
|
212
|
+
if (typeof handler === "function") {
|
|
213
|
+
handler(...args);
|
|
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
|
+
}
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
this.clearInterval = function(timeout2) {
|
|
230
|
+
if (typeof globalThis !== "undefined" && globalThis.clearInterval) {
|
|
231
|
+
globalThis.clearInterval(timeout2);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
// 存储相关
|
|
235
|
+
this.localStorage = new SimpleStorage();
|
|
236
|
+
this.sessionStorage = new SimpleStorage();
|
|
237
|
+
// 浏览器环境对象
|
|
238
|
+
this.location = new SimpleLocation();
|
|
239
|
+
this.navigator = new SimpleNavigator();
|
|
240
|
+
this.document = new SimpleDocument();
|
|
241
|
+
this.history = new SimpleHistory();
|
|
242
|
+
}
|
|
243
|
+
// 初始化方法
|
|
244
|
+
initialize() {
|
|
245
|
+
console.log("[WindowPlugin] 初始化完成");
|
|
246
|
+
}
|
|
247
|
+
// 销毁方法
|
|
248
|
+
destroy() {
|
|
249
|
+
console.log("[WindowPlugin] 已销毁");
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var window_default = new WindowPluginImpl();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Module, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from "../../modules/BaseModule";
|
|
3
|
+
export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
4
|
+
protected defaultName: string;
|
|
5
|
+
protected defaultVersion: string;
|
|
6
|
+
isSolution: boolean;
|
|
7
|
+
private request;
|
|
8
|
+
private window;
|
|
9
|
+
private store;
|
|
10
|
+
private otherParams;
|
|
11
|
+
initialize(core: PisellCore, options: any): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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/BookingByStep/index.ts
|
|
20
|
+
var BookingByStep_exports = {};
|
|
21
|
+
__export(BookingByStep_exports, {
|
|
22
|
+
BookingByStepImpl: () => BookingByStepImpl
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(BookingByStep_exports);
|
|
25
|
+
var import_BaseModule = require("../../modules/BaseModule");
|
|
26
|
+
var import_types = require("./types");
|
|
27
|
+
var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.defaultName = "bookingByStep";
|
|
31
|
+
this.defaultVersion = "1.0.0";
|
|
32
|
+
this.isSolution = true;
|
|
33
|
+
this.otherParams = {};
|
|
34
|
+
}
|
|
35
|
+
async initialize(core, options) {
|
|
36
|
+
this.core = core;
|
|
37
|
+
this.store = options.store || {};
|
|
38
|
+
this.otherParams = options.otherParams || {};
|
|
39
|
+
console.log("[BuyTickets] 初始化完成");
|
|
40
|
+
this.request = core.getPlugin("request");
|
|
41
|
+
this.window = core.getPlugin("window");
|
|
42
|
+
if (!this.request) {
|
|
43
|
+
throw new Error("tickets解决方案需要 request 插件支持");
|
|
44
|
+
}
|
|
45
|
+
if (this.otherParams.prodctIds) {
|
|
46
|
+
}
|
|
47
|
+
await this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
BookingByStepImpl
|
|
53
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ProductList, CartModule } from "../../modules";
|
|
2
|
+
import { AccountModule } from "../../modules/Account";
|
|
3
|
+
import { DateModule } from "../../modules/Date";
|
|
4
|
+
import { GuestListModule } from "../../modules/Guests";
|
|
5
|
+
import { OrderModule } from "../../modules/Order";
|
|
6
|
+
import { PaymentModule } from "../../modules/Payment";
|
|
7
|
+
import { ResourceListModule } from "../../modules/Resource";
|
|
8
|
+
export interface BookingByStepState {
|
|
9
|
+
cart: CartModule;
|
|
10
|
+
currentStep: number;
|
|
11
|
+
products: ProductList;
|
|
12
|
+
guests: GuestListModule;
|
|
13
|
+
date: DateModule;
|
|
14
|
+
resources: ResourceListModule[];
|
|
15
|
+
account: AccountModule;
|
|
16
|
+
order: OrderModule;
|
|
17
|
+
payment: PaymentModule;
|
|
18
|
+
}
|
|
19
|
+
export declare enum BookingByStepHooks {
|
|
20
|
+
onInited = "bookingByStep:onInited",
|
|
21
|
+
onDestroy = "bookingByStep:onDestroy",
|
|
22
|
+
onProductsLoaded = "bookingByStep:onProductsLoaded",
|
|
23
|
+
onGuestsLoaded = "bookingByStep:onGuestsLoaded",
|
|
24
|
+
onDateLoaded = "bookingByStep:onDateLoaded",
|
|
25
|
+
onResourcesLoaded = "bookingByStep:onResourcesLoaded",
|
|
26
|
+
onAccountLoaded = "bookingByStep:onAccountLoaded"
|
|
27
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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/BookingByStep/types.ts
|
|
20
|
+
var types_exports = {};
|
|
21
|
+
__export(types_exports, {
|
|
22
|
+
BookingByStepHooks: () => BookingByStepHooks
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var BookingByStepHooks = /* @__PURE__ */ ((BookingByStepHooks2) => {
|
|
26
|
+
BookingByStepHooks2["onInited"] = "bookingByStep:onInited";
|
|
27
|
+
BookingByStepHooks2["onDestroy"] = "bookingByStep:onDestroy";
|
|
28
|
+
BookingByStepHooks2["onProductsLoaded"] = "bookingByStep:onProductsLoaded";
|
|
29
|
+
BookingByStepHooks2["onGuestsLoaded"] = "bookingByStep:onGuestsLoaded";
|
|
30
|
+
BookingByStepHooks2["onDateLoaded"] = "bookingByStep:onDateLoaded";
|
|
31
|
+
BookingByStepHooks2["onResourcesLoaded"] = "bookingByStep:onResourcesLoaded";
|
|
32
|
+
BookingByStepHooks2["onAccountLoaded"] = "bookingByStep:onAccountLoaded";
|
|
33
|
+
return BookingByStepHooks2;
|
|
34
|
+
})(BookingByStepHooks || {});
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
BookingByStepHooks
|
|
38
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Module, PisellCore } from '../../types';
|
|
2
|
+
import { Product, ProductData } from '../../modules/';
|
|
3
|
+
import { BaseModule } from '../../modules/BaseModule';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export declare class BuyTicketsImpl extends BaseModule implements Module {
|
|
6
|
+
protected defaultName: string;
|
|
7
|
+
protected defaultVersion: string;
|
|
8
|
+
isSolution: boolean;
|
|
9
|
+
private request;
|
|
10
|
+
private window;
|
|
11
|
+
private store;
|
|
12
|
+
private otherParams;
|
|
13
|
+
constructor(name?: string, version?: string);
|
|
14
|
+
initialize(core: PisellCore, options: any): Promise<void>;
|
|
15
|
+
loadProductsByIds(ids: number[]): Promise<void>;
|
|
16
|
+
loadProductsByCategory(categoryId: number): Promise<void>;
|
|
17
|
+
destroy(): Promise<void>;
|
|
18
|
+
getProducts(): Promise<ProductData[]>;
|
|
19
|
+
getProduct(id: number): Promise<Product>;
|
|
20
|
+
listSubmit(data: Record<string, any>): Promise<{
|
|
21
|
+
status: boolean;
|
|
22
|
+
data: any;
|
|
23
|
+
} | undefined>;
|
|
24
|
+
cartSubmit(data: Record<string, any>): Promise<void>;
|
|
25
|
+
checkoutSubmit(data: Record<string, any>): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/solution/BuyTickets/index.ts
|
|
21
|
+
var BuyTickets_exports = {};
|
|
22
|
+
__export(BuyTickets_exports, {
|
|
23
|
+
BuyTicketsImpl: () => BuyTicketsImpl
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(BuyTickets_exports);
|
|
26
|
+
var import_modules = require("../../modules/");
|
|
27
|
+
var import_types = require("./types");
|
|
28
|
+
var import_BaseModule = require("../../modules/BaseModule");
|
|
29
|
+
__reExport(BuyTickets_exports, require("./types"), module.exports);
|
|
30
|
+
var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
|
|
31
|
+
constructor(name, version) {
|
|
32
|
+
super(name, version);
|
|
33
|
+
// 提供给 baseModule 用的默认名称 和 默认版本
|
|
34
|
+
this.defaultName = "buyTickets";
|
|
35
|
+
this.defaultVersion = "1.0.0";
|
|
36
|
+
this.isSolution = true;
|
|
37
|
+
this.otherParams = {};
|
|
38
|
+
}
|
|
39
|
+
async initialize(core, options) {
|
|
40
|
+
this.core = core;
|
|
41
|
+
this.store = options.store || {};
|
|
42
|
+
this.otherParams = options.otherParams || {};
|
|
43
|
+
console.log("[BuyTickets] 初始化完成");
|
|
44
|
+
this.request = core.getPlugin("request");
|
|
45
|
+
this.window = core.getPlugin("window");
|
|
46
|
+
if (!this.request) {
|
|
47
|
+
throw new Error("购物车模块需要 request 插件支持");
|
|
48
|
+
}
|
|
49
|
+
if (this.otherParams.prodctIds) {
|
|
50
|
+
await this.loadProductsByIds(this.otherParams.prodctIds);
|
|
51
|
+
}
|
|
52
|
+
await this.core.effects.emit(import_types.BuyTicketsHooks.onInited, {});
|
|
53
|
+
}
|
|
54
|
+
// 通过 ids 获取产品,在当前解决方案下,获取到的就是主商品
|
|
55
|
+
async loadProductsByIds(ids) {
|
|
56
|
+
const productsData = await this.request.post(
|
|
57
|
+
`${this.core.context.apiBasePath}/shop/product/query`,
|
|
58
|
+
{
|
|
59
|
+
ids,
|
|
60
|
+
open_quotation: 1,
|
|
61
|
+
open_bundle: 1,
|
|
62
|
+
with: ["bundleGroup.bundleItem"],
|
|
63
|
+
status: "published",
|
|
64
|
+
num: 10,
|
|
65
|
+
skip: 1
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
const mainProducts = new import_modules.ProductList(`product-kiosk-main-list`);
|
|
69
|
+
this.core.registerModule(mainProducts, { initialState: {
|
|
70
|
+
list: productsData.data.list
|
|
71
|
+
} });
|
|
72
|
+
this.store.mainProducts = mainProducts;
|
|
73
|
+
await this.core.effects.emit(import_types.BuyTicketsHooks.onMainProductsLoaded, {});
|
|
74
|
+
}
|
|
75
|
+
// 通过 ids 获取产品,在当前解决方案下,获取到的就是其他商品
|
|
76
|
+
async loadProductsByCategory(categoryId) {
|
|
77
|
+
}
|
|
78
|
+
async destroy() {
|
|
79
|
+
await this.core.effects.emit(import_types.BuyTicketsHooks.onDestroy, {});
|
|
80
|
+
console.log("[BuyTickets] 已销毁");
|
|
81
|
+
}
|
|
82
|
+
// 获取当前绑定的所有商品
|
|
83
|
+
async getProducts() {
|
|
84
|
+
var _a;
|
|
85
|
+
const mainData = await this.store.mainProducts.getProducts() || [];
|
|
86
|
+
const otherData = await ((_a = this.store.otherProducts) == null ? void 0 : _a.getProducts()) || [];
|
|
87
|
+
await this.core.effects.emit(import_types.BuyTicketsHooks.OnGetProducts, [...mainData, ...otherData]);
|
|
88
|
+
return [...mainData, ...otherData];
|
|
89
|
+
}
|
|
90
|
+
// 根据 id 获取商品详情,他会尝试先去主列表里找,找不到再去子列表,还找不到就报错
|
|
91
|
+
async getProduct(id) {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
const mainProduct = await ((_a = this.store.mainProducts) == null ? void 0 : _a.getProduct(id));
|
|
94
|
+
const otherProduct = await ((_b = this.store.otherProducts) == null ? void 0 : _b.getProduct(id));
|
|
95
|
+
if (mainProduct)
|
|
96
|
+
return mainProduct;
|
|
97
|
+
if (otherProduct)
|
|
98
|
+
return otherProduct;
|
|
99
|
+
return Promise.reject("Not fund product for id: " + id);
|
|
100
|
+
}
|
|
101
|
+
// 商品列表页提交
|
|
102
|
+
async listSubmit(data) {
|
|
103
|
+
const res = await this.core.effects.emit(import_types.BuyTicketsHooks.onListSubmit, { ...data, products: this.getProducts() });
|
|
104
|
+
if (res.status === false)
|
|
105
|
+
return res;
|
|
106
|
+
this.window.localStorage.setItem("buyTickets:listSubmit", JSON.stringify({ ...data, products: this.getProducts() }));
|
|
107
|
+
console.log("listSubmit 应该走逻辑层的 API 发请求了");
|
|
108
|
+
}
|
|
109
|
+
// 购物车提交
|
|
110
|
+
async cartSubmit(data) {
|
|
111
|
+
await this.core.effects.emit(import_types.BuyTicketsHooks.onCartSubmit, { ...data, products: this.getProducts() });
|
|
112
|
+
}
|
|
113
|
+
// 结算提交
|
|
114
|
+
async checkoutSubmit(data) {
|
|
115
|
+
await this.core.effects.emit(import_types.BuyTicketsHooks.onCheckoutSubmit, { ...data, products: this.getProducts() });
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
BuyTicketsImpl,
|
|
121
|
+
...require("./types")
|
|
122
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ProductData } from '../../modules';
|
|
2
|
+
import { ProductList } from '../../modules';
|
|
3
|
+
/**
|
|
4
|
+
* 购票流程hook
|
|
5
|
+
*/
|
|
6
|
+
export declare enum BuyTicketsHooks {
|
|
7
|
+
onInited = "buyTickets:onInited",
|
|
8
|
+
onDestroy = "buyTickets:onDestroy",
|
|
9
|
+
onMainProductsLoaded = "buyTickets:onMainProductsLoaded",
|
|
10
|
+
onOtherProductsLoaded = "buyTickets:onOtherProductsLoaded",
|
|
11
|
+
OnGetProducts = "buyTickets:onGetProducts",
|
|
12
|
+
OnGetProduct = "buyTickets:onGetProduct",
|
|
13
|
+
onListSubmit = "buyTickets:onListSubmit",
|
|
14
|
+
onCartSubmit = "buyTickets:onCartubmit",
|
|
15
|
+
onCheckoutSubmit = "buyTickets:onCheckoutSubmit"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 票务状态接口
|
|
19
|
+
*/
|
|
20
|
+
export interface TicketState {
|
|
21
|
+
products: ProductData[];
|
|
22
|
+
mainProducts: ProductList;
|
|
23
|
+
otherProducts: ProductList;
|
|
24
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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/BuyTickets/types.ts
|
|
20
|
+
var types_exports = {};
|
|
21
|
+
__export(types_exports, {
|
|
22
|
+
BuyTicketsHooks: () => BuyTicketsHooks
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var BuyTicketsHooks = /* @__PURE__ */ ((BuyTicketsHooks2) => {
|
|
26
|
+
BuyTicketsHooks2["onInited"] = "buyTickets:onInited";
|
|
27
|
+
BuyTicketsHooks2["onDestroy"] = "buyTickets:onDestroy";
|
|
28
|
+
BuyTicketsHooks2["onMainProductsLoaded"] = "buyTickets:onMainProductsLoaded";
|
|
29
|
+
BuyTicketsHooks2["onOtherProductsLoaded"] = "buyTickets:onOtherProductsLoaded";
|
|
30
|
+
BuyTicketsHooks2["OnGetProducts"] = "buyTickets:onGetProducts";
|
|
31
|
+
BuyTicketsHooks2["OnGetProduct"] = "buyTickets:onGetProduct";
|
|
32
|
+
BuyTicketsHooks2["onListSubmit"] = "buyTickets:onListSubmit";
|
|
33
|
+
BuyTicketsHooks2["onCartSubmit"] = "buyTickets:onCartubmit";
|
|
34
|
+
BuyTicketsHooks2["onCheckoutSubmit"] = "buyTickets:onCheckoutSubmit";
|
|
35
|
+
return BuyTicketsHooks2;
|
|
36
|
+
})(BuyTicketsHooks || {});
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
BuyTicketsHooks
|
|
40
|
+
});
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BuyTickets';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/solution/index.ts
|
|
17
|
+
var solution_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(solution_exports);
|
|
19
|
+
__reExport(solution_exports, require("./BuyTickets"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./BuyTickets")
|
|
23
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
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/store/createStore.ts
|
|
20
|
+
var createStore_exports = {};
|
|
21
|
+
__export(createStore_exports, {
|
|
22
|
+
createStore: () => createStore
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(createStore_exports);
|
|
25
|
+
function createStore(initialState, moduleName, onChange) {
|
|
26
|
+
const handler = {
|
|
27
|
+
get(target, prop, receiver) {
|
|
28
|
+
const value = Reflect.get(target, prop, receiver);
|
|
29
|
+
return value;
|
|
30
|
+
},
|
|
31
|
+
set(target, prop, value, receiver) {
|
|
32
|
+
const result = Reflect.set(target, prop, value, receiver);
|
|
33
|
+
onChange == null ? void 0 : onChange(`${moduleName}.${String(prop)}`, value);
|
|
34
|
+
return result;
|
|
35
|
+
},
|
|
36
|
+
deleteProperty(target, prop) {
|
|
37
|
+
return Reflect.deleteProperty(target, prop);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const proxy = new Proxy(initialState, handler);
|
|
41
|
+
return { proxy };
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
createStore
|
|
46
|
+
});
|