@pisell/pisellos 3.0.4 → 3.0.6
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 +20 -1
- package/dist/modules/AccountList/index.js +243 -75
- 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 +8 -5
- package/dist/modules/Cart/index.js +101 -25
- package/dist/modules/Cart/types.d.ts +82 -5
- package/dist/modules/Cart/types.js +22 -0
- package/dist/modules/Cart/utils.d.ts +106 -13
- package/dist/modules/Cart/utils.js +289 -76
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -58
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +81 -30
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +11 -5
- package/dist/modules/Order/index.js +47 -18
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +15 -0
- package/dist/modules/Product/index.d.ts +14 -1
- package/dist/modules/Product/index.js +35 -0
- package/dist/modules/Product/types.d.ts +27 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/types.d.ts +1 -0
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +121 -53
- package/dist/modules/Rules/types.d.ts +5 -1
- package/dist/modules/Schedule/index.d.ts +18 -0
- package/dist/modules/Schedule/index.js +111 -0
- package/dist/modules/Schedule/type.d.ts +157 -0
- package/dist/modules/Schedule/type.js +1 -0
- package/dist/modules/Schedule/types.d.ts +182 -0
- package/dist/modules/Schedule/types.js +1 -0
- package/dist/modules/Schedule/utils.d.ts +67 -0
- package/dist/modules/Schedule/utils.js +729 -0
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +12 -5
- package/dist/modules/Summary/index.js +33 -7
- package/dist/modules/Summary/types.d.ts +23 -2
- package/dist/modules/Summary/utils.d.ts +14 -4
- package/dist/modules/Summary/utils.js +46 -4
- package/dist/modules/index.d.ts +10 -0
- package/dist/modules/index.js +11 -1
- 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 +97 -24
- package/dist/solution/BookingByStep/index.js +1024 -322
- package/dist/solution/BookingByStep/types.d.ts +3 -10
- package/dist/solution/BookingByStep/types.js +11 -15
- 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 +60 -6
- package/dist/solution/BookingByStep/utils/resources.js +293 -52
- 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 +20 -1
- package/lib/modules/AccountList/index.js +122 -13
- 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 +8 -5
- package/lib/modules/Cart/index.js +81 -8
- package/lib/modules/Cart/types.d.ts +82 -5
- package/lib/modules/Cart/types.js +20 -2
- package/lib/modules/Cart/utils.d.ts +106 -13
- package/lib/modules/Cart/utils.js +188 -45
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +13 -28
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +47 -13
- 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 +11 -5
- package/lib/modules/Order/index.js +24 -3
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +45 -0
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +14 -1
- package/lib/modules/Product/index.js +19 -0
- package/lib/modules/Product/types.d.ts +27 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/types.d.ts +1 -0
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +118 -43
- package/lib/modules/Rules/types.d.ts +5 -1
- package/lib/modules/Schedule/index.d.ts +18 -0
- package/lib/modules/Schedule/index.js +81 -0
- package/lib/modules/Schedule/type.d.ts +157 -0
- package/lib/modules/Schedule/type.js +17 -0
- package/lib/modules/Schedule/types.d.ts +182 -0
- package/lib/modules/Schedule/types.js +17 -0
- package/lib/modules/Schedule/utils.d.ts +67 -0
- package/lib/modules/Schedule/utils.js +600 -0
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +12 -5
- package/lib/modules/Summary/index.js +15 -1
- package/lib/modules/Summary/types.d.ts +23 -2
- package/lib/modules/Summary/utils.d.ts +14 -4
- package/lib/modules/Summary/utils.js +30 -1
- package/lib/modules/index.d.ts +10 -0
- package/lib/modules/index.js +21 -1
- 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 +97 -24
- package/lib/solution/BookingByStep/index.js +693 -145
- package/lib/solution/BookingByStep/types.d.ts +3 -10
- package/lib/solution/BookingByStep/types.js +37 -14
- 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 +60 -6
- package/lib/solution/BookingByStep/utils/resources.js +286 -54
- 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
- package/dist/core/index.d.ts.map +0 -1
- package/dist/effects/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/modules/Account/index.d.ts.map +0 -1
- package/dist/modules/Account/types.d.ts.map +0 -1
- package/dist/modules/AccountList/types.d.ts.map +0 -1
- package/dist/modules/Cart/index.d.ts.map +0 -1
- package/dist/modules/Cart/types.d.ts.map +0 -1
- package/dist/modules/Date/types.d.ts.map +0 -1
- package/dist/modules/Date/utils.d.ts.map +0 -1
- package/dist/modules/Guests/index.d.ts.map +0 -1
- package/dist/modules/Guests/types.d.ts.map +0 -1
- package/dist/modules/Order/index.d.ts.map +0 -1
- package/dist/modules/Order/types.d.ts.map +0 -1
- package/dist/modules/Payment/index.d.ts.map +0 -1
- package/dist/modules/Payment/types.d.ts.map +0 -1
- package/dist/modules/Product/index.d.ts.map +0 -1
- package/dist/modules/Product/types.d.ts.map +0 -1
- package/dist/modules/ProductList/types.d.ts.map +0 -1
- package/dist/modules/Resource/index.d.ts.map +0 -1
- package/dist/modules/Resource/types.d.ts.map +0 -1
- package/dist/modules/Resource/utils.d.ts.map +0 -1
- package/dist/modules/Rules/types.d.ts.map +0 -1
- package/dist/modules/Step/index.d.ts.map +0 -1
- package/dist/modules/Step/tyeps.d.ts.map +0 -1
- package/dist/modules/Summary/index.d.ts.map +0 -1
- package/dist/modules/Summary/types.d.ts.map +0 -1
- package/dist/modules/Summary/utils.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/request.d.ts.map +0 -1
- package/dist/plugins/shopStore.d.ts.map +0 -1
- package/dist/plugins/window.d.ts.map +0 -1
- package/dist/solution/BookingByStep/types.d.ts.map +0 -1
- package/dist/solution/BookingByStep/utils/products.d.ts.map +0 -1
- package/dist/solution/BuyTickets/index.d.ts.map +0 -1
- package/dist/solution/BuyTickets/types.d.ts.map +0 -1
- package/dist/solution/PlaceOrder/index.d.ts.map +0 -1
- package/dist/solution/ShopDiscount/types.d.ts.map +0 -1
- package/dist/solution/ShopDiscount/utils.d.ts.map +0 -1
- package/dist/solution/index.d.ts.map +0 -1
- package/dist/store/createStore.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
|
@@ -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,23 +93,76 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
89
93
|
}
|
|
90
94
|
return initialize;
|
|
91
95
|
}()
|
|
96
|
+
/**
|
|
97
|
+
* 创建账号并添加到列表中
|
|
98
|
+
* @param account 账号信息
|
|
99
|
+
* @param needEmit 是否需要触发事件
|
|
100
|
+
*/
|
|
92
101
|
}, {
|
|
93
|
-
key: "
|
|
94
|
-
value: function () {
|
|
95
|
-
var
|
|
96
|
-
var
|
|
102
|
+
key: "createAccountAndAdd",
|
|
103
|
+
value: (function () {
|
|
104
|
+
var _createAccountAndAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(account) {
|
|
105
|
+
var needEmit,
|
|
106
|
+
tempAccountModule,
|
|
107
|
+
accountModule,
|
|
108
|
+
_args2 = arguments;
|
|
97
109
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
98
110
|
while (1) switch (_context2.prev = _context2.next) {
|
|
99
111
|
case 0:
|
|
100
|
-
|
|
112
|
+
needEmit = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
|
|
113
|
+
tempAccountModule = this.store.accounts.find(function (a) {
|
|
114
|
+
return a.getId() === account.id;
|
|
115
|
+
}); // 如果账号已经存在,则直接返回
|
|
116
|
+
if (!tempAccountModule) {
|
|
117
|
+
_context2.next = 4;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
return _context2.abrupt("return", tempAccountModule);
|
|
121
|
+
case 4:
|
|
122
|
+
this.store.accountList.push(account);
|
|
123
|
+
accountModule = new AccountModule("account_".concat(account.id));
|
|
124
|
+
this.core.registerModule(accountModule);
|
|
125
|
+
accountModule.setAccountInfo(account);
|
|
126
|
+
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts || []), [accountModule]);
|
|
127
|
+
if (!needEmit) {
|
|
128
|
+
_context2.next = 12;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
_context2.next = 12;
|
|
132
|
+
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
133
|
+
case 12:
|
|
134
|
+
return _context2.abrupt("return", accountModule);
|
|
135
|
+
case 13:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context2.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee2, this);
|
|
140
|
+
}));
|
|
141
|
+
function createAccountAndAdd(_x3) {
|
|
142
|
+
return _createAccountAndAdd.apply(this, arguments);
|
|
143
|
+
}
|
|
144
|
+
return createAccountAndAdd;
|
|
145
|
+
}())
|
|
146
|
+
}, {
|
|
147
|
+
key: "addAccount",
|
|
148
|
+
value: function () {
|
|
149
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(account) {
|
|
150
|
+
var currentAccountModule, accountModule;
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
152
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
_context3.prev = 0;
|
|
101
155
|
this.store.isLoading = true;
|
|
102
156
|
this.store.error = null;
|
|
103
157
|
if (!this.store.accounts.some(function (a) {
|
|
104
158
|
return a.getId() === account.id;
|
|
105
159
|
})) {
|
|
106
|
-
|
|
160
|
+
_context3.next = 6;
|
|
107
161
|
break;
|
|
108
162
|
}
|
|
163
|
+
currentAccountModule = this.store.accounts.find(function (n) {
|
|
164
|
+
return n.getId() === account.id;
|
|
165
|
+
});
|
|
109
166
|
throw new Error("Account with id ".concat(account.id, " already exists"));
|
|
110
167
|
case 6:
|
|
111
168
|
this.store.accountList.push(account);
|
|
@@ -116,29 +173,30 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
116
173
|
if (this.store.accounts.length === 1) {
|
|
117
174
|
this.setActiveAccount(accountModule.getId());
|
|
118
175
|
}
|
|
119
|
-
|
|
176
|
+
currentAccountModule = accountModule;
|
|
177
|
+
_context3.next = 15;
|
|
120
178
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
121
|
-
case
|
|
122
|
-
|
|
179
|
+
case 15:
|
|
180
|
+
_context3.next = 23;
|
|
123
181
|
break;
|
|
124
|
-
case
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.error(
|
|
128
|
-
this.store.error =
|
|
129
|
-
|
|
182
|
+
case 17:
|
|
183
|
+
_context3.prev = 17;
|
|
184
|
+
_context3.t0 = _context3["catch"](0);
|
|
185
|
+
console.error(_context3.t0);
|
|
186
|
+
this.store.error = _context3.t0 instanceof Error ? _context3.t0.message : 'Failed to add account';
|
|
187
|
+
_context3.next = 23;
|
|
130
188
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
131
|
-
case
|
|
132
|
-
|
|
189
|
+
case 23:
|
|
190
|
+
_context3.prev = 23;
|
|
133
191
|
this.store.isLoading = false;
|
|
134
|
-
return
|
|
135
|
-
case
|
|
192
|
+
return _context3.abrupt("return", currentAccountModule);
|
|
193
|
+
case 27:
|
|
136
194
|
case "end":
|
|
137
|
-
return
|
|
195
|
+
return _context3.stop();
|
|
138
196
|
}
|
|
139
|
-
},
|
|
197
|
+
}, _callee3, this, [[0, 17, 23, 27]]);
|
|
140
198
|
}));
|
|
141
|
-
function addAccount(
|
|
199
|
+
function addAccount(_x4) {
|
|
142
200
|
return _addAccount.apply(this, arguments);
|
|
143
201
|
}
|
|
144
202
|
return addAccount;
|
|
@@ -146,17 +204,17 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
146
204
|
}, {
|
|
147
205
|
key: "updateAccount",
|
|
148
206
|
value: function () {
|
|
149
|
-
var _updateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
207
|
+
var _updateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id, updates) {
|
|
150
208
|
var account, index;
|
|
151
|
-
return _regeneratorRuntime().wrap(function
|
|
152
|
-
while (1) switch (
|
|
209
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
210
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
153
211
|
case 0:
|
|
154
|
-
|
|
212
|
+
_context4.prev = 0;
|
|
155
213
|
this.store.isLoading = true;
|
|
156
214
|
this.store.error = null;
|
|
157
215
|
account = this.getAccount(id);
|
|
158
216
|
if (account) {
|
|
159
|
-
|
|
217
|
+
_context4.next = 6;
|
|
160
218
|
break;
|
|
161
219
|
}
|
|
162
220
|
throw new Error("Account with id ".concat(id, " not found"));
|
|
@@ -173,28 +231,28 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
173
231
|
if (index !== -1) {
|
|
174
232
|
this.store.accountList[index] = updates;
|
|
175
233
|
}
|
|
176
|
-
|
|
234
|
+
_context4.next = 11;
|
|
177
235
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
178
236
|
case 11:
|
|
179
|
-
|
|
237
|
+
_context4.next = 18;
|
|
180
238
|
break;
|
|
181
239
|
case 13:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.store.error =
|
|
185
|
-
|
|
240
|
+
_context4.prev = 13;
|
|
241
|
+
_context4.t0 = _context4["catch"](0);
|
|
242
|
+
this.store.error = _context4.t0 instanceof Error ? _context4.t0.message : 'Failed to update account';
|
|
243
|
+
_context4.next = 18;
|
|
186
244
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
187
245
|
case 18:
|
|
188
|
-
|
|
246
|
+
_context4.prev = 18;
|
|
189
247
|
this.store.isLoading = false;
|
|
190
|
-
return
|
|
248
|
+
return _context4.finish(18);
|
|
191
249
|
case 21:
|
|
192
250
|
case "end":
|
|
193
|
-
return
|
|
251
|
+
return _context4.stop();
|
|
194
252
|
}
|
|
195
|
-
},
|
|
253
|
+
}, _callee4, this, [[0, 13, 18, 21]]);
|
|
196
254
|
}));
|
|
197
|
-
function updateAccount(
|
|
255
|
+
function updateAccount(_x5, _x6) {
|
|
198
256
|
return _updateAccount.apply(this, arguments);
|
|
199
257
|
}
|
|
200
258
|
return updateAccount;
|
|
@@ -202,9 +260,9 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
202
260
|
}, {
|
|
203
261
|
key: "updateAccountListById",
|
|
204
262
|
value: function () {
|
|
205
|
-
var _updateAccountListById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
206
|
-
return _regeneratorRuntime().wrap(function
|
|
207
|
-
while (1) switch (
|
|
263
|
+
var _updateAccountListById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, updates) {
|
|
264
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
265
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
208
266
|
case 0:
|
|
209
267
|
this.store.accountList = this.store.accountList.map(function (account) {
|
|
210
268
|
if (account.id === id) {
|
|
@@ -218,11 +276,11 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
218
276
|
});
|
|
219
277
|
case 2:
|
|
220
278
|
case "end":
|
|
221
|
-
return
|
|
279
|
+
return _context5.stop();
|
|
222
280
|
}
|
|
223
|
-
},
|
|
281
|
+
}, _callee5, this);
|
|
224
282
|
}));
|
|
225
|
-
function updateAccountListById(
|
|
283
|
+
function updateAccountListById(_x7, _x8) {
|
|
226
284
|
return _updateAccountListById.apply(this, arguments);
|
|
227
285
|
}
|
|
228
286
|
return updateAccountListById;
|
|
@@ -230,19 +288,19 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
230
288
|
}, {
|
|
231
289
|
key: "removeAccount",
|
|
232
290
|
value: function () {
|
|
233
|
-
var _removeAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
291
|
+
var _removeAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
234
292
|
var index;
|
|
235
|
-
return _regeneratorRuntime().wrap(function
|
|
236
|
-
while (1) switch (
|
|
293
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
294
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
237
295
|
case 0:
|
|
238
|
-
|
|
296
|
+
_context6.prev = 0;
|
|
239
297
|
this.store.isLoading = true;
|
|
240
298
|
this.store.error = null;
|
|
241
299
|
index = this.store.accounts.findIndex(function (a) {
|
|
242
300
|
return a.getId() === id;
|
|
243
301
|
});
|
|
244
302
|
if (!(index === -1)) {
|
|
245
|
-
|
|
303
|
+
_context6.next = 6;
|
|
246
304
|
break;
|
|
247
305
|
}
|
|
248
306
|
throw new Error("Account with id ".concat(id, " not found"));
|
|
@@ -252,28 +310,28 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
252
310
|
this.store.accountList = this.store.accountList.filter(function (account) {
|
|
253
311
|
return account.id !== id;
|
|
254
312
|
});
|
|
255
|
-
|
|
313
|
+
_context6.next = 11;
|
|
256
314
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
257
315
|
case 11:
|
|
258
|
-
|
|
316
|
+
_context6.next = 18;
|
|
259
317
|
break;
|
|
260
318
|
case 13:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.store.error =
|
|
264
|
-
|
|
319
|
+
_context6.prev = 13;
|
|
320
|
+
_context6.t0 = _context6["catch"](0);
|
|
321
|
+
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : 'Failed to remove account';
|
|
322
|
+
_context6.next = 18;
|
|
265
323
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
266
324
|
case 18:
|
|
267
|
-
|
|
325
|
+
_context6.prev = 18;
|
|
268
326
|
this.store.isLoading = false;
|
|
269
|
-
return
|
|
327
|
+
return _context6.finish(18);
|
|
270
328
|
case 21:
|
|
271
329
|
case "end":
|
|
272
|
-
return
|
|
330
|
+
return _context6.stop();
|
|
273
331
|
}
|
|
274
|
-
},
|
|
332
|
+
}, _callee6, this, [[0, 13, 18, 21]]);
|
|
275
333
|
}));
|
|
276
|
-
function removeAccount(
|
|
334
|
+
function removeAccount(_x9) {
|
|
277
335
|
return _removeAccount.apply(this, arguments);
|
|
278
336
|
}
|
|
279
337
|
return removeAccount;
|
|
@@ -293,34 +351,34 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
293
351
|
}, {
|
|
294
352
|
key: "clearAccounts",
|
|
295
353
|
value: function () {
|
|
296
|
-
var _clearAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
297
|
-
return _regeneratorRuntime().wrap(function
|
|
298
|
-
while (1) switch (
|
|
354
|
+
var _clearAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
355
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
356
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
299
357
|
case 0:
|
|
300
|
-
|
|
358
|
+
_context7.prev = 0;
|
|
301
359
|
this.store.isLoading = true;
|
|
302
360
|
this.store.error = null;
|
|
303
361
|
this.store.accounts = [];
|
|
304
|
-
|
|
362
|
+
_context7.next = 6;
|
|
305
363
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
306
364
|
case 6:
|
|
307
|
-
|
|
365
|
+
_context7.next = 13;
|
|
308
366
|
break;
|
|
309
367
|
case 8:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.store.error =
|
|
313
|
-
|
|
368
|
+
_context7.prev = 8;
|
|
369
|
+
_context7.t0 = _context7["catch"](0);
|
|
370
|
+
this.store.error = _context7.t0 instanceof Error ? _context7.t0.message : 'Failed to clear accounts';
|
|
371
|
+
_context7.next = 13;
|
|
314
372
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
315
373
|
case 13:
|
|
316
|
-
|
|
374
|
+
_context7.prev = 13;
|
|
317
375
|
this.store.isLoading = false;
|
|
318
|
-
return
|
|
376
|
+
return _context7.finish(13);
|
|
319
377
|
case 16:
|
|
320
378
|
case "end":
|
|
321
|
-
return
|
|
379
|
+
return _context7.stop();
|
|
322
380
|
}
|
|
323
|
-
},
|
|
381
|
+
}, _callee7, this, [[0, 8, 13, 16]]);
|
|
324
382
|
}));
|
|
325
383
|
function clearAccounts() {
|
|
326
384
|
return _clearAccounts.apply(this, arguments);
|
|
@@ -364,6 +422,116 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
422
|
});
|
|
365
423
|
}
|
|
366
424
|
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 批量添加holder类型账号
|
|
428
|
+
* @param holders 账号信息列表
|
|
429
|
+
* @param customerId 账户id
|
|
430
|
+
*/
|
|
431
|
+
}, {
|
|
432
|
+
key: "addHolderAccounts",
|
|
433
|
+
value: (function () {
|
|
434
|
+
var _addHolderAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(holders, customerId) {
|
|
435
|
+
var accountModules, _iterator, _step, holder, account, accountModule;
|
|
436
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
437
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
438
|
+
case 0:
|
|
439
|
+
accountModules = [];
|
|
440
|
+
_iterator = _createForOfIteratorHelper(holders);
|
|
441
|
+
_context8.prev = 2;
|
|
442
|
+
_iterator.s();
|
|
443
|
+
case 4:
|
|
444
|
+
if ((_step = _iterator.n()).done) {
|
|
445
|
+
_context8.next = 13;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
holder = _step.value;
|
|
449
|
+
account = createHolderAccount(holder, customerId);
|
|
450
|
+
_context8.next = 9;
|
|
451
|
+
return this.createAccountAndAdd(account, false);
|
|
452
|
+
case 9:
|
|
453
|
+
accountModule = _context8.sent;
|
|
454
|
+
accountModules.push(accountModule);
|
|
455
|
+
case 11:
|
|
456
|
+
_context8.next = 4;
|
|
457
|
+
break;
|
|
458
|
+
case 13:
|
|
459
|
+
_context8.next = 18;
|
|
460
|
+
break;
|
|
461
|
+
case 15:
|
|
462
|
+
_context8.prev = 15;
|
|
463
|
+
_context8.t0 = _context8["catch"](2);
|
|
464
|
+
_iterator.e(_context8.t0);
|
|
465
|
+
case 18:
|
|
466
|
+
_context8.prev = 18;
|
|
467
|
+
_iterator.f();
|
|
468
|
+
return _context8.finish(18);
|
|
469
|
+
case 21:
|
|
470
|
+
_context8.next = 23;
|
|
471
|
+
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
472
|
+
case 23:
|
|
473
|
+
return _context8.abrupt("return", accountModules);
|
|
474
|
+
case 24:
|
|
475
|
+
case "end":
|
|
476
|
+
return _context8.stop();
|
|
477
|
+
}
|
|
478
|
+
}, _callee8, this, [[2, 15, 18, 21]]);
|
|
479
|
+
}));
|
|
480
|
+
function addHolderAccounts(_x10, _x11) {
|
|
481
|
+
return _addHolderAccounts.apply(this, arguments);
|
|
482
|
+
}
|
|
483
|
+
return addHolderAccounts;
|
|
484
|
+
}()
|
|
485
|
+
/**
|
|
486
|
+
* 获取holder类型账户列表
|
|
487
|
+
* @param params
|
|
488
|
+
*/
|
|
489
|
+
)
|
|
490
|
+
}, {
|
|
491
|
+
key: "fetchHolderAccounts",
|
|
492
|
+
value: (function () {
|
|
493
|
+
var _fetchHolderAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
494
|
+
var url, _ref, form_id, shop_id, num, skip, customer_id, _res$data, res;
|
|
495
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
496
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
497
|
+
case 0:
|
|
498
|
+
url = params.url || '/account/holder';
|
|
499
|
+
_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;
|
|
500
|
+
_context9.prev = 2;
|
|
501
|
+
_context9.next = 5;
|
|
502
|
+
return this.request.get(url, {
|
|
503
|
+
customer_id: customer_id,
|
|
504
|
+
form_id: form_id,
|
|
505
|
+
shop_id: shop_id,
|
|
506
|
+
num: num || 100,
|
|
507
|
+
skip: skip || 1
|
|
508
|
+
});
|
|
509
|
+
case 5:
|
|
510
|
+
res = _context9.sent;
|
|
511
|
+
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)) {
|
|
512
|
+
_context9.next = 9;
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
_context9.next = 9;
|
|
516
|
+
return this.addHolderAccounts(res.data.list, customer_id);
|
|
517
|
+
case 9:
|
|
518
|
+
_context9.next = 14;
|
|
519
|
+
break;
|
|
520
|
+
case 11:
|
|
521
|
+
_context9.prev = 11;
|
|
522
|
+
_context9.t0 = _context9["catch"](2);
|
|
523
|
+
console.error(_context9.t0);
|
|
524
|
+
case 14:
|
|
525
|
+
case "end":
|
|
526
|
+
return _context9.stop();
|
|
527
|
+
}
|
|
528
|
+
}, _callee9, this, [[2, 11]]);
|
|
529
|
+
}));
|
|
530
|
+
function fetchHolderAccounts(_x12) {
|
|
531
|
+
return _fetchHolderAccounts.apply(this, arguments);
|
|
532
|
+
}
|
|
533
|
+
return fetchHolderAccounts;
|
|
534
|
+
}())
|
|
367
535
|
}]);
|
|
368
536
|
return AccountListModule;
|
|
369
537
|
}(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, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
4
|
+
export * from './types';
|
|
5
5
|
/**
|
|
6
6
|
* 购物车模块实现
|
|
7
7
|
*/
|
|
@@ -57,11 +57,14 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
57
57
|
clearCartByAccount(account_id: string): void;
|
|
58
58
|
/**
|
|
59
59
|
* 清除购物车商品中的信息
|
|
60
|
+
* @param type 清除购物车商品中的信息类型
|
|
61
|
+
* @param _id 购物车商品ID
|
|
60
62
|
*/
|
|
61
|
-
deleteCartItemInfo(
|
|
63
|
+
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
62
64
|
/**
|
|
63
65
|
* 清除购物车
|
|
64
66
|
*/
|
|
65
67
|
clear(): void;
|
|
66
68
|
storeChange(): void;
|
|
69
|
+
checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
|
|
67
70
|
}
|