@pisell/pisellos 0.0.15 → 0.0.16
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/modules/AccountList/index.d.ts +5 -1
- package/dist/modules/AccountList/index.js +82 -36
- package/dist/modules/AccountList/types.d.ts +1 -0
- package/dist/modules/BaseModule.d.ts +6 -0
- package/dist/modules/BaseModule.js +41 -0
- package/dist/modules/Cart/index.d.ts +4 -0
- package/dist/modules/Cart/index.js +33 -6
- package/dist/modules/Date/index.d.ts +5 -0
- package/dist/modules/Date/index.js +35 -2
- package/dist/modules/Discount/index.d.ts +4 -0
- package/dist/modules/Discount/index.js +32 -4
- package/dist/modules/Discount/types.d.ts +3 -0
- package/dist/modules/Rules/index.js +7 -4
- package/dist/modules/Step/index.d.ts +4 -0
- package/dist/modules/Step/index.js +29 -1
- package/dist/modules/Summary/index.d.ts +4 -0
- package/dist/modules/Summary/index.js +28 -2
- package/dist/solution/BookingByStep/index.d.ts +12 -1
- package/dist/solution/BookingByStep/index.js +112 -17
- package/dist/solution/BookingByStep/types.js +0 -3
- package/dist/solution/ShopDiscount/index.js +24 -3
- package/lib/modules/AccountList/index.d.ts +5 -1
- package/lib/modules/AccountList/index.js +33 -1
- package/lib/modules/AccountList/types.d.ts +1 -0
- package/lib/modules/BaseModule.d.ts +6 -0
- package/lib/modules/BaseModule.js +37 -0
- package/lib/modules/Cart/index.d.ts +4 -0
- package/lib/modules/Cart/index.js +19 -1
- package/lib/modules/Date/index.d.ts +5 -0
- package/lib/modules/Date/index.js +21 -0
- package/lib/modules/Discount/index.d.ts +4 -0
- package/lib/modules/Discount/index.js +19 -0
- package/lib/modules/Discount/types.d.ts +3 -0
- package/lib/modules/Rules/index.js +9 -4
- package/lib/modules/Step/index.d.ts +4 -0
- package/lib/modules/Step/index.js +19 -0
- package/lib/modules/Summary/index.d.ts +4 -0
- package/lib/modules/Summary/index.js +17 -0
- package/lib/solution/BookingByStep/index.d.ts +12 -1
- package/lib/solution/BookingByStep/index.js +55 -5
- package/lib/solution/BookingByStep/types.js +0 -3
- package/lib/solution/ShopDiscount/index.js +21 -3
- package/package.json +1 -1
|
@@ -11,6 +11,9 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
11
11
|
private request;
|
|
12
12
|
private window;
|
|
13
13
|
private store;
|
|
14
|
+
private cacheId;
|
|
15
|
+
private openCache;
|
|
16
|
+
private fatherModule;
|
|
14
17
|
constructor(name?: string, version?: string);
|
|
15
18
|
/**
|
|
16
19
|
* 初始化购物车模块
|
|
@@ -56,4 +59,5 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
56
59
|
* 清除购物车
|
|
57
60
|
*/
|
|
58
61
|
clear(): void;
|
|
62
|
+
storeChange(): void;
|
|
59
63
|
}
|
|
@@ -33,14 +33,27 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
33
33
|
// 提供给 baseModule 用的默认名称 和 默认版本
|
|
34
34
|
this.defaultName = "cart";
|
|
35
35
|
this.defaultVersion = "1.0.0";
|
|
36
|
+
this.openCache = false;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* 初始化购物车模块
|
|
39
40
|
*/
|
|
40
41
|
async initialize(core, options) {
|
|
42
|
+
var _a, _b, _c;
|
|
41
43
|
this.core = core;
|
|
42
44
|
this.store = options.store;
|
|
43
|
-
|
|
45
|
+
if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
|
|
46
|
+
this.store.list = options.initialState.list;
|
|
47
|
+
} else {
|
|
48
|
+
this.store.list = [];
|
|
49
|
+
}
|
|
50
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.cacheId) {
|
|
51
|
+
this.openCache = options.otherParams.openCache;
|
|
52
|
+
this.cacheId = options.otherParams.cacheId;
|
|
53
|
+
}
|
|
54
|
+
if ((_c = options.otherParams) == null ? void 0 : _c.fatherModule) {
|
|
55
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
56
|
+
}
|
|
44
57
|
this.request = core.getPlugin("request");
|
|
45
58
|
this.window = core.getPlugin("window");
|
|
46
59
|
if (!this.request) {
|
|
@@ -172,6 +185,11 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
172
185
|
clear() {
|
|
173
186
|
this.store.list = [];
|
|
174
187
|
}
|
|
188
|
+
storeChange() {
|
|
189
|
+
if (this.openCache) {
|
|
190
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["list"] });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
175
193
|
};
|
|
176
194
|
// Annotate the CommonJS export names for ESM import in node:
|
|
177
195
|
0 && (module.exports = {
|
|
@@ -6,6 +6,9 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
6
6
|
protected defaultVersion: string;
|
|
7
7
|
private store;
|
|
8
8
|
private request;
|
|
9
|
+
private cacheId;
|
|
10
|
+
private openCache;
|
|
11
|
+
private fatherModule;
|
|
9
12
|
constructor(name?: string, version?: string);
|
|
10
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
11
14
|
setDateRange(dateRange: ITime[]): void;
|
|
@@ -13,4 +16,6 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
13
16
|
getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
14
17
|
getDateList(): Promise<ITime[]>;
|
|
15
18
|
getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
19
|
+
clearDateRange(): void;
|
|
20
|
+
storeChange(): void;
|
|
16
21
|
}
|
|
@@ -40,14 +40,27 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
40
40
|
super(name, version);
|
|
41
41
|
this.defaultName = "date";
|
|
42
42
|
this.defaultVersion = "1.0.0";
|
|
43
|
+
this.openCache = false;
|
|
43
44
|
}
|
|
44
45
|
async initialize(core, options) {
|
|
46
|
+
var _a, _b;
|
|
45
47
|
this.core = core;
|
|
46
48
|
this.store = options.store;
|
|
47
49
|
this.request = this.core.getPlugin("request");
|
|
50
|
+
if (options.initialState) {
|
|
51
|
+
this.store.dateRange = options.initialState.dateRange;
|
|
52
|
+
this.store.dateList = options.initialState.dateList;
|
|
53
|
+
}
|
|
48
54
|
if (!this.request) {
|
|
49
55
|
throw new Error("DateModule 需要 request 插件支持");
|
|
50
56
|
}
|
|
57
|
+
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
58
|
+
this.openCache = options.otherParams.openCache;
|
|
59
|
+
this.cacheId = options.otherParams.cacheId;
|
|
60
|
+
}
|
|
61
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
|
|
62
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
63
|
+
}
|
|
51
64
|
}
|
|
52
65
|
setDateRange(dateRange) {
|
|
53
66
|
this.store.dateRange = dateRange;
|
|
@@ -90,6 +103,14 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
90
103
|
return (0, import_utils.disableAllDates)(dates);
|
|
91
104
|
}
|
|
92
105
|
}
|
|
106
|
+
clearDateRange() {
|
|
107
|
+
this.store.dateRange = [];
|
|
108
|
+
}
|
|
109
|
+
storeChange() {
|
|
110
|
+
if (this.openCache) {
|
|
111
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["dateRange", "dateList"] });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
93
114
|
};
|
|
94
115
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
116
|
0 && (module.exports = {
|
|
@@ -7,6 +7,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
7
7
|
private request;
|
|
8
8
|
private window;
|
|
9
9
|
private store;
|
|
10
|
+
private cacheId;
|
|
11
|
+
private openCache;
|
|
12
|
+
private fatherModule;
|
|
10
13
|
constructor(name?: string, version?: string);
|
|
11
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
12
15
|
setDiscountList(discountList: Discount[]): Promise<void>;
|
|
@@ -23,4 +26,5 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
23
26
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number;
|
|
24
27
|
destroy(): Promise<void>;
|
|
25
28
|
clear(): Promise<void>;
|
|
29
|
+
storeChange(): void;
|
|
26
30
|
}
|
|
@@ -30,10 +30,24 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
30
30
|
super(name, version);
|
|
31
31
|
this.defaultName = "discount";
|
|
32
32
|
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.openCache = false;
|
|
33
34
|
}
|
|
34
35
|
async initialize(core, options) {
|
|
36
|
+
var _a, _b, _c;
|
|
35
37
|
this.core = core;
|
|
36
38
|
this.store = options == null ? void 0 : options.store;
|
|
39
|
+
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.discountList)) {
|
|
40
|
+
this.store.discountList = options == null ? void 0 : options.initialState.discountList;
|
|
41
|
+
} else {
|
|
42
|
+
this.store.discountList = [];
|
|
43
|
+
}
|
|
44
|
+
if ((_b = options == null ? void 0 : options.otherParams) == null ? void 0 : _b.cacheId) {
|
|
45
|
+
this.openCache = options.otherParams.openCache;
|
|
46
|
+
this.cacheId = options.otherParams.cacheId;
|
|
47
|
+
}
|
|
48
|
+
if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.fatherModule) {
|
|
49
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
50
|
+
}
|
|
37
51
|
this.request = core.getPlugin("request");
|
|
38
52
|
this.window = core.getPlugin("window");
|
|
39
53
|
if (!this.request) {
|
|
@@ -111,6 +125,11 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
111
125
|
this.store.discountList = [];
|
|
112
126
|
console.log("[Discount] clear");
|
|
113
127
|
}
|
|
128
|
+
storeChange() {
|
|
129
|
+
if (this.openCache) {
|
|
130
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["discountList"] });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
114
133
|
};
|
|
115
134
|
// Annotate the CommonJS export names for ESM import in node:
|
|
116
135
|
0 && (module.exports = {
|
|
@@ -71,7 +71,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
71
71
|
const { discount_list } = this.hooks.getProduct(product);
|
|
72
72
|
if (discount_list && discount_list.length > 0) {
|
|
73
73
|
const usedNewDiscount = discount_list.some(
|
|
74
|
-
(discount) =>
|
|
74
|
+
(discount) => {
|
|
75
|
+
var _a;
|
|
76
|
+
return newDiscountIds.includes((_a = discount == null ? void 0 : discount.discount) == null ? void 0 : _a.resource_id);
|
|
77
|
+
}
|
|
75
78
|
);
|
|
76
79
|
if (usedNewDiscount) {
|
|
77
80
|
hasApplicableDiscount = true;
|
|
@@ -135,9 +138,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
135
138
|
applicableProducts.push({
|
|
136
139
|
amount: product.price,
|
|
137
140
|
type: discount.tag,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
discount: {
|
|
142
|
+
resource_id: discount.id,
|
|
143
|
+
title: discount.format_title,
|
|
144
|
+
original_amount: product.origin_total
|
|
145
|
+
}
|
|
141
146
|
});
|
|
142
147
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
143
148
|
}
|
|
@@ -5,6 +5,9 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
7
7
|
private store;
|
|
8
|
+
private cacheId;
|
|
9
|
+
private openCache;
|
|
10
|
+
private fatherModule;
|
|
8
11
|
constructor(name?: string, version?: string);
|
|
9
12
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
10
13
|
init(steps: IStep[]): void;
|
|
@@ -16,4 +19,5 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
16
19
|
prevStep(): void;
|
|
17
20
|
nextStep(): void;
|
|
18
21
|
gotoStep(stepIndex: number): void;
|
|
22
|
+
storeChange(): void;
|
|
19
23
|
}
|
|
@@ -28,10 +28,24 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
28
28
|
super(name, version);
|
|
29
29
|
this.defaultName = "step";
|
|
30
30
|
this.defaultVersion = "1.0.0";
|
|
31
|
+
this.openCache = false;
|
|
31
32
|
}
|
|
32
33
|
async initialize(core, options) {
|
|
34
|
+
var _a, _b;
|
|
33
35
|
this.core = core;
|
|
34
36
|
this.store = options.store;
|
|
37
|
+
if (options.initialState) {
|
|
38
|
+
this.store.stepList = options.initialState.stepList;
|
|
39
|
+
this.store.currentStep = options.initialState.currentStep;
|
|
40
|
+
this.store.currentStepIndex = options.initialState.currentStepIndex;
|
|
41
|
+
}
|
|
42
|
+
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
43
|
+
this.openCache = options.otherParams.openCache;
|
|
44
|
+
this.cacheId = options.otherParams.cacheId;
|
|
45
|
+
}
|
|
46
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
|
|
47
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
48
|
+
}
|
|
35
49
|
}
|
|
36
50
|
init(steps) {
|
|
37
51
|
this.setSteps(steps);
|
|
@@ -69,6 +83,11 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
69
83
|
gotoStep(stepIndex) {
|
|
70
84
|
this.setCurrentStep(stepIndex);
|
|
71
85
|
}
|
|
86
|
+
storeChange() {
|
|
87
|
+
if (this.openCache) {
|
|
88
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["currentStepIndex", "currentStep", "stepList"] });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
72
91
|
};
|
|
73
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
93
|
0 && (module.exports = {
|
|
@@ -7,7 +7,11 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private shopStore;
|
|
9
9
|
private store;
|
|
10
|
+
private cacheId;
|
|
11
|
+
private openCache;
|
|
12
|
+
private fatherModule;
|
|
10
13
|
constructor(name?: string, version?: string);
|
|
11
14
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
12
15
|
getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
|
|
16
|
+
storeChange(): void;
|
|
13
17
|
}
|
|
@@ -29,11 +29,23 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
29
29
|
super(name, version);
|
|
30
30
|
this.defaultName = "summary";
|
|
31
31
|
this.defaultVersion = "1.0.0";
|
|
32
|
+
this.openCache = false;
|
|
32
33
|
}
|
|
33
34
|
async initialize(core, options) {
|
|
35
|
+
var _a, _b;
|
|
34
36
|
this.core = core;
|
|
35
37
|
this.store = options.store;
|
|
36
38
|
this.shopStore = this.core.getPlugin("shopStore");
|
|
39
|
+
if (options.initialState) {
|
|
40
|
+
this.store.summary = options.initialState.summary;
|
|
41
|
+
}
|
|
42
|
+
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
43
|
+
this.openCache = options.otherParams.openCache;
|
|
44
|
+
this.cacheId = options.otherParams.cacheId;
|
|
45
|
+
}
|
|
46
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
|
|
47
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
48
|
+
}
|
|
37
49
|
if (!this.shopStore) {
|
|
38
50
|
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
39
51
|
}
|
|
@@ -45,6 +57,11 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
45
57
|
this.store.summary = summary;
|
|
46
58
|
return this.store.summary;
|
|
47
59
|
}
|
|
60
|
+
storeChange() {
|
|
61
|
+
if (this.openCache) {
|
|
62
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["summary"] });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
48
65
|
};
|
|
49
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
67
|
0 && (module.exports = {
|
|
@@ -38,7 +38,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
38
38
|
getActiveAccount(): Account | null;
|
|
39
39
|
removeAccount(id: string): void;
|
|
40
40
|
setDateRange(dateRange: ITime[]): Promise<void>;
|
|
41
|
-
|
|
41
|
+
clearDateRange(): void;
|
|
42
|
+
getDateRange(): Promise<ITime[]>;
|
|
42
43
|
getCart(): Promise<CartItem[]>;
|
|
43
44
|
getAvailableDate(params?: {
|
|
44
45
|
products?: ProductData[];
|
|
@@ -79,6 +80,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
79
80
|
deleteCartItemInfo(types: "resource" | "time"): void;
|
|
80
81
|
destory(): void;
|
|
81
82
|
getResourcesList(): any[];
|
|
83
|
+
getResourcesListByCartItem(id: string | number): {
|
|
84
|
+
id: number | undefined;
|
|
85
|
+
_id: string;
|
|
86
|
+
product: ProductData | undefined;
|
|
87
|
+
resources: import("./utils/resources").ResourceItem[];
|
|
88
|
+
holder_id: string | number | undefined;
|
|
89
|
+
holder_name: string | undefined;
|
|
90
|
+
} | undefined;
|
|
82
91
|
getResourceTimeSlot({ product, resources, currentResourceId, }: {
|
|
83
92
|
product: ProductData;
|
|
84
93
|
resources: any[];
|
|
@@ -111,4 +120,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
111
120
|
};
|
|
112
121
|
getTimeSlotByAllResources(resources_code: string): any[];
|
|
113
122
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
123
|
+
clearCache(): void;
|
|
124
|
+
clearCacheByModule(module: string): void;
|
|
114
125
|
}
|
|
@@ -48,6 +48,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
48
48
|
this.otherParams = {};
|
|
49
49
|
}
|
|
50
50
|
async initialize(core, options) {
|
|
51
|
+
var _a;
|
|
51
52
|
this.core = core;
|
|
52
53
|
this.store = options.store || {};
|
|
53
54
|
this.otherParams = options.otherParams || {};
|
|
@@ -58,22 +59,35 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
58
59
|
if (!this.request) {
|
|
59
60
|
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
60
61
|
}
|
|
62
|
+
let targetCacheData = {};
|
|
63
|
+
if ((_a = this.otherParams) == null ? void 0 : _a.cacheId) {
|
|
64
|
+
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
65
|
+
if (sessionData) {
|
|
66
|
+
const data = JSON.parse(sessionData);
|
|
67
|
+
targetCacheData = data[this.otherParams.cacheId];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
61
70
|
const moduleArr = [
|
|
62
71
|
"cart",
|
|
63
72
|
"summary",
|
|
64
73
|
"step",
|
|
65
74
|
"products",
|
|
66
|
-
"guests",
|
|
67
75
|
"date",
|
|
68
76
|
"accountList",
|
|
69
77
|
"order",
|
|
70
78
|
"payment"
|
|
71
79
|
];
|
|
72
80
|
moduleArr.forEach((step) => {
|
|
81
|
+
var _a2, _b;
|
|
73
82
|
const targetModule = (0, import_types.createModule)(step, this.name);
|
|
74
83
|
if (targetModule) {
|
|
75
84
|
this.store[step] = targetModule;
|
|
76
|
-
this.core.registerModule(targetModule
|
|
85
|
+
this.core.registerModule(targetModule, { initialState: targetCacheData[targetModule.name], otherParams: {
|
|
86
|
+
...this.otherParams,
|
|
87
|
+
fatherModule: this.name,
|
|
88
|
+
openCache: ((_a2 = this.otherParams) == null ? void 0 : _a2.cacheId) ? true : false,
|
|
89
|
+
cacheId: (_b = this.otherParams) == null ? void 0 : _b.cacheId
|
|
90
|
+
} });
|
|
77
91
|
} else {
|
|
78
92
|
throw new Error(`模块 ${step} 不存在`);
|
|
79
93
|
}
|
|
@@ -126,7 +140,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
126
140
|
category_ids,
|
|
127
141
|
ids: product_ids,
|
|
128
142
|
collection
|
|
129
|
-
});
|
|
143
|
+
}, { useCache: true });
|
|
130
144
|
this.store.products.addProduct(productsData.data.list);
|
|
131
145
|
return productsData.data.list;
|
|
132
146
|
}
|
|
@@ -174,9 +188,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
174
188
|
async setDateRange(dateRange) {
|
|
175
189
|
this.store.date.setDateRange(dateRange);
|
|
176
190
|
}
|
|
191
|
+
clearDateRange() {
|
|
192
|
+
this.store.date.clearDateRange();
|
|
193
|
+
}
|
|
177
194
|
// 获取日期模块里选中的日期
|
|
178
|
-
async
|
|
179
|
-
return
|
|
195
|
+
async getDateRange() {
|
|
196
|
+
return this.store.date.getDateRange();
|
|
180
197
|
}
|
|
181
198
|
async getCart() {
|
|
182
199
|
return this.store.cart.getItems();
|
|
@@ -337,6 +354,35 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
337
354
|
});
|
|
338
355
|
return arr;
|
|
339
356
|
}
|
|
357
|
+
// 给单个购物车里的商品获取资源列表
|
|
358
|
+
getResourcesListByCartItem(id) {
|
|
359
|
+
const cartItems = this.store.cart.getItems();
|
|
360
|
+
const dateRange = this.store.date.getDateRange();
|
|
361
|
+
const resources = [];
|
|
362
|
+
dateRange.forEach((n) => {
|
|
363
|
+
if (n.resource)
|
|
364
|
+
resources.push(...n.resource);
|
|
365
|
+
});
|
|
366
|
+
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
367
|
+
const arr = [];
|
|
368
|
+
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
369
|
+
if (!targetCartItem) {
|
|
370
|
+
throw new Error(`没有找到${id}购物车商品`);
|
|
371
|
+
}
|
|
372
|
+
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, targetCartItem, cartItems);
|
|
373
|
+
if (productResources) {
|
|
374
|
+
return {
|
|
375
|
+
id: targetCartItem.id,
|
|
376
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
377
|
+
_id: targetCartItem._id,
|
|
378
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
379
|
+
product: targetCartItem._productOrigin,
|
|
380
|
+
resources: productResources,
|
|
381
|
+
holder_id: targetCartItem.holder_id,
|
|
382
|
+
holder_name: targetCartItem.holder_title
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
}
|
|
340
386
|
// 通过资源列表和指定的资源 id,获取指定资源的时间切片
|
|
341
387
|
getResourceTimeSlot({
|
|
342
388
|
product,
|
|
@@ -612,6 +658,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
612
658
|
});
|
|
613
659
|
});
|
|
614
660
|
}
|
|
661
|
+
clearCache() {
|
|
662
|
+
}
|
|
663
|
+
clearCacheByModule(module2) {
|
|
664
|
+
}
|
|
615
665
|
};
|
|
616
666
|
// Annotate the CommonJS export names for ESM import in node:
|
|
617
667
|
0 && (module.exports = {
|
|
@@ -26,7 +26,6 @@ module.exports = __toCommonJS(types_exports);
|
|
|
26
26
|
var import_modules = require("../../modules");
|
|
27
27
|
var import_AccountList = require("../../modules/AccountList");
|
|
28
28
|
var import_Date = require("../../modules/Date");
|
|
29
|
-
var import_Guests = require("../../modules/Guests");
|
|
30
29
|
var import_Order = require("../../modules/Order");
|
|
31
30
|
var import_Payment = require("../../modules/Payment");
|
|
32
31
|
var import_Step = require("../../modules/Step");
|
|
@@ -41,8 +40,6 @@ function createModule(moduleName, solutionName, name, version) {
|
|
|
41
40
|
return new import_Step.StepModule(`${solutionName}_${name || moduleName}`, version);
|
|
42
41
|
case "products":
|
|
43
42
|
return new import_modules.ProductList(`${solutionName}_${name || moduleName}`, version);
|
|
44
|
-
case "guests":
|
|
45
|
-
return new import_Guests.GuestListModule(`${solutionName}_${name || moduleName}`, version);
|
|
46
43
|
case "date":
|
|
47
44
|
return new import_Date.DateModule(`${solutionName}_${name || moduleName}`, version);
|
|
48
45
|
case "accountList":
|
|
@@ -82,15 +82,29 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
registerDependentModules() {
|
|
85
|
-
var _a, _b, _c, _d;
|
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
86
|
+
let targetCacheData = {};
|
|
87
|
+
if ((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
88
|
+
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
89
|
+
if (sessionData) {
|
|
90
|
+
const data = JSON.parse(sessionData);
|
|
91
|
+
targetCacheData = data[this.options.otherParams.cacheId];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
86
94
|
const discount = new import_Discount.DiscountModule(`${this.name}_discount`);
|
|
87
95
|
this.core.registerModule(discount, {
|
|
88
|
-
|
|
96
|
+
initialState: targetCacheData[discount.name],
|
|
97
|
+
hooks: (_c = (_b = this.options.otherParams) == null ? void 0 : _b.discount) == null ? void 0 : _c.hooks,
|
|
98
|
+
otherParams: {
|
|
99
|
+
fatherModule: this.name,
|
|
100
|
+
openCache: ((_d = this.options.otherParams) == null ? void 0 : _d.cacheId) ? true : false,
|
|
101
|
+
cacheId: (_e = this.options.otherParams) == null ? void 0 : _e.cacheId
|
|
102
|
+
}
|
|
89
103
|
});
|
|
90
104
|
this.store.discount = discount;
|
|
91
105
|
const rules = new import_Rules.RulesModule(`${this.name}_rules`);
|
|
92
106
|
this.core.registerModule(rules, {
|
|
93
|
-
hooks: (
|
|
107
|
+
hooks: (_g = (_f = this.options.otherParams) == null ? void 0 : _f.rules) == null ? void 0 : _g.hooks
|
|
94
108
|
});
|
|
95
109
|
this.store.rules = rules;
|
|
96
110
|
}
|
|
@@ -98,6 +112,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
98
112
|
this.core.effects.on(
|
|
99
113
|
import_types.ShopDiscountHooks.onCustomerChange,
|
|
100
114
|
(customer) => {
|
|
115
|
+
var _a;
|
|
116
|
+
if (((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) && this.getDiscountList().length) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
101
119
|
this.loadPrepareConfig({
|
|
102
120
|
customerId: customer.id,
|
|
103
121
|
action: "create",
|