@pisell/pisellos 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +4 -1
- package/dist/effects/index.d.ts +1 -1
- package/dist/effects/index.js +3 -3
- package/dist/modules/Account/index.d.ts +5 -3
- package/dist/modules/Account/index.js +23 -36
- package/dist/modules/Account/types.d.ts +2 -1
- package/dist/modules/AccountList/index.d.ts +2 -0
- package/dist/modules/AccountList/index.js +34 -11
- package/dist/modules/Cart/index.d.ts +17 -11
- package/dist/modules/Cart/index.js +179 -121
- package/dist/modules/Cart/types.d.ts +98 -9
- package/dist/modules/Cart/types.js +8 -0
- package/dist/modules/Cart/utils.d.ts +114 -0
- package/dist/modules/Cart/utils.js +345 -0
- package/dist/modules/Date/index.d.ts +11 -12
- package/dist/modules/Date/index.js +104 -60
- package/dist/modules/Date/types.d.ts +51 -20
- package/dist/modules/Date/types.js +2 -5
- package/dist/modules/Date/utils.d.ts +35 -0
- package/dist/modules/Date/utils.js +211 -0
- package/dist/modules/Discount/index.d.ts +26 -0
- package/dist/modules/Discount/index.js +234 -0
- package/dist/modules/Discount/types.d.ts +66 -0
- package/dist/modules/Discount/types.js +5 -0
- package/dist/modules/Order/index.d.ts +16 -12
- package/dist/modules/Order/index.js +38 -166
- package/dist/modules/Order/types.d.ts +18 -41
- package/dist/modules/Order/types.js +0 -14
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +45 -76
- package/dist/modules/Payment/types.d.ts +0 -2
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/types.d.ts +50 -1
- package/dist/modules/ProductList/index.d.ts +1 -0
- package/dist/modules/ProductList/index.js +23 -2
- package/dist/modules/ProductList/types.d.ts +1 -0
- package/dist/modules/Resource/types.d.ts +6 -2
- package/dist/modules/Rules/index.d.ts +32 -0
- package/dist/modules/Rules/index.js +423 -0
- package/dist/modules/Rules/types.d.ts +46 -0
- package/dist/modules/Rules/types.js +5 -0
- package/dist/modules/Summary/index.d.ts +13 -0
- package/dist/modules/Summary/index.js +80 -0
- package/dist/modules/Summary/types.d.ts +13 -0
- package/dist/modules/Summary/types.js +1 -0
- package/dist/modules/Summary/utils.d.ts +19 -0
- package/dist/modules/Summary/utils.js +56 -0
- package/dist/plugins/index.d.ts +3 -2
- package/dist/plugins/index.js +2 -1
- package/dist/plugins/request.d.ts +4 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +4 -0
- package/dist/plugins/shopStore.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +73 -10
- package/dist/solution/BookingByStep/index.js +641 -74
- package/dist/solution/BookingByStep/types.d.ts +2 -0
- package/dist/solution/BookingByStep/types.js +11 -8
- package/dist/solution/BookingByStep/utils/products.d.ts +11 -0
- package/dist/solution/BookingByStep/utils/products.js +47 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +59 -10
- package/dist/solution/BookingByStep/utils/resources.js +144 -79
- package/dist/solution/ShopDiscount/index.d.ts +50 -0
- package/dist/solution/ShopDiscount/index.js +546 -0
- package/dist/solution/ShopDiscount/types.d.ts +24 -0
- package/dist/solution/ShopDiscount/types.js +10 -0
- package/dist/solution/ShopDiscount/utils.d.ts +1 -0
- package/dist/solution/ShopDiscount/utils.js +7 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +1 -1
- package/lib/effects/index.js +1 -1
- package/lib/modules/Account/index.d.ts +5 -3
- package/lib/modules/Account/index.js +14 -3
- package/lib/modules/Account/types.d.ts +2 -1
- package/lib/modules/AccountList/index.d.ts +2 -0
- package/lib/modules/AccountList/index.js +17 -0
- package/lib/modules/Cart/index.d.ts +17 -11
- package/lib/modules/Cart/index.js +72 -21
- package/lib/modules/Cart/types.d.ts +98 -9
- package/lib/modules/Cart/utils.d.ts +114 -0
- package/lib/modules/Cart/utils.js +320 -0
- package/lib/modules/Date/index.d.ts +11 -12
- package/lib/modules/Date/index.js +50 -31
- package/lib/modules/Date/types.d.ts +51 -20
- package/lib/modules/Date/types.js +0 -4
- package/lib/modules/Date/utils.d.ts +35 -0
- package/lib/modules/Date/utils.js +167 -0
- package/lib/modules/Discount/index.d.ts +26 -0
- package/lib/modules/Discount/index.js +118 -0
- package/lib/modules/Discount/types.d.ts +66 -0
- package/lib/modules/Discount/types.js +33 -0
- package/lib/modules/Order/index.d.ts +16 -12
- package/lib/modules/Order/index.js +23 -51
- package/lib/modules/Order/types.d.ts +18 -41
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +6 -17
- package/lib/modules/Payment/types.d.ts +0 -2
- package/lib/modules/Product/types.d.ts +50 -1
- package/lib/modules/ProductList/index.d.ts +1 -0
- package/lib/modules/ProductList/index.js +6 -1
- package/lib/modules/ProductList/types.d.ts +1 -0
- package/lib/modules/Resource/types.d.ts +6 -2
- package/lib/modules/Rules/index.d.ts +32 -0
- package/lib/modules/Rules/index.js +283 -0
- package/lib/modules/Rules/types.d.ts +46 -0
- package/lib/modules/Rules/types.js +33 -0
- package/lib/modules/Summary/index.d.ts +13 -0
- package/lib/modules/Summary/index.js +49 -0
- package/lib/modules/Summary/types.d.ts +13 -0
- package/lib/modules/Summary/types.js +17 -0
- package/lib/modules/Summary/utils.d.ts +19 -0
- package/lib/modules/Summary/utils.js +79 -0
- package/lib/plugins/index.d.ts +3 -2
- package/lib/plugins/index.js +3 -1
- package/lib/plugins/request.d.ts +4 -3
- package/lib/plugins/request.js +4 -20
- package/lib/plugins/shopStore.d.ts +4 -0
- package/lib/plugins/shopStore.js +17 -0
- package/lib/solution/BookingByStep/index.d.ts +73 -10
- package/lib/solution/BookingByStep/index.js +452 -20
- package/lib/solution/BookingByStep/types.d.ts +2 -0
- package/lib/solution/BookingByStep/types.js +3 -0
- package/lib/solution/BookingByStep/utils/products.d.ts +11 -0
- package/lib/solution/BookingByStep/utils/products.js +60 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +59 -10
- package/lib/solution/BookingByStep/utils/resources.js +106 -49
- package/lib/solution/ShopDiscount/index.d.ts +50 -0
- package/lib/solution/ShopDiscount/index.js +321 -0
- package/lib/solution/ShopDiscount/types.d.ts +24 -0
- package/lib/solution/ShopDiscount/types.js +38 -0
- package/lib/solution/ShopDiscount/utils.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +32 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/package.json +8 -7
package/dist/core/index.js
CHANGED
|
@@ -175,7 +175,10 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
175
175
|
// 预先给模块初始化值系统
|
|
176
176
|
var _createStore = createStore((options === null || options === void 0 ? void 0 : options.initialState) || {}, module.name, function (path, value) {
|
|
177
177
|
console.log('core 检测到模块值更新', module.name, path, value);
|
|
178
|
-
_this3.effects.emit("".concat(module.name, ":changed"),
|
|
178
|
+
_this3.effects.emit("".concat(module.name, ":changed"), {
|
|
179
|
+
path: path,
|
|
180
|
+
value: value
|
|
181
|
+
});
|
|
179
182
|
if (module.storeChange) module.storeChange(path, value);
|
|
180
183
|
}),
|
|
181
184
|
proxy = _createStore.proxy;
|
package/dist/effects/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare class EffectsManager {
|
|
|
8
8
|
off(event: string, callback: EffectCallback): void;
|
|
9
9
|
offByModuleDestroy(module: string): void;
|
|
10
10
|
once(event: string, callback: EffectCallback): void;
|
|
11
|
-
emit(event: string, payload: any
|
|
11
|
+
emit(event: string, payload: any): Promise<{
|
|
12
12
|
status: boolean;
|
|
13
13
|
data: any;
|
|
14
14
|
}>;
|
package/dist/effects/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
69
69
|
}, {
|
|
70
70
|
key: "emit",
|
|
71
71
|
value: function () {
|
|
72
|
-
var _emit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(event, payload
|
|
72
|
+
var _emit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(event, payload) {
|
|
73
73
|
var callbacks;
|
|
74
74
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
75
75
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -135,7 +135,7 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
135
135
|
}
|
|
136
136
|
}, _callee2, null, [[2, 14, 17, 20]]);
|
|
137
137
|
}));
|
|
138
|
-
return function (
|
|
138
|
+
return function (_x4) {
|
|
139
139
|
return _ref2.apply(this, arguments);
|
|
140
140
|
};
|
|
141
141
|
}()));
|
|
@@ -145,7 +145,7 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
145
145
|
}
|
|
146
146
|
}, _callee3, this);
|
|
147
147
|
}));
|
|
148
|
-
function emit(_x2, _x3
|
|
148
|
+
function emit(_x2, _x3) {
|
|
149
149
|
return _emit.apply(this, arguments);
|
|
150
150
|
}
|
|
151
151
|
return emit;
|
|
@@ -9,7 +9,7 @@ export declare class AccountModule extends BaseModule implements Module, Account
|
|
|
9
9
|
private store;
|
|
10
10
|
constructor(name?: string, version?: string);
|
|
11
11
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
12
|
-
getId(): string;
|
|
12
|
+
getId(): string | number;
|
|
13
13
|
login(credentials: {
|
|
14
14
|
username: string;
|
|
15
15
|
password: string;
|
|
@@ -21,7 +21,9 @@ export declare class AccountModule extends BaseModule implements Module, Account
|
|
|
21
21
|
isLoggedIn(): boolean;
|
|
22
22
|
resetPassword(email: string): Promise<void>;
|
|
23
23
|
updatePassword(oldPassword: string, newPassword: string): Promise<void>;
|
|
24
|
-
getLoginStatus():
|
|
25
|
-
getAccount():
|
|
24
|
+
getLoginStatus(): boolean;
|
|
25
|
+
getAccount(): Account | null;
|
|
26
26
|
setAccountInfo(account: Account): void;
|
|
27
|
+
setActive(active: boolean): void;
|
|
28
|
+
isActive(): boolean;
|
|
27
29
|
}
|
|
@@ -32,7 +32,8 @@ export var AccountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
32
32
|
_defineProperty(_assertThisInitialized(_this), "isGuest", false);
|
|
33
33
|
_defineProperty(_assertThisInitialized(_this), "store", {
|
|
34
34
|
currentAccount: null,
|
|
35
|
-
isLoggedIn: false
|
|
35
|
+
isLoggedIn: false,
|
|
36
|
+
active: false
|
|
36
37
|
});
|
|
37
38
|
return _this;
|
|
38
39
|
}
|
|
@@ -45,7 +46,8 @@ export var AccountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
45
46
|
case 0:
|
|
46
47
|
this.core = core;
|
|
47
48
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
48
|
-
|
|
49
|
+
this.store.isLoggedIn = false;
|
|
50
|
+
case 3:
|
|
49
51
|
case "end":
|
|
50
52
|
return _context.stop();
|
|
51
53
|
}
|
|
@@ -216,46 +218,31 @@ export var AccountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
216
218
|
}()
|
|
217
219
|
}, {
|
|
218
220
|
key: "getLoginStatus",
|
|
219
|
-
value: function () {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
223
|
-
case 0:
|
|
224
|
-
return _context8.abrupt("return", this.store.isLoggedIn);
|
|
225
|
-
case 1:
|
|
226
|
-
case "end":
|
|
227
|
-
return _context8.stop();
|
|
228
|
-
}
|
|
229
|
-
}, _callee8, this);
|
|
230
|
-
}));
|
|
231
|
-
function getLoginStatus() {
|
|
232
|
-
return _getLoginStatus.apply(this, arguments);
|
|
233
|
-
}
|
|
234
|
-
return getLoginStatus;
|
|
235
|
-
}()
|
|
221
|
+
value: function getLoginStatus() {
|
|
222
|
+
return this.store.isLoggedIn;
|
|
223
|
+
}
|
|
236
224
|
}, {
|
|
237
225
|
key: "getAccount",
|
|
238
|
-
value: function () {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
242
|
-
case 0:
|
|
243
|
-
return _context9.abrupt("return", this.store.currentAccount);
|
|
244
|
-
case 1:
|
|
245
|
-
case "end":
|
|
246
|
-
return _context9.stop();
|
|
247
|
-
}
|
|
248
|
-
}, _callee9, this);
|
|
249
|
-
}));
|
|
250
|
-
function getAccount() {
|
|
251
|
-
return _getAccount.apply(this, arguments);
|
|
252
|
-
}
|
|
253
|
-
return getAccount;
|
|
254
|
-
}()
|
|
226
|
+
value: function getAccount() {
|
|
227
|
+
return this.store.currentAccount;
|
|
228
|
+
}
|
|
255
229
|
}, {
|
|
256
230
|
key: "setAccountInfo",
|
|
257
231
|
value: function setAccountInfo(account) {
|
|
258
232
|
this.store.currentAccount = account;
|
|
233
|
+
if (account.isGuest) {
|
|
234
|
+
this.isGuest = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}, {
|
|
238
|
+
key: "setActive",
|
|
239
|
+
value: function setActive(active) {
|
|
240
|
+
this.store.active = active;
|
|
241
|
+
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "isActive",
|
|
244
|
+
value: function isActive() {
|
|
245
|
+
return this.store.active;
|
|
259
246
|
}
|
|
260
247
|
}]);
|
|
261
248
|
return AccountModule;
|
|
@@ -8,7 +8,7 @@ export declare enum AccountHooks {
|
|
|
8
8
|
* 用户账户信息
|
|
9
9
|
*/
|
|
10
10
|
export interface Account {
|
|
11
|
-
id: string;
|
|
11
|
+
id: string | number;
|
|
12
12
|
username: string;
|
|
13
13
|
email?: string;
|
|
14
14
|
phone?: string;
|
|
@@ -23,6 +23,7 @@ export interface Account {
|
|
|
23
23
|
export interface AccountState {
|
|
24
24
|
currentAccount: Account | null;
|
|
25
25
|
isLoggedIn: boolean;
|
|
26
|
+
active: boolean;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* 账户模块 API
|
|
@@ -15,4 +15,6 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
15
15
|
getAccount(id: string): AccountModule | null;
|
|
16
16
|
clearAccounts(): Promise<void>;
|
|
17
17
|
getState(): AccountListState;
|
|
18
|
+
setActiveAccount(id: string | number): void;
|
|
19
|
+
getActiveAccount(): AccountModule | null;
|
|
18
20
|
}
|
|
@@ -84,27 +84,32 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
84
84
|
case 5:
|
|
85
85
|
accountModule = new AccountModule("account_".concat(account.id));
|
|
86
86
|
this.core.registerModule(accountModule);
|
|
87
|
+
accountModule.setAccountInfo(account);
|
|
87
88
|
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts), [accountModule]);
|
|
88
|
-
_context2.next =
|
|
89
|
+
_context2.next = 11;
|
|
89
90
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
90
|
-
case
|
|
91
|
-
|
|
91
|
+
case 11:
|
|
92
|
+
if (this.store.accounts.length === 1) {
|
|
93
|
+
this.setActiveAccount(accountModule.getId());
|
|
94
|
+
}
|
|
95
|
+
_context2.next = 20;
|
|
92
96
|
break;
|
|
93
|
-
case
|
|
94
|
-
_context2.prev =
|
|
97
|
+
case 14:
|
|
98
|
+
_context2.prev = 14;
|
|
95
99
|
_context2.t0 = _context2["catch"](0);
|
|
100
|
+
console.error(_context2.t0);
|
|
96
101
|
this.store.error = _context2.t0 instanceof Error ? _context2.t0.message : 'Failed to add account';
|
|
97
|
-
_context2.next =
|
|
102
|
+
_context2.next = 20;
|
|
98
103
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
99
|
-
case 17:
|
|
100
|
-
_context2.prev = 17;
|
|
101
|
-
this.store.isLoading = false;
|
|
102
|
-
return _context2.finish(17);
|
|
103
104
|
case 20:
|
|
105
|
+
_context2.prev = 20;
|
|
106
|
+
this.store.isLoading = false;
|
|
107
|
+
return _context2.finish(20);
|
|
108
|
+
case 23:
|
|
104
109
|
case "end":
|
|
105
110
|
return _context2.stop();
|
|
106
111
|
}
|
|
107
|
-
}, _callee2, this, [[0,
|
|
112
|
+
}, _callee2, this, [[0, 14, 20, 23]]);
|
|
108
113
|
}));
|
|
109
114
|
function addAccount(_x3) {
|
|
110
115
|
return _addAccount.apply(this, arguments);
|
|
@@ -259,6 +264,24 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
259
264
|
value: function getState() {
|
|
260
265
|
return _objectSpread({}, this.store);
|
|
261
266
|
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "setActiveAccount",
|
|
269
|
+
value: function setActiveAccount(id) {
|
|
270
|
+
this.store.accounts.forEach(function (account) {
|
|
271
|
+
if (account.getId() === id) {
|
|
272
|
+
account.setActive(true);
|
|
273
|
+
} else {
|
|
274
|
+
account.setActive(false);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "getActiveAccount",
|
|
280
|
+
value: function getActiveAccount() {
|
|
281
|
+
return this.store.accounts.find(function (account) {
|
|
282
|
+
return account.isActive();
|
|
283
|
+
}) || null;
|
|
284
|
+
}
|
|
262
285
|
}]);
|
|
263
286
|
return AccountListModule;
|
|
264
287
|
}(BaseModule);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { CartItem, CartModuleAPI } from
|
|
4
|
-
export * from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from "../../types";
|
|
2
|
+
import { BaseModule } from "../BaseModule";
|
|
3
|
+
import { CartItem, CartModuleAPI, IAddItemParams, IUpdateItemParams } from "./types";
|
|
4
|
+
export * from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* 购物车模块实现
|
|
7
7
|
*/
|
|
@@ -18,18 +18,24 @@ export declare class CartModule extends BaseModule implements Module {
|
|
|
18
18
|
*/
|
|
19
19
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* 添加商品到购物车
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
addItem(params: IAddItemParams): Promise<void>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* 更新购物车信息
|
|
26
|
+
*/
|
|
27
|
+
updateItem(params: IUpdateItemParams): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* 批量设置购物车数据
|
|
26
30
|
*/
|
|
27
|
-
|
|
31
|
+
batchSetItems(items: CartItem[]): Promise<void>;
|
|
28
32
|
getItemCount(): number;
|
|
29
33
|
getTotalPrice(): number;
|
|
30
|
-
getItems():
|
|
31
|
-
updateItem(id: string, item: CartItem): Promise<void>;
|
|
34
|
+
getItems(): CartItem[];
|
|
32
35
|
removeItem(id: string): Promise<void>;
|
|
33
36
|
storeTemp(key: string, value: any): Promise<void>;
|
|
34
|
-
getTemp(key?: string):
|
|
37
|
+
getTemp(key?: string): any;
|
|
38
|
+
clear(): void;
|
|
39
|
+
clearCartByAccount(account_id: string): void;
|
|
40
|
+
getCartByAccount(account_id: string | number): CartItem[];
|
|
35
41
|
}
|