@pisell/pisellos 0.0.45 → 0.0.46
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 +2 -2
- package/dist/modules/AccountList/index.js +52 -38
- package/dist/modules/Cart/index.js +1 -0
- package/dist/modules/Cart/types.d.ts +3 -3
- package/dist/solution/BookingByStep/index.d.ts +11 -5
- package/dist/solution/BookingByStep/index.js +280 -201
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -0
- package/dist/solution/BookingByStep/utils/resources.js +26 -8
- package/lib/modules/AccountList/index.d.ts +2 -2
- package/lib/modules/AccountList/index.js +16 -4
- package/lib/modules/Cart/index.js +1 -0
- package/lib/modules/Cart/types.d.ts +3 -3
- package/lib/solution/BookingByStep/index.d.ts +11 -5
- package/lib/solution/BookingByStep/index.js +65 -29
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -0
- package/lib/solution/BookingByStep/utils/resources.js +27 -8
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
18
18
|
* @param needEmit 是否需要触发事件
|
|
19
19
|
*/
|
|
20
20
|
private createAccountAndAdd;
|
|
21
|
-
addAccount(account: Account): Promise<
|
|
21
|
+
addAccount(account: Account): Promise<AccountModule>;
|
|
22
22
|
updateAccount(id: string, updates: Account): Promise<void>;
|
|
23
23
|
updateAccountListById(id: string | number, updates: Account): Promise<void>;
|
|
24
24
|
removeAccount(id: string): Promise<void>;
|
|
@@ -33,7 +33,7 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
33
33
|
* @param holders 账号信息列表
|
|
34
34
|
* @param customerId 账户id
|
|
35
35
|
*/
|
|
36
|
-
addHolderAccounts(holders: IHolder[], customerId: number): Promise<
|
|
36
|
+
addHolderAccounts(holders: IHolder[], customerId: number): Promise<AccountModule[]>;
|
|
37
37
|
/**
|
|
38
38
|
* 获取holder类型账户列表
|
|
39
39
|
* @param params
|
|
@@ -103,32 +103,36 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
103
103
|
value: (function () {
|
|
104
104
|
var _createAccountAndAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(account) {
|
|
105
105
|
var needEmit,
|
|
106
|
+
tempAccountModule,
|
|
106
107
|
accountModule,
|
|
107
108
|
_args2 = arguments;
|
|
108
109
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
109
110
|
while (1) switch (_context2.prev = _context2.next) {
|
|
110
111
|
case 0:
|
|
111
112
|
needEmit = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
|
|
112
|
-
|
|
113
|
+
tempAccountModule = this.store.accounts.find(function (a) {
|
|
113
114
|
return a.getId() === account.id;
|
|
114
|
-
})
|
|
115
|
-
|
|
115
|
+
}); // 如果账号已经存在,则直接返回
|
|
116
|
+
if (!tempAccountModule) {
|
|
117
|
+
_context2.next = 4;
|
|
116
118
|
break;
|
|
117
119
|
}
|
|
118
|
-
return _context2.abrupt("return");
|
|
119
|
-
case
|
|
120
|
+
return _context2.abrupt("return", tempAccountModule);
|
|
121
|
+
case 4:
|
|
120
122
|
this.store.accountList.push(account);
|
|
121
123
|
accountModule = new AccountModule("account_".concat(account.id));
|
|
122
124
|
this.core.registerModule(accountModule);
|
|
123
125
|
accountModule.setAccountInfo(account);
|
|
124
126
|
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts || []), [accountModule]);
|
|
125
127
|
if (!needEmit) {
|
|
126
|
-
_context2.next =
|
|
128
|
+
_context2.next = 12;
|
|
127
129
|
break;
|
|
128
130
|
}
|
|
129
|
-
_context2.next =
|
|
131
|
+
_context2.next = 12;
|
|
130
132
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
131
|
-
case
|
|
133
|
+
case 12:
|
|
134
|
+
return _context2.abrupt("return", accountModule);
|
|
135
|
+
case 13:
|
|
132
136
|
case "end":
|
|
133
137
|
return _context2.stop();
|
|
134
138
|
}
|
|
@@ -143,7 +147,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
143
147
|
key: "addAccount",
|
|
144
148
|
value: function () {
|
|
145
149
|
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(account) {
|
|
146
|
-
var accountModule;
|
|
150
|
+
var currentAccountModule, accountModule;
|
|
147
151
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
148
152
|
while (1) switch (_context3.prev = _context3.next) {
|
|
149
153
|
case 0:
|
|
@@ -156,6 +160,9 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
156
160
|
_context3.next = 6;
|
|
157
161
|
break;
|
|
158
162
|
}
|
|
163
|
+
currentAccountModule = this.store.accounts.find(function (n) {
|
|
164
|
+
return n.getId() === account.id;
|
|
165
|
+
});
|
|
159
166
|
throw new Error("Account with id ".concat(account.id, " already exists"));
|
|
160
167
|
case 6:
|
|
161
168
|
this.store.accountList.push(account);
|
|
@@ -166,27 +173,28 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
166
173
|
if (this.store.accounts.length === 1) {
|
|
167
174
|
this.setActiveAccount(accountModule.getId());
|
|
168
175
|
}
|
|
169
|
-
|
|
176
|
+
currentAccountModule = accountModule;
|
|
177
|
+
_context3.next = 15;
|
|
170
178
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
171
|
-
case
|
|
172
|
-
_context3.next =
|
|
179
|
+
case 15:
|
|
180
|
+
_context3.next = 23;
|
|
173
181
|
break;
|
|
174
|
-
case
|
|
175
|
-
_context3.prev =
|
|
182
|
+
case 17:
|
|
183
|
+
_context3.prev = 17;
|
|
176
184
|
_context3.t0 = _context3["catch"](0);
|
|
177
185
|
console.error(_context3.t0);
|
|
178
186
|
this.store.error = _context3.t0 instanceof Error ? _context3.t0.message : 'Failed to add account';
|
|
179
|
-
_context3.next =
|
|
187
|
+
_context3.next = 23;
|
|
180
188
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
181
|
-
case
|
|
182
|
-
_context3.prev =
|
|
189
|
+
case 23:
|
|
190
|
+
_context3.prev = 23;
|
|
183
191
|
this.store.isLoading = false;
|
|
184
|
-
return _context3.
|
|
185
|
-
case
|
|
192
|
+
return _context3.abrupt("return", currentAccountModule);
|
|
193
|
+
case 27:
|
|
186
194
|
case "end":
|
|
187
195
|
return _context3.stop();
|
|
188
196
|
}
|
|
189
|
-
}, _callee3, this, [[0,
|
|
197
|
+
}, _callee3, this, [[0, 17, 23, 27]]);
|
|
190
198
|
}));
|
|
191
199
|
function addAccount(_x4) {
|
|
192
200
|
return _addAccount.apply(this, arguments);
|
|
@@ -424,44 +432,50 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
424
432
|
key: "addHolderAccounts",
|
|
425
433
|
value: (function () {
|
|
426
434
|
var _addHolderAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(holders, customerId) {
|
|
427
|
-
var _iterator, _step, holder, account;
|
|
435
|
+
var accountModules, _iterator, _step, holder, account, accountModule;
|
|
428
436
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
429
437
|
while (1) switch (_context8.prev = _context8.next) {
|
|
430
438
|
case 0:
|
|
439
|
+
accountModules = [];
|
|
431
440
|
_iterator = _createForOfIteratorHelper(holders);
|
|
432
|
-
_context8.prev =
|
|
441
|
+
_context8.prev = 2;
|
|
433
442
|
_iterator.s();
|
|
434
|
-
case
|
|
443
|
+
case 4:
|
|
435
444
|
if ((_step = _iterator.n()).done) {
|
|
436
|
-
_context8.next =
|
|
445
|
+
_context8.next = 13;
|
|
437
446
|
break;
|
|
438
447
|
}
|
|
439
448
|
holder = _step.value;
|
|
440
449
|
account = createHolderAccount(holder, customerId);
|
|
441
|
-
_context8.next =
|
|
450
|
+
_context8.next = 9;
|
|
442
451
|
return this.createAccountAndAdd(account, false);
|
|
443
|
-
case
|
|
444
|
-
|
|
452
|
+
case 9:
|
|
453
|
+
accountModule = _context8.sent;
|
|
454
|
+
accountModules.push(accountModule);
|
|
455
|
+
case 11:
|
|
456
|
+
_context8.next = 4;
|
|
445
457
|
break;
|
|
446
|
-
case
|
|
447
|
-
_context8.next =
|
|
458
|
+
case 13:
|
|
459
|
+
_context8.next = 18;
|
|
448
460
|
break;
|
|
449
|
-
case 12:
|
|
450
|
-
_context8.prev = 12;
|
|
451
|
-
_context8.t0 = _context8["catch"](1);
|
|
452
|
-
_iterator.e(_context8.t0);
|
|
453
461
|
case 15:
|
|
454
462
|
_context8.prev = 15;
|
|
455
|
-
|
|
456
|
-
|
|
463
|
+
_context8.t0 = _context8["catch"](2);
|
|
464
|
+
_iterator.e(_context8.t0);
|
|
457
465
|
case 18:
|
|
458
|
-
_context8.
|
|
466
|
+
_context8.prev = 18;
|
|
467
|
+
_iterator.f();
|
|
468
|
+
return _context8.finish(18);
|
|
469
|
+
case 21:
|
|
470
|
+
_context8.next = 23;
|
|
459
471
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
460
|
-
case
|
|
472
|
+
case 23:
|
|
473
|
+
return _context8.abrupt("return", accountModules);
|
|
474
|
+
case 24:
|
|
461
475
|
case "end":
|
|
462
476
|
return _context8.stop();
|
|
463
477
|
}
|
|
464
|
-
}, _callee8, this, [[
|
|
478
|
+
}, _callee8, this, [[2, 15, 18, 21]]);
|
|
465
479
|
}));
|
|
466
480
|
function addHolderAccounts(_x10, _x11) {
|
|
467
481
|
return _addHolderAccounts.apply(this, arguments);
|
|
@@ -122,6 +122,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
122
122
|
};
|
|
123
123
|
if (product) {
|
|
124
124
|
cartItem._productOrigin = cloneDeep(product);
|
|
125
|
+
cartItem._productInit = cloneDeep(product);
|
|
125
126
|
cartItem = formatProductToCartItem({
|
|
126
127
|
cartItem: cartItem,
|
|
127
128
|
product: product,
|
|
@@ -96,16 +96,16 @@ export interface CartItem {
|
|
|
96
96
|
title: string;
|
|
97
97
|
}[];
|
|
98
98
|
} | null;
|
|
99
|
-
/**
|
|
99
|
+
/** 接口原始数据 */
|
|
100
100
|
_origin: any;
|
|
101
|
+
/** 商品加入购物车时初始数据 */
|
|
102
|
+
_productInit?: ProductData;
|
|
101
103
|
/** 商品原始数据 */
|
|
102
104
|
_productOrigin?: ProductData;
|
|
103
105
|
/** 资源原始数据 */
|
|
104
106
|
_resourceOrigin?: Resource[];
|
|
105
107
|
/** 容量 */
|
|
106
108
|
capacity?: any;
|
|
107
|
-
/** 商品套餐 */
|
|
108
|
-
product_bundle?: any;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* 购物车状态接口
|
|
@@ -2,7 +2,7 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { Response } from '../../plugins';
|
|
4
4
|
import { BookingByStepState } from './types';
|
|
5
|
-
import { CartItem, IUpdateItemParams, ProductData } from '../../modules';
|
|
5
|
+
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem } from '../../modules';
|
|
6
6
|
import { Account } from '../../modules/Account/types';
|
|
7
7
|
import { IStep } from '../../modules/Step/tyeps';
|
|
8
8
|
import { TimeSliceItem } from './utils/resources';
|
|
@@ -52,10 +52,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
52
52
|
custom_page_id?: number;
|
|
53
53
|
}): Promise<ITime[]>;
|
|
54
54
|
storeProduct(productData: ProductData): Promise<void>;
|
|
55
|
-
addAccount(
|
|
55
|
+
addAccount(account: Account | IHolder, extra?: {
|
|
56
56
|
type: 'account' | 'holder';
|
|
57
57
|
customerId: number;
|
|
58
|
-
}): Promise<
|
|
58
|
+
}): Promise<Account | null>;
|
|
59
|
+
addAccounts(accounts: Account[] | IHolder[], extra?: {
|
|
60
|
+
type: 'account' | 'holder';
|
|
61
|
+
customerId: number;
|
|
62
|
+
}): Promise<Account[] | undefined>;
|
|
59
63
|
getAccounts(): Promise<(Account | null)[]>;
|
|
60
64
|
checkHasLoginAccount(): boolean;
|
|
61
65
|
setActiveAccount(id: string): void;
|
|
@@ -71,6 +75,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
71
75
|
getDateRange(): Promise<ITime[]>;
|
|
72
76
|
getCart(): CartItem[];
|
|
73
77
|
getAvailableDate(params?: {
|
|
78
|
+
url?: string;
|
|
74
79
|
products?: ProductData[];
|
|
75
80
|
startDate?: string;
|
|
76
81
|
endDate?: string;
|
|
@@ -172,9 +177,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
172
177
|
private getScheduleDataByIds;
|
|
173
178
|
openProductDetail(productId: number): Promise<void>;
|
|
174
179
|
closeProductDetail(): void;
|
|
175
|
-
getTimeslotBySchedule({ date, scheduleIds, }: {
|
|
180
|
+
getTimeslotBySchedule({ date, scheduleIds, resources, }: {
|
|
176
181
|
date: string;
|
|
177
|
-
scheduleIds
|
|
182
|
+
scheduleIds?: number[];
|
|
183
|
+
resources?: ProductResourceItem[];
|
|
178
184
|
}): {
|
|
179
185
|
start_time: string;
|
|
180
186
|
end_time: string;
|