@pisell/pisellos 0.0.207 → 0.0.209
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 +1 -1
- package/dist/modules/Cart/index.d.ts +1 -0
- package/dist/modules/Cart/index.js +42 -14
- package/dist/modules/Cart/utils/changePrice.d.ts +1 -1
- package/dist/modules/Cart/utils/changePrice.js +8 -3
- package/dist/modules/Order/index.js +2 -2
- package/dist/modules/Rules/index.js +5 -5
- 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 -0
- package/dist/solution/BookingByStep/index.js +10 -5
- 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/lib/core/index.js +28 -27
- package/lib/effects/index.d.ts +1 -1
- package/lib/effects/index.js +7 -3
- package/lib/modules/Account/index.js +10 -9
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.js +3 -6
- package/lib/modules/Cart/index.d.ts +1 -0
- package/lib/modules/Cart/index.js +19 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Cart/utils/changePrice.d.ts +1 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -1
- package/lib/modules/Date/index.js +4 -8
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +6 -11
- package/lib/modules/Guests/index.js +15 -10
- package/lib/modules/Order/index.js +4 -6
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +86 -98
- package/lib/modules/Payment/wallet.js +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +4 -5
- package/lib/modules/Resource/index.js +12 -8
- package/lib/modules/Rules/index.js +17 -14
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +79 -53
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/timeslots.js +12 -6
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/ShopDiscount/index.js +11 -15
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -26,14 +26,13 @@ module.exports = __toCommonJS(Product_exports);
|
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
27
|
__reExport(Product_exports, require("./types"), module.exports);
|
|
28
28
|
var Product = class extends import_BaseModule.BaseModule {
|
|
29
|
-
defaultName = "product";
|
|
30
|
-
defaultVersion = "1.0.0";
|
|
31
|
-
store;
|
|
32
|
-
otherParams = {
|
|
33
|
-
scheduler: []
|
|
34
|
-
};
|
|
35
29
|
constructor(name, version) {
|
|
36
30
|
super(name, version);
|
|
31
|
+
this.defaultName = "product";
|
|
32
|
+
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.otherParams = {
|
|
34
|
+
scheduler: []
|
|
35
|
+
};
|
|
37
36
|
}
|
|
38
37
|
async initialize(core, options) {
|
|
39
38
|
this.core = core;
|
|
@@ -29,12 +29,10 @@ var import_types = require("./types");
|
|
|
29
29
|
var import_lodash_es = require("lodash-es");
|
|
30
30
|
__reExport(ProductList_exports, require("./types"), module.exports);
|
|
31
31
|
var ProductList = class extends import_BaseModule.BaseModule {
|
|
32
|
-
defaultName = "productList";
|
|
33
|
-
defaultVersion = "1.0.0";
|
|
34
|
-
store;
|
|
35
|
-
request;
|
|
36
32
|
constructor(name, version) {
|
|
37
33
|
super(name, version);
|
|
34
|
+
this.defaultName = "productList";
|
|
35
|
+
this.defaultVersion = "1.0.0";
|
|
38
36
|
}
|
|
39
37
|
async initialize(core, options) {
|
|
40
38
|
var _a;
|
|
@@ -142,7 +140,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
142
140
|
this.store.list
|
|
143
141
|
);
|
|
144
142
|
const product = this.store.productMap.get(`${id}`);
|
|
145
|
-
if (product)
|
|
143
|
+
if (product)
|
|
144
|
+
return product;
|
|
146
145
|
return void 0;
|
|
147
146
|
}
|
|
148
147
|
async addProduct(products) {
|
|
@@ -25,11 +25,10 @@ module.exports = __toCommonJS(Resource_exports);
|
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
26
|
var import_types = require("./types");
|
|
27
27
|
var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
28
|
-
defaultName = "resourceList";
|
|
29
|
-
defaultVersion = "1.0.0";
|
|
30
|
-
store;
|
|
31
28
|
constructor(name, version) {
|
|
32
29
|
super(name, version);
|
|
30
|
+
this.defaultName = "resourceList";
|
|
31
|
+
this.defaultVersion = "1.0.0";
|
|
33
32
|
}
|
|
34
33
|
async initialize(core, options) {
|
|
35
34
|
this.core = core;
|
|
@@ -40,7 +39,8 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
40
39
|
}
|
|
41
40
|
async selectResource(resourceId) {
|
|
42
41
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
43
|
-
if (!resource)
|
|
42
|
+
if (!resource)
|
|
43
|
+
return;
|
|
44
44
|
this.store.selectedResource = resource;
|
|
45
45
|
await this.core.effects.emit(import_types.ResourceHooks.OnResourceSelect, resource);
|
|
46
46
|
}
|
|
@@ -49,19 +49,22 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
49
49
|
}
|
|
50
50
|
async checkAvailability(resourceId, start, end) {
|
|
51
51
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
52
|
-
if (!resource)
|
|
52
|
+
if (!resource)
|
|
53
|
+
return false;
|
|
53
54
|
return resource.timeSlots.some(
|
|
54
55
|
(slot) => slot.start.getTime() <= start.getTime() && slot.end.getTime() >= end.getTime() && slot.availableCapacity > 0
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
async getAvailableTimeSlots(resourceId) {
|
|
58
59
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
59
|
-
if (!resource)
|
|
60
|
+
if (!resource)
|
|
61
|
+
return [];
|
|
60
62
|
return resource.timeSlots.filter((slot) => slot.availableCapacity > 0);
|
|
61
63
|
}
|
|
62
64
|
getAvailableCapacity(resourceId, timeSlot) {
|
|
63
65
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
64
|
-
if (!resource)
|
|
66
|
+
if (!resource)
|
|
67
|
+
return 0;
|
|
65
68
|
const slot = resource.timeSlots.find(
|
|
66
69
|
(s) => s.start.getTime() === timeSlot.start.getTime() && s.end.getTime() === timeSlot.end.getTime()
|
|
67
70
|
);
|
|
@@ -69,7 +72,8 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
69
72
|
}
|
|
70
73
|
async updateResource(resourceId, updates) {
|
|
71
74
|
const index = this.store.list.findIndex((r) => r.id === resourceId);
|
|
72
|
-
if (index === -1)
|
|
75
|
+
if (index === -1)
|
|
76
|
+
return;
|
|
73
77
|
this.store.list[index] = {
|
|
74
78
|
...this.store.list[index],
|
|
75
79
|
...updates
|
|
@@ -38,12 +38,10 @@ var import_utils = require("../../solution/ShopDiscount/utils");
|
|
|
38
38
|
var import_utils2 = require("../Cart/utils");
|
|
39
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
40
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
41
|
-
defaultName = "rules";
|
|
42
|
-
defaultVersion = "1.0.0";
|
|
43
|
-
store;
|
|
44
|
-
hooks;
|
|
45
41
|
constructor(name, version) {
|
|
46
42
|
super(name, version);
|
|
43
|
+
this.defaultName = "rules";
|
|
44
|
+
this.defaultVersion = "1.0.0";
|
|
47
45
|
this.hooks = {};
|
|
48
46
|
}
|
|
49
47
|
async initialize(core, options) {
|
|
@@ -133,8 +131,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
133
131
|
return !discount.isManualSelect;
|
|
134
132
|
});
|
|
135
133
|
const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
|
|
136
|
-
if (a.tag === "good_pass" && b.tag !== "good_pass")
|
|
137
|
-
|
|
134
|
+
if (a.tag === "good_pass" && b.tag !== "good_pass")
|
|
135
|
+
return -1;
|
|
136
|
+
if (b.tag === "good_pass" && a.tag !== "good_pass")
|
|
137
|
+
return 1;
|
|
138
138
|
if (a.tag === "good_pass" && b.tag === "good_pass") {
|
|
139
139
|
return compareByExpireTime(a, b);
|
|
140
140
|
} else if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
|
|
@@ -215,13 +215,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
215
215
|
}
|
|
216
216
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
217
217
|
var _a2;
|
|
218
|
-
if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
|
|
218
|
+
if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
|
|
219
|
+
return false;
|
|
219
220
|
if ((Number(product.total) === 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
|
|
220
221
|
var _a3;
|
|
221
222
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
222
|
-
})) && (discount.tag || discount.type) !== "good_pass")
|
|
223
|
+
})) && (discount.tag || discount.type) !== "good_pass")
|
|
224
|
+
return false;
|
|
223
225
|
const targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
224
|
-
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|
|
226
|
+
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|
|
227
|
+
return false;
|
|
225
228
|
const limitedData = discount.limited_relation_product_data;
|
|
226
229
|
if (limitedData.type === "product_all") {
|
|
227
230
|
return true;
|
|
@@ -299,12 +302,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
299
302
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
300
303
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
301
304
|
let productOriginTotal = product.origin_total || product.total || 0;
|
|
302
|
-
if (
|
|
303
|
-
productOriginTotal = product.total;
|
|
304
|
-
}
|
|
305
|
-
if (((_h = product.discount_list) == null ? void 0 : _h.length) && product.origin_total) {
|
|
305
|
+
if (((_g = product.discount_list) == null ? void 0 : _g.length) && product.origin_total) {
|
|
306
306
|
productOriginTotal = product.origin_total;
|
|
307
307
|
}
|
|
308
|
+
if (Number(((_h = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _h.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
309
|
+
productOriginTotal = product.total;
|
|
310
|
+
}
|
|
308
311
|
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
|
|
309
312
|
const discountDetail = {
|
|
310
313
|
amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
|
|
@@ -450,7 +453,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
450
453
|
async destroy() {
|
|
451
454
|
this.core.effects.offByModuleDestroy(this.name);
|
|
452
455
|
await this.core.effects.emit(import_types.RulesHooks.OnDestroy, {});
|
|
453
|
-
console.log("[Rules]
|
|
456
|
+
console.log("[Rules] 已销毁");
|
|
454
457
|
}
|
|
455
458
|
async clear() {
|
|
456
459
|
console.log("[Rules] clear");
|
|
@@ -41,22 +41,19 @@ var import_utils = require("../Date/utils");
|
|
|
41
41
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
42
42
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
43
43
|
var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
44
|
-
defaultName = "schedule";
|
|
45
|
-
defaultVersion = "1.0.0";
|
|
46
|
-
request;
|
|
47
|
-
store = {};
|
|
48
|
-
cacheId;
|
|
49
|
-
openCache = false;
|
|
50
|
-
fatherModule;
|
|
51
44
|
constructor(name, version) {
|
|
52
45
|
super(name, version);
|
|
46
|
+
this.defaultName = "schedule";
|
|
47
|
+
this.defaultVersion = "1.0.0";
|
|
48
|
+
this.store = {};
|
|
49
|
+
this.openCache = false;
|
|
53
50
|
}
|
|
54
51
|
async initialize(core, options) {
|
|
55
52
|
var _a, _b;
|
|
56
53
|
this.core = core;
|
|
57
54
|
this.request = core.getPlugin("request");
|
|
58
55
|
if (!this.request) {
|
|
59
|
-
throw new Error("ScheduleModule
|
|
56
|
+
throw new Error("ScheduleModule 需要 request 插件支持");
|
|
60
57
|
}
|
|
61
58
|
this.store = options == null ? void 0 : options.store;
|
|
62
59
|
if (options.initialState) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ScheduleItem = {
|
|
2
2
|
/** 颜色 */
|
|
3
3
|
color: string;
|
|
4
4
|
/** 创建时间 */
|
|
@@ -65,7 +65,7 @@ export declare type ScheduleItem = {
|
|
|
65
65
|
schedule_id: number;
|
|
66
66
|
}[];
|
|
67
67
|
};
|
|
68
|
-
export
|
|
68
|
+
export type ScheduleFormOtherValue = {
|
|
69
69
|
/** 截止模式
|
|
70
70
|
* 1: 永不截止
|
|
71
71
|
* 2: 按日期截止
|
|
@@ -79,11 +79,11 @@ export declare type ScheduleFormOtherValue = {
|
|
|
79
79
|
includeStatus: boolean;
|
|
80
80
|
type: 'standard' | 'time-slots' | 'designation';
|
|
81
81
|
};
|
|
82
|
-
export
|
|
82
|
+
export type ExcIncDate = {
|
|
83
83
|
start: string;
|
|
84
84
|
end: string;
|
|
85
85
|
};
|
|
86
|
-
export
|
|
86
|
+
export type ScheduleFormData = {
|
|
87
87
|
/** 颜色 */
|
|
88
88
|
color: string;
|
|
89
89
|
/** 日程名称 */
|
|
@@ -131,20 +131,20 @@ export declare type ScheduleFormData = {
|
|
|
131
131
|
start_time: any;
|
|
132
132
|
end_time: any;
|
|
133
133
|
};
|
|
134
|
-
export
|
|
134
|
+
export type CalendarDataItem = {
|
|
135
135
|
date: string;
|
|
136
136
|
color: string[];
|
|
137
137
|
isExcluded: boolean;
|
|
138
138
|
schedule_ids?: number[];
|
|
139
139
|
[key: string]: any;
|
|
140
140
|
};
|
|
141
|
-
export
|
|
141
|
+
export type RequestData<Data> = {
|
|
142
142
|
data: Data;
|
|
143
143
|
status: boolean;
|
|
144
144
|
message: string;
|
|
145
145
|
code: number;
|
|
146
146
|
};
|
|
147
|
-
export
|
|
147
|
+
export type ResponseListData<Data> = {
|
|
148
148
|
status: boolean;
|
|
149
149
|
message: string;
|
|
150
150
|
code: number;
|
|
@@ -4,7 +4,7 @@ export interface ScheduleState {
|
|
|
4
4
|
availabilityDateList: ScheduleAvailabilityDateItem[];
|
|
5
5
|
otherProductsIds: number[];
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type ScheduleAvailabilityDateItem = {
|
|
8
8
|
date: string;
|
|
9
9
|
schedule_id: number[];
|
|
10
10
|
product_ids: number[];
|
|
@@ -24,7 +24,7 @@ export interface LoadScheduleAvailableDateParams {
|
|
|
24
24
|
}
|
|
25
25
|
export interface ScheduleModuleAPI {
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type ScheduleItem = {
|
|
28
28
|
/** 颜色 */
|
|
29
29
|
color: string;
|
|
30
30
|
/** 创建时间 */
|
|
@@ -91,7 +91,7 @@ export declare type ScheduleItem = {
|
|
|
91
91
|
schedule_id: number;
|
|
92
92
|
}[];
|
|
93
93
|
};
|
|
94
|
-
export
|
|
94
|
+
export type ScheduleFormOtherValue = {
|
|
95
95
|
/** 截止模式
|
|
96
96
|
* 1: 永不截止
|
|
97
97
|
* 2: 按日期截止
|
|
@@ -105,11 +105,11 @@ export declare type ScheduleFormOtherValue = {
|
|
|
105
105
|
includeStatus: boolean;
|
|
106
106
|
type: 'standard' | 'time-slots' | 'designation';
|
|
107
107
|
};
|
|
108
|
-
export
|
|
108
|
+
export type ExcIncDate = {
|
|
109
109
|
start: string;
|
|
110
110
|
end: string;
|
|
111
111
|
};
|
|
112
|
-
export
|
|
112
|
+
export type ScheduleFormData = {
|
|
113
113
|
/** 颜色 */
|
|
114
114
|
color: string;
|
|
115
115
|
/** 日程名称 */
|
|
@@ -157,20 +157,20 @@ export declare type ScheduleFormData = {
|
|
|
157
157
|
start_time: any;
|
|
158
158
|
end_time: any;
|
|
159
159
|
};
|
|
160
|
-
export
|
|
160
|
+
export type CalendarDataItem = {
|
|
161
161
|
date: string;
|
|
162
162
|
color: string[];
|
|
163
163
|
isExcluded: boolean;
|
|
164
164
|
schedule_ids?: number[];
|
|
165
165
|
[key: string]: any;
|
|
166
166
|
};
|
|
167
|
-
export
|
|
167
|
+
export type RequestData<Data> = {
|
|
168
168
|
data: Data;
|
|
169
169
|
status: boolean;
|
|
170
170
|
message: string;
|
|
171
171
|
code: number;
|
|
172
172
|
};
|
|
173
|
-
export
|
|
173
|
+
export type ResponseListData<Data> = {
|
|
174
174
|
status: boolean;
|
|
175
175
|
message: string;
|
|
176
176
|
code: number;
|
|
@@ -181,7 +181,7 @@ export declare type ResponseListData<Data> = {
|
|
|
181
181
|
skip: number;
|
|
182
182
|
};
|
|
183
183
|
};
|
|
184
|
-
export
|
|
184
|
+
export type ScheduleAllMap = Record<string, {
|
|
185
185
|
minTime: dayjs.Dayjs | null;
|
|
186
186
|
maxTime: dayjs.Dayjs | null;
|
|
187
187
|
minTimeStr: string | null;
|
|
@@ -343,7 +343,8 @@ var calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
|
|
|
343
343
|
time_slot
|
|
344
344
|
} = values;
|
|
345
345
|
const { endRadio, excludedStatus, includeStatus } = others;
|
|
346
|
-
if (!start_time)
|
|
346
|
+
if (!start_time)
|
|
347
|
+
return [];
|
|
347
348
|
const start = (0, import_dayjs.default)(start_time);
|
|
348
349
|
const end = (0, import_dayjs.default)(start_time);
|
|
349
350
|
return processDateRange(
|
|
@@ -577,7 +578,8 @@ function getAllSortedDateRanges(schedules) {
|
|
|
577
578
|
}
|
|
578
579
|
let sortedDateRanges = allDateRanges.sort((a, b) => {
|
|
579
580
|
const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
580
|
-
if (startTimeCompare !== 0)
|
|
581
|
+
if (startTimeCompare !== 0)
|
|
582
|
+
return startTimeCompare;
|
|
581
583
|
const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
|
|
582
584
|
const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
583
585
|
return durationA - durationB;
|
|
@@ -24,14 +24,11 @@ __export(Step_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(Step_exports);
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
26
|
var StepModule = class extends import_BaseModule.BaseModule {
|
|
27
|
-
defaultName = "step";
|
|
28
|
-
defaultVersion = "1.0.0";
|
|
29
|
-
store;
|
|
30
|
-
cacheId;
|
|
31
|
-
openCache = false;
|
|
32
|
-
fatherModule;
|
|
33
27
|
constructor(name, version) {
|
|
34
28
|
super(name, version);
|
|
29
|
+
this.defaultName = "step";
|
|
30
|
+
this.defaultVersion = "1.0.0";
|
|
31
|
+
this.openCache = false;
|
|
35
32
|
}
|
|
36
33
|
async initialize(core, options) {
|
|
37
34
|
var _a, _b;
|
|
@@ -116,7 +113,7 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
116
113
|
let stepList = this.store.stepList;
|
|
117
114
|
const index = stepList.findIndex((n) => n.key === step.key);
|
|
118
115
|
if (index !== -1) {
|
|
119
|
-
console.log("[StepModule]
|
|
116
|
+
console.log("[StepModule] 步骤已存在,添加失败");
|
|
120
117
|
return;
|
|
121
118
|
}
|
|
122
119
|
if (key) {
|
|
@@ -25,16 +25,11 @@ module.exports = __toCommonJS(Summary_exports);
|
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
26
|
var import_utils = require("./utils");
|
|
27
27
|
var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
28
|
-
defaultName = "summary";
|
|
29
|
-
defaultVersion = "1.0.0";
|
|
30
|
-
shopStore;
|
|
31
|
-
store;
|
|
32
|
-
request;
|
|
33
|
-
cacheId;
|
|
34
|
-
openCache = false;
|
|
35
|
-
fatherModule;
|
|
36
28
|
constructor(name, version) {
|
|
37
29
|
super(name, version);
|
|
30
|
+
this.defaultName = "summary";
|
|
31
|
+
this.defaultVersion = "1.0.0";
|
|
32
|
+
this.openCache = false;
|
|
38
33
|
}
|
|
39
34
|
async initialize(core, options) {
|
|
40
35
|
var _a, _b;
|
|
@@ -53,7 +48,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
53
48
|
this.fatherModule = options.otherParams.fatherModule;
|
|
54
49
|
}
|
|
55
50
|
if (!this.shopStore) {
|
|
56
|
-
throw new Error("SummaryModule
|
|
51
|
+
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
57
52
|
}
|
|
58
53
|
}
|
|
59
54
|
async getSummary(cartItems) {
|
package/lib/plugins/request.js
CHANGED
|
@@ -24,9 +24,6 @@ __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;
|
|
30
27
|
constructor(message, config, request, response) {
|
|
31
28
|
super(message);
|
|
32
29
|
this.name = "RequestError";
|
|
@@ -36,36 +33,38 @@ var RequestError = class extends Error {
|
|
|
36
33
|
}
|
|
37
34
|
};
|
|
38
35
|
var RequestPluginImpl = class {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
constructor() {
|
|
37
|
+
this.name = "request";
|
|
38
|
+
this.version = "1.0.0";
|
|
39
|
+
this.core = null;
|
|
40
|
+
/**
|
|
41
|
+
* 默认请求选项
|
|
42
|
+
*/
|
|
43
|
+
this.defaultOptions = {
|
|
44
|
+
method: "GET",
|
|
45
|
+
headers: {
|
|
46
|
+
"Content-Type": "application/json"
|
|
47
|
+
},
|
|
48
|
+
timeout: 3e4,
|
|
49
|
+
responseType: "json"
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 全局拦截器
|
|
53
|
+
*/
|
|
54
|
+
this.interceptors = {
|
|
55
|
+
request: [],
|
|
56
|
+
response: [],
|
|
57
|
+
error: []
|
|
58
|
+
};
|
|
59
|
+
}
|
|
61
60
|
// 初始化方法
|
|
62
61
|
initialize() {
|
|
63
62
|
this.core = globalThis.pisellOS;
|
|
64
|
-
console.log("[RequestPlugin]
|
|
63
|
+
console.log("[RequestPlugin] 初始化完成");
|
|
65
64
|
}
|
|
66
65
|
// 销毁方法
|
|
67
66
|
destroy() {
|
|
68
|
-
console.log("[RequestPlugin]
|
|
67
|
+
console.log("[RequestPlugin] 已销毁");
|
|
69
68
|
}
|
|
70
69
|
/**
|
|
71
70
|
* 添加请求拦截器
|
|
@@ -150,7 +149,7 @@ var RequestPluginImpl = class {
|
|
|
150
149
|
config = await Promise.resolve(interceptor(config));
|
|
151
150
|
} catch (error) {
|
|
152
151
|
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
153
|
-
error instanceof Error ? error.message : "
|
|
152
|
+
error instanceof Error ? error.message : "请求拦截器错误",
|
|
154
153
|
config
|
|
155
154
|
);
|
|
156
155
|
let processedError = requestError;
|
|
@@ -175,7 +174,7 @@ var RequestPluginImpl = class {
|
|
|
175
174
|
);
|
|
176
175
|
} catch (error) {
|
|
177
176
|
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
178
|
-
error instanceof Error ? error.message : "
|
|
177
|
+
error instanceof Error ? error.message : "响应拦截器错误",
|
|
179
178
|
config,
|
|
180
179
|
null,
|
|
181
180
|
response
|
|
@@ -195,7 +194,7 @@ var RequestPluginImpl = class {
|
|
|
195
194
|
return processedResponse.data;
|
|
196
195
|
} catch (error) {
|
|
197
196
|
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
198
|
-
error instanceof Error ? error.message : "
|
|
197
|
+
error instanceof Error ? error.message : "请求错误",
|
|
199
198
|
config
|
|
200
199
|
);
|
|
201
200
|
let processedError = requestError;
|
|
@@ -226,7 +225,7 @@ var RequestPluginImpl = class {
|
|
|
226
225
|
withCredentials
|
|
227
226
|
} = config;
|
|
228
227
|
if (!url) {
|
|
229
|
-
throw new RequestError("URL
|
|
228
|
+
throw new RequestError("URL不能为空", config);
|
|
230
229
|
}
|
|
231
230
|
let fullUrl = url;
|
|
232
231
|
if (params && Object.keys(params).length > 0) {
|
|
@@ -256,13 +255,13 @@ var RequestPluginImpl = class {
|
|
|
256
255
|
const timeoutPromise = new Promise((_, reject) => {
|
|
257
256
|
if (timeout) {
|
|
258
257
|
timeoutId = setTimeout(() => {
|
|
259
|
-
reject(new RequestError(
|
|
258
|
+
reject(new RequestError(`请求超时: ${timeout}ms`, config));
|
|
260
259
|
}, timeout);
|
|
261
260
|
}
|
|
262
261
|
});
|
|
263
262
|
try {
|
|
264
263
|
const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(
|
|
265
|
-
new RequestError("
|
|
264
|
+
new RequestError("当前环境不支持 fetch API", config)
|
|
266
265
|
);
|
|
267
266
|
const response = await Promise.race([fetchPromise, timeoutPromise]);
|
|
268
267
|
const responseHeaders = {};
|
|
@@ -298,7 +297,7 @@ var RequestPluginImpl = class {
|
|
|
298
297
|
};
|
|
299
298
|
if (!response.ok) {
|
|
300
299
|
throw new RequestError(
|
|
301
|
-
|
|
300
|
+
`请求失败,状态码: ${response.status}`,
|
|
302
301
|
config,
|
|
303
302
|
fetchOptions,
|
|
304
303
|
result
|