@pisell/pisellos 0.0.44 → 0.0.45
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/Account/index.d.ts +2 -6
- package/dist/modules/Account/index.js +21 -103
- package/dist/modules/Account/types.d.ts +12 -1
- package/dist/modules/AccountList/index.d.ts +19 -0
- package/dist/modules/AccountList/index.js +224 -70
- package/dist/modules/AccountList/types.d.ts +33 -1
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/AccountList/utils.d.ts +9 -0
- package/dist/modules/AccountList/utils.js +25 -0
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +1 -1
- package/dist/modules/Cart/index.d.ts +5 -5
- package/dist/modules/Cart/index.js +32 -19
- package/dist/modules/Cart/types.d.ts +18 -4
- package/dist/modules/Cart/utils.d.ts +29 -5
- package/dist/modules/Cart/utils.js +72 -26
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -55
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +74 -23
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +10 -5
- package/dist/modules/Order/index.js +32 -16
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Product/index.d.ts +4 -1
- package/dist/modules/Product/index.js +22 -0
- package/dist/modules/Product/types.d.ts +7 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +4 -4
- package/dist/modules/Rules/index.js +11 -11
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/index.d.ts +8 -3
- package/dist/modules/Schedule/index.js +45 -5
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +8 -8
- package/dist/modules/Schedule/utils.d.ts +9 -3
- package/dist/modules/Schedule/utils.js +77 -48
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +5 -5
- package/dist/modules/Summary/index.js +7 -7
- package/dist/modules/Summary/types.d.ts +2 -2
- package/dist/modules/Summary/utils.d.ts +4 -4
- package/dist/modules/Summary/utils.js +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/request.d.ts +3 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +65 -16
- package/dist/solution/BookingByStep/index.js +553 -216
- package/dist/solution/BookingByStep/types.d.ts +2 -2
- package/dist/solution/BookingByStep/types.js +9 -9
- package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/products.js +3 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +5 -5
- package/dist/solution/BookingByStep/utils/resources.js +11 -11
- package/dist/solution/ShopDiscount/index.d.ts +4 -4
- package/dist/solution/ShopDiscount/index.js +16 -16
- package/dist/solution/ShopDiscount/types.d.ts +2 -2
- package/dist/solution/ShopDiscount/utils.js +1 -1
- package/lib/core/index.js +7 -2
- package/lib/modules/Account/index.d.ts +2 -6
- package/lib/modules/Account/index.js +15 -30
- package/lib/modules/Account/types.d.ts +12 -1
- package/lib/modules/AccountList/index.d.ts +19 -0
- package/lib/modules/AccountList/index.js +109 -12
- package/lib/modules/AccountList/types.d.ts +33 -1
- package/lib/modules/AccountList/utils.d.ts +9 -0
- package/lib/modules/AccountList/utils.js +39 -0
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +14 -3
- package/lib/modules/Cart/index.d.ts +5 -5
- package/lib/modules/Cart/index.js +27 -6
- package/lib/modules/Cart/types.d.ts +18 -4
- package/lib/modules/Cart/utils.d.ts +29 -5
- package/lib/modules/Cart/utils.js +47 -3
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +6 -6
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +37 -6
- package/lib/modules/Discount/index.d.ts +4 -4
- package/lib/modules/Discount/index.js +9 -2
- package/lib/modules/Guests/index.js +4 -1
- package/lib/modules/Order/index.d.ts +10 -5
- package/lib/modules/Order/index.js +11 -1
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +4 -1
- package/lib/modules/Product/index.js +16 -0
- package/lib/modules/Product/types.d.ts +7 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +4 -4
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.d.ts +8 -3
- package/lib/modules/Schedule/index.js +33 -2
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +8 -8
- package/lib/modules/Schedule/utils.d.ts +9 -3
- package/lib/modules/Schedule/utils.js +32 -4
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +5 -5
- package/lib/modules/Summary/types.d.ts +2 -2
- package/lib/modules/Summary/utils.d.ts +4 -4
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/request.d.ts +3 -3
- package/lib/plugins/request.js +48 -11
- package/lib/plugins/shopStore.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +65 -16
- package/lib/solution/BookingByStep/index.js +351 -39
- package/lib/solution/BookingByStep/types.d.ts +2 -2
- package/lib/solution/BookingByStep/types.js +36 -9
- package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/products.js +3 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +5 -5
- package/lib/solution/BookingByStep/utils/resources.js +103 -52
- package/lib/solution/BuyTickets/index.js +34 -20
- package/lib/solution/ShopDiscount/index.d.ts +4 -4
- package/lib/solution/ShopDiscount/index.js +10 -2
- package/lib/solution/ShopDiscount/types.d.ts +2 -2
- package/package.json +4 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -25,6 +26,7 @@ import { cloneDeep } from 'lodash-es';
|
|
|
25
26
|
import { AccountModule } from "../Account";
|
|
26
27
|
import { BaseModule } from "../BaseModule";
|
|
27
28
|
import { AccountListHooks } from "./types";
|
|
29
|
+
import { createHolderAccount } from "./utils";
|
|
28
30
|
export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
29
31
|
_inherits(AccountListModule, _BaseModule);
|
|
30
32
|
var _super = _createSuper(AccountListModule);
|
|
@@ -42,6 +44,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
42
44
|
isLoading: false,
|
|
43
45
|
error: null
|
|
44
46
|
});
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
45
48
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
46
49
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
47
50
|
_defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
|
|
@@ -61,6 +64,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
61
64
|
case 0:
|
|
62
65
|
this.core = core;
|
|
63
66
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
67
|
+
this.request = this.core.getPlugin('request');
|
|
64
68
|
if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.accountList)) {
|
|
65
69
|
recordList = cloneDeep(options.initialState.accountList || []);
|
|
66
70
|
this.store.accounts = [];
|
|
@@ -78,7 +82,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
82
|
if (options !== null && options !== void 0 && (_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
|
|
79
83
|
this.fatherModule = options.otherParams.fatherModule;
|
|
80
84
|
}
|
|
81
|
-
case
|
|
85
|
+
case 6:
|
|
82
86
|
case "end":
|
|
83
87
|
return _context.stop();
|
|
84
88
|
}
|
|
@@ -89,21 +93,67 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
89
93
|
}
|
|
90
94
|
return initialize;
|
|
91
95
|
}()
|
|
96
|
+
/**
|
|
97
|
+
* 创建账号并添加到列表中
|
|
98
|
+
* @param account 账号信息
|
|
99
|
+
* @param needEmit 是否需要触发事件
|
|
100
|
+
*/
|
|
101
|
+
}, {
|
|
102
|
+
key: "createAccountAndAdd",
|
|
103
|
+
value: (function () {
|
|
104
|
+
var _createAccountAndAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(account) {
|
|
105
|
+
var needEmit,
|
|
106
|
+
accountModule,
|
|
107
|
+
_args2 = arguments;
|
|
108
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
109
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
needEmit = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
|
|
112
|
+
if (!this.store.accounts.some(function (a) {
|
|
113
|
+
return a.getId() === account.id;
|
|
114
|
+
})) {
|
|
115
|
+
_context2.next = 3;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
return _context2.abrupt("return");
|
|
119
|
+
case 3:
|
|
120
|
+
this.store.accountList.push(account);
|
|
121
|
+
accountModule = new AccountModule("account_".concat(account.id));
|
|
122
|
+
this.core.registerModule(accountModule);
|
|
123
|
+
accountModule.setAccountInfo(account);
|
|
124
|
+
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts || []), [accountModule]);
|
|
125
|
+
if (!needEmit) {
|
|
126
|
+
_context2.next = 11;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
_context2.next = 11;
|
|
130
|
+
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
131
|
+
case 11:
|
|
132
|
+
case "end":
|
|
133
|
+
return _context2.stop();
|
|
134
|
+
}
|
|
135
|
+
}, _callee2, this);
|
|
136
|
+
}));
|
|
137
|
+
function createAccountAndAdd(_x3) {
|
|
138
|
+
return _createAccountAndAdd.apply(this, arguments);
|
|
139
|
+
}
|
|
140
|
+
return createAccountAndAdd;
|
|
141
|
+
}())
|
|
92
142
|
}, {
|
|
93
143
|
key: "addAccount",
|
|
94
144
|
value: function () {
|
|
95
|
-
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
145
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(account) {
|
|
96
146
|
var accountModule;
|
|
97
|
-
return _regeneratorRuntime().wrap(function
|
|
98
|
-
while (1) switch (
|
|
147
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
148
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
99
149
|
case 0:
|
|
100
|
-
|
|
150
|
+
_context3.prev = 0;
|
|
101
151
|
this.store.isLoading = true;
|
|
102
152
|
this.store.error = null;
|
|
103
153
|
if (!this.store.accounts.some(function (a) {
|
|
104
154
|
return a.getId() === account.id;
|
|
105
155
|
})) {
|
|
106
|
-
|
|
156
|
+
_context3.next = 6;
|
|
107
157
|
break;
|
|
108
158
|
}
|
|
109
159
|
throw new Error("Account with id ".concat(account.id, " already exists"));
|
|
@@ -116,29 +166,29 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
116
166
|
if (this.store.accounts.length === 1) {
|
|
117
167
|
this.setActiveAccount(accountModule.getId());
|
|
118
168
|
}
|
|
119
|
-
|
|
169
|
+
_context3.next = 14;
|
|
120
170
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
121
171
|
case 14:
|
|
122
|
-
|
|
172
|
+
_context3.next = 22;
|
|
123
173
|
break;
|
|
124
174
|
case 16:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.error(
|
|
128
|
-
this.store.error =
|
|
129
|
-
|
|
175
|
+
_context3.prev = 16;
|
|
176
|
+
_context3.t0 = _context3["catch"](0);
|
|
177
|
+
console.error(_context3.t0);
|
|
178
|
+
this.store.error = _context3.t0 instanceof Error ? _context3.t0.message : 'Failed to add account';
|
|
179
|
+
_context3.next = 22;
|
|
130
180
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
131
181
|
case 22:
|
|
132
|
-
|
|
182
|
+
_context3.prev = 22;
|
|
133
183
|
this.store.isLoading = false;
|
|
134
|
-
return
|
|
184
|
+
return _context3.finish(22);
|
|
135
185
|
case 25:
|
|
136
186
|
case "end":
|
|
137
|
-
return
|
|
187
|
+
return _context3.stop();
|
|
138
188
|
}
|
|
139
|
-
},
|
|
189
|
+
}, _callee3, this, [[0, 16, 22, 25]]);
|
|
140
190
|
}));
|
|
141
|
-
function addAccount(
|
|
191
|
+
function addAccount(_x4) {
|
|
142
192
|
return _addAccount.apply(this, arguments);
|
|
143
193
|
}
|
|
144
194
|
return addAccount;
|
|
@@ -146,17 +196,17 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
146
196
|
}, {
|
|
147
197
|
key: "updateAccount",
|
|
148
198
|
value: function () {
|
|
149
|
-
var _updateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
199
|
+
var _updateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id, updates) {
|
|
150
200
|
var account, index;
|
|
151
|
-
return _regeneratorRuntime().wrap(function
|
|
152
|
-
while (1) switch (
|
|
201
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
202
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
153
203
|
case 0:
|
|
154
|
-
|
|
204
|
+
_context4.prev = 0;
|
|
155
205
|
this.store.isLoading = true;
|
|
156
206
|
this.store.error = null;
|
|
157
207
|
account = this.getAccount(id);
|
|
158
208
|
if (account) {
|
|
159
|
-
|
|
209
|
+
_context4.next = 6;
|
|
160
210
|
break;
|
|
161
211
|
}
|
|
162
212
|
throw new Error("Account with id ".concat(id, " not found"));
|
|
@@ -173,28 +223,28 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
173
223
|
if (index !== -1) {
|
|
174
224
|
this.store.accountList[index] = updates;
|
|
175
225
|
}
|
|
176
|
-
|
|
226
|
+
_context4.next = 11;
|
|
177
227
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
178
228
|
case 11:
|
|
179
|
-
|
|
229
|
+
_context4.next = 18;
|
|
180
230
|
break;
|
|
181
231
|
case 13:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.store.error =
|
|
185
|
-
|
|
232
|
+
_context4.prev = 13;
|
|
233
|
+
_context4.t0 = _context4["catch"](0);
|
|
234
|
+
this.store.error = _context4.t0 instanceof Error ? _context4.t0.message : 'Failed to update account';
|
|
235
|
+
_context4.next = 18;
|
|
186
236
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
187
237
|
case 18:
|
|
188
|
-
|
|
238
|
+
_context4.prev = 18;
|
|
189
239
|
this.store.isLoading = false;
|
|
190
|
-
return
|
|
240
|
+
return _context4.finish(18);
|
|
191
241
|
case 21:
|
|
192
242
|
case "end":
|
|
193
|
-
return
|
|
243
|
+
return _context4.stop();
|
|
194
244
|
}
|
|
195
|
-
},
|
|
245
|
+
}, _callee4, this, [[0, 13, 18, 21]]);
|
|
196
246
|
}));
|
|
197
|
-
function updateAccount(
|
|
247
|
+
function updateAccount(_x5, _x6) {
|
|
198
248
|
return _updateAccount.apply(this, arguments);
|
|
199
249
|
}
|
|
200
250
|
return updateAccount;
|
|
@@ -202,9 +252,9 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
202
252
|
}, {
|
|
203
253
|
key: "updateAccountListById",
|
|
204
254
|
value: function () {
|
|
205
|
-
var _updateAccountListById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
206
|
-
return _regeneratorRuntime().wrap(function
|
|
207
|
-
while (1) switch (
|
|
255
|
+
var _updateAccountListById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, updates) {
|
|
256
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
257
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
208
258
|
case 0:
|
|
209
259
|
this.store.accountList = this.store.accountList.map(function (account) {
|
|
210
260
|
if (account.id === id) {
|
|
@@ -218,11 +268,11 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
218
268
|
});
|
|
219
269
|
case 2:
|
|
220
270
|
case "end":
|
|
221
|
-
return
|
|
271
|
+
return _context5.stop();
|
|
222
272
|
}
|
|
223
|
-
},
|
|
273
|
+
}, _callee5, this);
|
|
224
274
|
}));
|
|
225
|
-
function updateAccountListById(
|
|
275
|
+
function updateAccountListById(_x7, _x8) {
|
|
226
276
|
return _updateAccountListById.apply(this, arguments);
|
|
227
277
|
}
|
|
228
278
|
return updateAccountListById;
|
|
@@ -230,19 +280,19 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
230
280
|
}, {
|
|
231
281
|
key: "removeAccount",
|
|
232
282
|
value: function () {
|
|
233
|
-
var _removeAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
283
|
+
var _removeAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
234
284
|
var index;
|
|
235
|
-
return _regeneratorRuntime().wrap(function
|
|
236
|
-
while (1) switch (
|
|
285
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
286
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
237
287
|
case 0:
|
|
238
|
-
|
|
288
|
+
_context6.prev = 0;
|
|
239
289
|
this.store.isLoading = true;
|
|
240
290
|
this.store.error = null;
|
|
241
291
|
index = this.store.accounts.findIndex(function (a) {
|
|
242
292
|
return a.getId() === id;
|
|
243
293
|
});
|
|
244
294
|
if (!(index === -1)) {
|
|
245
|
-
|
|
295
|
+
_context6.next = 6;
|
|
246
296
|
break;
|
|
247
297
|
}
|
|
248
298
|
throw new Error("Account with id ".concat(id, " not found"));
|
|
@@ -252,28 +302,28 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
252
302
|
this.store.accountList = this.store.accountList.filter(function (account) {
|
|
253
303
|
return account.id !== id;
|
|
254
304
|
});
|
|
255
|
-
|
|
305
|
+
_context6.next = 11;
|
|
256
306
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
257
307
|
case 11:
|
|
258
|
-
|
|
308
|
+
_context6.next = 18;
|
|
259
309
|
break;
|
|
260
310
|
case 13:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.store.error =
|
|
264
|
-
|
|
311
|
+
_context6.prev = 13;
|
|
312
|
+
_context6.t0 = _context6["catch"](0);
|
|
313
|
+
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : 'Failed to remove account';
|
|
314
|
+
_context6.next = 18;
|
|
265
315
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
266
316
|
case 18:
|
|
267
|
-
|
|
317
|
+
_context6.prev = 18;
|
|
268
318
|
this.store.isLoading = false;
|
|
269
|
-
return
|
|
319
|
+
return _context6.finish(18);
|
|
270
320
|
case 21:
|
|
271
321
|
case "end":
|
|
272
|
-
return
|
|
322
|
+
return _context6.stop();
|
|
273
323
|
}
|
|
274
|
-
},
|
|
324
|
+
}, _callee6, this, [[0, 13, 18, 21]]);
|
|
275
325
|
}));
|
|
276
|
-
function removeAccount(
|
|
326
|
+
function removeAccount(_x9) {
|
|
277
327
|
return _removeAccount.apply(this, arguments);
|
|
278
328
|
}
|
|
279
329
|
return removeAccount;
|
|
@@ -293,34 +343,34 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
293
343
|
}, {
|
|
294
344
|
key: "clearAccounts",
|
|
295
345
|
value: function () {
|
|
296
|
-
var _clearAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
297
|
-
return _regeneratorRuntime().wrap(function
|
|
298
|
-
while (1) switch (
|
|
346
|
+
var _clearAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
347
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
348
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
299
349
|
case 0:
|
|
300
|
-
|
|
350
|
+
_context7.prev = 0;
|
|
301
351
|
this.store.isLoading = true;
|
|
302
352
|
this.store.error = null;
|
|
303
353
|
this.store.accounts = [];
|
|
304
|
-
|
|
354
|
+
_context7.next = 6;
|
|
305
355
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
306
356
|
case 6:
|
|
307
|
-
|
|
357
|
+
_context7.next = 13;
|
|
308
358
|
break;
|
|
309
359
|
case 8:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.store.error =
|
|
313
|
-
|
|
360
|
+
_context7.prev = 8;
|
|
361
|
+
_context7.t0 = _context7["catch"](0);
|
|
362
|
+
this.store.error = _context7.t0 instanceof Error ? _context7.t0.message : 'Failed to clear accounts';
|
|
363
|
+
_context7.next = 13;
|
|
314
364
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
315
365
|
case 13:
|
|
316
|
-
|
|
366
|
+
_context7.prev = 13;
|
|
317
367
|
this.store.isLoading = false;
|
|
318
|
-
return
|
|
368
|
+
return _context7.finish(13);
|
|
319
369
|
case 16:
|
|
320
370
|
case "end":
|
|
321
|
-
return
|
|
371
|
+
return _context7.stop();
|
|
322
372
|
}
|
|
323
|
-
},
|
|
373
|
+
}, _callee7, this, [[0, 8, 13, 16]]);
|
|
324
374
|
}));
|
|
325
375
|
function clearAccounts() {
|
|
326
376
|
return _clearAccounts.apply(this, arguments);
|
|
@@ -364,6 +414,110 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
414
|
});
|
|
365
415
|
}
|
|
366
416
|
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* 批量添加holder类型账号
|
|
420
|
+
* @param holders 账号信息列表
|
|
421
|
+
* @param customerId 账户id
|
|
422
|
+
*/
|
|
423
|
+
}, {
|
|
424
|
+
key: "addHolderAccounts",
|
|
425
|
+
value: (function () {
|
|
426
|
+
var _addHolderAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(holders, customerId) {
|
|
427
|
+
var _iterator, _step, holder, account;
|
|
428
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
429
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
430
|
+
case 0:
|
|
431
|
+
_iterator = _createForOfIteratorHelper(holders);
|
|
432
|
+
_context8.prev = 1;
|
|
433
|
+
_iterator.s();
|
|
434
|
+
case 3:
|
|
435
|
+
if ((_step = _iterator.n()).done) {
|
|
436
|
+
_context8.next = 10;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
holder = _step.value;
|
|
440
|
+
account = createHolderAccount(holder, customerId);
|
|
441
|
+
_context8.next = 8;
|
|
442
|
+
return this.createAccountAndAdd(account, false);
|
|
443
|
+
case 8:
|
|
444
|
+
_context8.next = 3;
|
|
445
|
+
break;
|
|
446
|
+
case 10:
|
|
447
|
+
_context8.next = 15;
|
|
448
|
+
break;
|
|
449
|
+
case 12:
|
|
450
|
+
_context8.prev = 12;
|
|
451
|
+
_context8.t0 = _context8["catch"](1);
|
|
452
|
+
_iterator.e(_context8.t0);
|
|
453
|
+
case 15:
|
|
454
|
+
_context8.prev = 15;
|
|
455
|
+
_iterator.f();
|
|
456
|
+
return _context8.finish(15);
|
|
457
|
+
case 18:
|
|
458
|
+
_context8.next = 20;
|
|
459
|
+
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
460
|
+
case 20:
|
|
461
|
+
case "end":
|
|
462
|
+
return _context8.stop();
|
|
463
|
+
}
|
|
464
|
+
}, _callee8, this, [[1, 12, 15, 18]]);
|
|
465
|
+
}));
|
|
466
|
+
function addHolderAccounts(_x10, _x11) {
|
|
467
|
+
return _addHolderAccounts.apply(this, arguments);
|
|
468
|
+
}
|
|
469
|
+
return addHolderAccounts;
|
|
470
|
+
}()
|
|
471
|
+
/**
|
|
472
|
+
* 获取holder类型账户列表
|
|
473
|
+
* @param params
|
|
474
|
+
*/
|
|
475
|
+
)
|
|
476
|
+
}, {
|
|
477
|
+
key: "fetchHolderAccounts",
|
|
478
|
+
value: (function () {
|
|
479
|
+
var _fetchHolderAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
480
|
+
var url, _ref, form_id, shop_id, num, skip, customer_id, _res$data, res;
|
|
481
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
482
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
483
|
+
case 0:
|
|
484
|
+
url = params.url || '/account/holder';
|
|
485
|
+
_ref = (params === null || params === void 0 ? void 0 : params.query) || {}, form_id = _ref.form_id, shop_id = _ref.shop_id, num = _ref.num, skip = _ref.skip, customer_id = _ref.customer_id;
|
|
486
|
+
_context9.prev = 2;
|
|
487
|
+
_context9.next = 5;
|
|
488
|
+
return this.request.get(url, {
|
|
489
|
+
customer_id: customer_id,
|
|
490
|
+
form_id: form_id,
|
|
491
|
+
shop_id: shop_id,
|
|
492
|
+
num: num || 100,
|
|
493
|
+
skip: skip || 1
|
|
494
|
+
});
|
|
495
|
+
case 5:
|
|
496
|
+
res = _context9.sent;
|
|
497
|
+
if (!(res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && (_res$data = _res$data.list) !== null && _res$data !== void 0 && _res$data.length)) {
|
|
498
|
+
_context9.next = 9;
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
_context9.next = 9;
|
|
502
|
+
return this.addHolderAccounts(res.data.list, customer_id);
|
|
503
|
+
case 9:
|
|
504
|
+
_context9.next = 14;
|
|
505
|
+
break;
|
|
506
|
+
case 11:
|
|
507
|
+
_context9.prev = 11;
|
|
508
|
+
_context9.t0 = _context9["catch"](2);
|
|
509
|
+
console.error(_context9.t0);
|
|
510
|
+
case 14:
|
|
511
|
+
case "end":
|
|
512
|
+
return _context9.stop();
|
|
513
|
+
}
|
|
514
|
+
}, _callee9, this, [[2, 11]]);
|
|
515
|
+
}));
|
|
516
|
+
function fetchHolderAccounts(_x12) {
|
|
517
|
+
return _fetchHolderAccounts.apply(this, arguments);
|
|
518
|
+
}
|
|
519
|
+
return fetchHolderAccounts;
|
|
520
|
+
}())
|
|
367
521
|
}]);
|
|
368
522
|
return AccountListModule;
|
|
369
523
|
}(BaseModule);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, AccountModule } from
|
|
1
|
+
import { Account, AccountModule } from '../Account';
|
|
2
2
|
export declare enum AccountListHooks {
|
|
3
3
|
OnAccountListUpdate = "accountList:onUpdate",
|
|
4
4
|
OnAccountListError = "accountList:onError"
|
|
@@ -27,11 +27,43 @@ export interface AccountListState {
|
|
|
27
27
|
* 账户列表模块 API
|
|
28
28
|
*/
|
|
29
29
|
export interface AccountListModuleAPI {
|
|
30
|
+
/** 添加账户 */
|
|
30
31
|
addAccount: (account: Account) => Promise<void>;
|
|
32
|
+
/** 更新账户 */
|
|
31
33
|
updateAccount: (id: string, updates: Partial<AccountModule>) => Promise<void>;
|
|
34
|
+
/** 删除账户 */
|
|
32
35
|
removeAccount: (id: string) => Promise<void>;
|
|
36
|
+
/** 获取账户列表 */
|
|
33
37
|
getAccounts: () => AccountModule[];
|
|
38
|
+
/** 获取单个账户 */
|
|
34
39
|
getAccount: (id: string) => AccountModule | null;
|
|
40
|
+
/** 清空账户列表 */
|
|
35
41
|
clearAccounts: () => Promise<void>;
|
|
42
|
+
/** 批量添加账户 */
|
|
36
43
|
addAccounts: (accounts: AccountModule[]) => Promise<void>;
|
|
44
|
+
/** 获取holder类型账户列表 */
|
|
45
|
+
fetchHolderAccounts: (params: IFetchHolderAccountsParams) => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 获取holder类型账户列表参数
|
|
49
|
+
*/
|
|
50
|
+
export interface IFetchHolderAccountsParams {
|
|
51
|
+
url?: string;
|
|
52
|
+
query: {
|
|
53
|
+
customer_id: number;
|
|
54
|
+
form_id: string | number;
|
|
55
|
+
shop_id: string | number;
|
|
56
|
+
num?: number;
|
|
57
|
+
skip?: number;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* holder类型数据
|
|
62
|
+
*/
|
|
63
|
+
export interface IHolder {
|
|
64
|
+
created_at: string;
|
|
65
|
+
form_id: number;
|
|
66
|
+
form_record_id: number;
|
|
67
|
+
main_field: string;
|
|
68
|
+
customer_cover?: string;
|
|
37
69
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
/**
|
|
8
|
+
* 创建holder类型账号
|
|
9
|
+
* @param holder
|
|
10
|
+
* @param customer_id 账户id
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export var createHolderAccount = function createHolderAccount(holder, customerId) {
|
|
14
|
+
var account = {
|
|
15
|
+
id: holder.form_record_id,
|
|
16
|
+
name: holder.main_field,
|
|
17
|
+
username: holder.main_field,
|
|
18
|
+
avatar: (holder === null || holder === void 0 ? void 0 : holder.customer_cover) || '',
|
|
19
|
+
type: 'holder',
|
|
20
|
+
_origin: _objectSpread(_objectSpread({}, holder), {}, {
|
|
21
|
+
customer_id: customerId
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
return account;
|
|
25
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PisellCore } from
|
|
1
|
+
import { PisellCore } from '../types';
|
|
2
2
|
export declare class BaseModule {
|
|
3
3
|
protected defaultName: string;
|
|
4
4
|
protected defaultVersion: string;
|
|
@@ -8,7 +8,7 @@ export declare class BaseModule {
|
|
|
8
8
|
protected core: PisellCore;
|
|
9
9
|
constructor(name?: string, version?: string);
|
|
10
10
|
destroy(): void;
|
|
11
|
-
checkSaveCache({ cacheId, fatherModule, store, cacheKey }: {
|
|
11
|
+
checkSaveCache({ cacheId, fatherModule, store, cacheKey, }: {
|
|
12
12
|
cacheId: string | undefined;
|
|
13
13
|
fatherModule: string | undefined;
|
|
14
14
|
store: any;
|
|
@@ -33,7 +33,7 @@ export var BaseModule = /*#__PURE__*/function () {
|
|
|
33
33
|
fatherModule = _ref.fatherModule,
|
|
34
34
|
store = _ref.store,
|
|
35
35
|
cacheKey = _ref.cacheKey;
|
|
36
|
-
var window = this.core.getPlugin(
|
|
36
|
+
var window = this.core.getPlugin('window');
|
|
37
37
|
if (cacheId) {
|
|
38
38
|
if (fatherModule) {
|
|
39
39
|
var currentCacheData = window.sessionStorage.getItem(fatherModule);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { CartItem, CartModuleAPI, IAddItemParams, IUpdateItemParams } 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
|
*/
|
|
@@ -58,7 +58,7 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
58
58
|
/**
|
|
59
59
|
* 清除购物车商品中的信息
|
|
60
60
|
*/
|
|
61
|
-
deleteCartItemInfo(types:
|
|
61
|
+
deleteCartItemInfo(types: 'resource' | 'time'): void;
|
|
62
62
|
/**
|
|
63
63
|
* 清除购物车
|
|
64
64
|
*/
|