@pisell/pisellos 0.0.13 → 0.0.15
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/Cart/index.d.ts +26 -8
- package/dist/modules/Cart/index.js +134 -122
- package/dist/modules/Cart/types.d.ts +36 -15
- package/dist/modules/Cart/types.js +3 -3
- package/dist/modules/Cart/utils.d.ts +49 -1
- package/dist/modules/Cart/utils.js +109 -0
- package/dist/modules/Date/index.js +6 -1
- package/dist/modules/Rules/index.js +6 -4
- package/dist/modules/Summary/index.js +6 -1
- package/dist/modules/Summary/utils.js +4 -5
- package/dist/solution/BookingByStep/index.d.ts +11 -4
- package/dist/solution/BookingByStep/index.js +185 -159
- package/dist/solution/BookingByStep/utils/resources.js +4 -2
- package/lib/modules/Cart/index.d.ts +26 -8
- package/lib/modules/Cart/index.js +67 -52
- package/lib/modules/Cart/types.d.ts +36 -15
- package/lib/modules/Cart/utils.d.ts +49 -1
- package/lib/modules/Cart/utils.js +74 -0
- package/lib/modules/Date/index.js +3 -0
- package/lib/modules/Rules/index.js +6 -4
- package/lib/modules/Summary/index.js +3 -0
- package/lib/modules/Summary/utils.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +11 -4
- package/lib/solution/BookingByStep/index.js +60 -30
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/package.json +1 -1
|
@@ -138,35 +138,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// 获取购物车里 temp.xxx的方法
|
|
141
|
-
|
|
142
|
-
key
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
147
|
-
case 0:
|
|
148
|
-
return _context2.abrupt("return", this.store.cart.getTemp(key));
|
|
149
|
-
case 1:
|
|
150
|
-
case "end":
|
|
151
|
-
return _context2.stop();
|
|
152
|
-
}
|
|
153
|
-
}, _callee2, this);
|
|
154
|
-
}));
|
|
155
|
-
function getStoreCart(_x3) {
|
|
156
|
-
return _getStoreCart.apply(this, arguments);
|
|
157
|
-
}
|
|
158
|
-
return getStoreCart;
|
|
159
|
-
}() // 加载商品,然后导到商品列表里去
|
|
141
|
+
// async getStoreCart(key?: string) {
|
|
142
|
+
// return this.store.cart.getTemp(key);
|
|
143
|
+
// }
|
|
144
|
+
|
|
145
|
+
// 加载商品,然后导到商品列表里去
|
|
160
146
|
}, {
|
|
161
147
|
key: "loadProducts",
|
|
162
148
|
value: function () {
|
|
163
|
-
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
149
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
164
150
|
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, productsData;
|
|
165
|
-
return _regeneratorRuntime().wrap(function
|
|
166
|
-
while (1) switch (
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
152
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
167
153
|
case 0:
|
|
168
154
|
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection;
|
|
169
|
-
|
|
155
|
+
_context2.next = 3;
|
|
170
156
|
return this.request.post("/product/query", {
|
|
171
157
|
open_quotation: 1,
|
|
172
158
|
open_bundle: 1,
|
|
@@ -179,16 +165,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
179
165
|
collection: collection
|
|
180
166
|
});
|
|
181
167
|
case 3:
|
|
182
|
-
productsData =
|
|
168
|
+
productsData = _context2.sent;
|
|
183
169
|
this.store.products.addProduct(productsData.data.list);
|
|
184
|
-
return
|
|
170
|
+
return _context2.abrupt("return", productsData.data.list);
|
|
185
171
|
case 6:
|
|
186
172
|
case "end":
|
|
187
|
-
return
|
|
173
|
+
return _context2.stop();
|
|
188
174
|
}
|
|
189
|
-
},
|
|
175
|
+
}, _callee2, this);
|
|
190
176
|
}));
|
|
191
|
-
function loadProducts(
|
|
177
|
+
function loadProducts(_x3) {
|
|
192
178
|
return _loadProducts.apply(this, arguments);
|
|
193
179
|
}
|
|
194
180
|
return loadProducts;
|
|
@@ -196,15 +182,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
182
|
}, {
|
|
197
183
|
key: "storeProduct",
|
|
198
184
|
value: function () {
|
|
199
|
-
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
185
|
+
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(productData) {
|
|
200
186
|
var activeAccount, _ref2, bundle, options, origin, product_variant_id, product;
|
|
201
|
-
return _regeneratorRuntime().wrap(function
|
|
202
|
-
while (1) switch (
|
|
187
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
188
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
203
189
|
case 0:
|
|
204
190
|
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
205
191
|
activeAccount = this.getActiveAccount();
|
|
206
192
|
if (activeAccount) {
|
|
207
|
-
|
|
193
|
+
_context3.next = 3;
|
|
208
194
|
break;
|
|
209
195
|
}
|
|
210
196
|
throw new Error("没有找到当前账户");
|
|
@@ -221,11 +207,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
221
207
|
});
|
|
222
208
|
case 6:
|
|
223
209
|
case "end":
|
|
224
|
-
return
|
|
210
|
+
return _context3.stop();
|
|
225
211
|
}
|
|
226
|
-
},
|
|
212
|
+
}, _callee3, this);
|
|
227
213
|
}));
|
|
228
|
-
function storeProduct(
|
|
214
|
+
function storeProduct(_x4) {
|
|
229
215
|
return _storeProduct.apply(this, arguments);
|
|
230
216
|
}
|
|
231
217
|
return storeProduct;
|
|
@@ -233,21 +219,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
233
219
|
}, {
|
|
234
220
|
key: "addAccount",
|
|
235
221
|
value: function () {
|
|
236
|
-
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
222
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(accounts) {
|
|
237
223
|
var _this3 = this;
|
|
238
|
-
return _regeneratorRuntime().wrap(function
|
|
239
|
-
while (1) switch (
|
|
224
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
225
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
240
226
|
case 0:
|
|
241
227
|
accounts.forEach(function (account) {
|
|
242
228
|
_this3.store.accountList.addAccount(account);
|
|
243
229
|
});
|
|
244
230
|
case 1:
|
|
245
231
|
case "end":
|
|
246
|
-
return
|
|
232
|
+
return _context4.stop();
|
|
247
233
|
}
|
|
248
|
-
},
|
|
234
|
+
}, _callee4);
|
|
249
235
|
}));
|
|
250
|
-
function addAccount(
|
|
236
|
+
function addAccount(_x5) {
|
|
251
237
|
return _addAccount.apply(this, arguments);
|
|
252
238
|
}
|
|
253
239
|
return addAccount;
|
|
@@ -255,20 +241,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
255
241
|
}, {
|
|
256
242
|
key: "getAccounts",
|
|
257
243
|
value: function () {
|
|
258
|
-
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
244
|
+
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
259
245
|
var accounts;
|
|
260
|
-
return _regeneratorRuntime().wrap(function
|
|
261
|
-
while (1) switch (
|
|
246
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
247
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
262
248
|
case 0:
|
|
263
249
|
accounts = this.store.accountList.getAccounts();
|
|
264
|
-
return
|
|
250
|
+
return _context5.abrupt("return", accounts.map(function (account) {
|
|
265
251
|
return account.getAccount();
|
|
266
252
|
}));
|
|
267
253
|
case 2:
|
|
268
254
|
case "end":
|
|
269
|
-
return
|
|
255
|
+
return _context5.stop();
|
|
270
256
|
}
|
|
271
|
-
},
|
|
257
|
+
}, _callee5, this);
|
|
272
258
|
}));
|
|
273
259
|
function getAccounts() {
|
|
274
260
|
return _getAccounts.apply(this, arguments);
|
|
@@ -306,18 +292,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
306
292
|
}, {
|
|
307
293
|
key: "setDateRange",
|
|
308
294
|
value: function () {
|
|
309
|
-
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
310
|
-
return _regeneratorRuntime().wrap(function
|
|
311
|
-
while (1) switch (
|
|
295
|
+
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(dateRange) {
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
297
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
312
298
|
case 0:
|
|
313
299
|
this.store.date.setDateRange(dateRange);
|
|
314
300
|
case 1:
|
|
315
301
|
case "end":
|
|
316
|
-
return
|
|
302
|
+
return _context6.stop();
|
|
317
303
|
}
|
|
318
|
-
},
|
|
304
|
+
}, _callee6, this);
|
|
319
305
|
}));
|
|
320
|
-
function setDateRange(
|
|
306
|
+
function setDateRange(_x6) {
|
|
321
307
|
return _setDateRange.apply(this, arguments);
|
|
322
308
|
}
|
|
323
309
|
return setDateRange;
|
|
@@ -325,16 +311,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
325
311
|
}, {
|
|
326
312
|
key: "getRangeDate",
|
|
327
313
|
value: function () {
|
|
328
|
-
var _getRangeDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
329
|
-
return _regeneratorRuntime().wrap(function
|
|
330
|
-
while (1) switch (
|
|
314
|
+
var _getRangeDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
315
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
316
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
331
317
|
case 0:
|
|
332
|
-
return
|
|
318
|
+
return _context7.abrupt("return", "2024-01-01");
|
|
333
319
|
case 1:
|
|
334
320
|
case "end":
|
|
335
|
-
return
|
|
321
|
+
return _context7.stop();
|
|
336
322
|
}
|
|
337
|
-
},
|
|
323
|
+
}, _callee7);
|
|
338
324
|
}));
|
|
339
325
|
function getRangeDate() {
|
|
340
326
|
return _getRangeDate.apply(this, arguments);
|
|
@@ -344,16 +330,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
344
330
|
}, {
|
|
345
331
|
key: "getCart",
|
|
346
332
|
value: function () {
|
|
347
|
-
var _getCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
348
|
-
return _regeneratorRuntime().wrap(function
|
|
349
|
-
while (1) switch (
|
|
333
|
+
var _getCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
334
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
335
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
350
336
|
case 0:
|
|
351
|
-
return
|
|
337
|
+
return _context8.abrupt("return", this.store.cart.getItems());
|
|
352
338
|
case 1:
|
|
353
339
|
case "end":
|
|
354
|
-
return
|
|
340
|
+
return _context8.stop();
|
|
355
341
|
}
|
|
356
|
-
},
|
|
342
|
+
}, _callee8, this);
|
|
357
343
|
}));
|
|
358
344
|
function getCart() {
|
|
359
345
|
return _getCart.apply(this, arguments);
|
|
@@ -363,7 +349,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
363
349
|
}, {
|
|
364
350
|
key: "getAvailableDate",
|
|
365
351
|
value: function () {
|
|
366
|
-
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
352
|
+
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
367
353
|
var _this$otherParams, _this$otherParams2;
|
|
368
354
|
var params,
|
|
369
355
|
products,
|
|
@@ -377,11 +363,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
377
363
|
rules,
|
|
378
364
|
resourcesMap,
|
|
379
365
|
res,
|
|
380
|
-
|
|
381
|
-
return _regeneratorRuntime().wrap(function
|
|
382
|
-
while (1) switch (
|
|
366
|
+
_args9 = arguments;
|
|
367
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
368
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
383
369
|
case 0:
|
|
384
|
-
params =
|
|
370
|
+
params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
|
385
371
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
386
372
|
products = params.products, startDate = params.startDate, endDate = params.endDate;
|
|
387
373
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
@@ -390,16 +376,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
390
376
|
tempStartDate = startDate || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams = _this$otherParams.dateRange) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams[0]);
|
|
391
377
|
tempEndDate = endDate || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 || (_this$otherParams2 = _this$otherParams2.dateRange) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2[1]);
|
|
392
378
|
if (tempProducts.length) {
|
|
393
|
-
|
|
379
|
+
_context9.next = 7;
|
|
394
380
|
break;
|
|
395
381
|
}
|
|
396
|
-
return
|
|
382
|
+
return _context9.abrupt("return", []);
|
|
397
383
|
case 7:
|
|
398
384
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
399
385
|
_ref3 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref3.resourceIds, rules = _ref3.rules, resourcesMap = _ref3.resourcesMap;
|
|
400
386
|
console.log("resourceIds", tempProducts);
|
|
401
387
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
402
|
-
|
|
388
|
+
_context9.next = 12;
|
|
403
389
|
return this.store.date.getMonthDates({
|
|
404
390
|
query: {
|
|
405
391
|
start_date: tempStartDate,
|
|
@@ -409,13 +395,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
409
395
|
rules: rules
|
|
410
396
|
});
|
|
411
397
|
case 12:
|
|
412
|
-
res =
|
|
413
|
-
return
|
|
398
|
+
res = _context9.sent;
|
|
399
|
+
return _context9.abrupt("return", res);
|
|
414
400
|
case 14:
|
|
415
401
|
case "end":
|
|
416
|
-
return
|
|
402
|
+
return _context9.stop();
|
|
417
403
|
}
|
|
418
|
-
},
|
|
404
|
+
}, _callee9, this);
|
|
419
405
|
}));
|
|
420
406
|
function getAvailableDate() {
|
|
421
407
|
return _getAvailableDate.apply(this, arguments);
|
|
@@ -428,22 +414,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
414
|
}, {
|
|
429
415
|
key: "getSummary",
|
|
430
416
|
value: (function () {
|
|
431
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
417
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
432
418
|
var cartItems, summary;
|
|
433
|
-
return _regeneratorRuntime().wrap(function
|
|
434
|
-
while (1) switch (
|
|
419
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
420
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
435
421
|
case 0:
|
|
436
422
|
cartItems = this.store.cart.getItems();
|
|
437
|
-
|
|
423
|
+
_context10.next = 3;
|
|
438
424
|
return this.store.summary.getSummary(cartItems);
|
|
439
425
|
case 3:
|
|
440
|
-
summary =
|
|
441
|
-
return
|
|
426
|
+
summary = _context10.sent;
|
|
427
|
+
return _context10.abrupt("return", summary);
|
|
442
428
|
case 5:
|
|
443
429
|
case "end":
|
|
444
|
-
return
|
|
430
|
+
return _context10.stop();
|
|
445
431
|
}
|
|
446
|
-
},
|
|
432
|
+
}, _callee10, this);
|
|
447
433
|
}));
|
|
448
434
|
function getSummary() {
|
|
449
435
|
return _getSummary.apply(this, arguments);
|
|
@@ -454,16 +440,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
454
440
|
}, {
|
|
455
441
|
key: "getProducts",
|
|
456
442
|
value: function () {
|
|
457
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
458
|
-
return _regeneratorRuntime().wrap(function
|
|
459
|
-
while (1) switch (
|
|
443
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
444
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
445
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
460
446
|
case 0:
|
|
461
|
-
return
|
|
447
|
+
return _context11.abrupt("return", this.store.products.getProducts());
|
|
462
448
|
case 1:
|
|
463
449
|
case "end":
|
|
464
|
-
return
|
|
450
|
+
return _context11.stop();
|
|
465
451
|
}
|
|
466
|
-
},
|
|
452
|
+
}, _callee11, this);
|
|
467
453
|
}));
|
|
468
454
|
function getProducts() {
|
|
469
455
|
return _getProducts.apply(this, arguments);
|
|
@@ -473,15 +459,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
473
459
|
}, {
|
|
474
460
|
key: "setLoginAccount",
|
|
475
461
|
value: function () {
|
|
476
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
462
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(accountId, accountInfo) {
|
|
477
463
|
var _this4 = this;
|
|
478
464
|
var account, cartItems;
|
|
479
|
-
return _regeneratorRuntime().wrap(function
|
|
480
|
-
while (1) switch (
|
|
465
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
466
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
481
467
|
case 0:
|
|
482
468
|
account = this.store.accountList.getAccount(accountId);
|
|
483
469
|
if (!account) {
|
|
484
|
-
|
|
470
|
+
_context12.next = 7;
|
|
485
471
|
break;
|
|
486
472
|
}
|
|
487
473
|
account.setAccountInfo(accountInfo);
|
|
@@ -495,17 +481,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
495
481
|
});
|
|
496
482
|
}
|
|
497
483
|
});
|
|
498
|
-
|
|
484
|
+
_context12.next = 8;
|
|
499
485
|
break;
|
|
500
486
|
case 7:
|
|
501
487
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
502
488
|
case 8:
|
|
503
489
|
case "end":
|
|
504
|
-
return
|
|
490
|
+
return _context12.stop();
|
|
505
491
|
}
|
|
506
|
-
},
|
|
492
|
+
}, _callee12, this);
|
|
507
493
|
}));
|
|
508
|
-
function setLoginAccount(
|
|
494
|
+
function setLoginAccount(_x7, _x8) {
|
|
509
495
|
return _setLoginAccount.apply(this, arguments);
|
|
510
496
|
}
|
|
511
497
|
return setLoginAccount;
|
|
@@ -513,14 +499,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
513
499
|
}, {
|
|
514
500
|
key: "generateCartData",
|
|
515
501
|
value: function () {
|
|
516
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
517
|
-
return _regeneratorRuntime().wrap(function
|
|
518
|
-
while (1) switch (
|
|
502
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
503
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
504
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
519
505
|
case 0:
|
|
520
506
|
case "end":
|
|
521
|
-
return
|
|
507
|
+
return _context13.stop();
|
|
522
508
|
}
|
|
523
|
-
},
|
|
509
|
+
}, _callee13);
|
|
524
510
|
}));
|
|
525
511
|
function generateCartData() {
|
|
526
512
|
return _generateCartData.apply(this, arguments);
|
|
@@ -530,10 +516,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
530
516
|
}, {
|
|
531
517
|
key: "submitOrder",
|
|
532
518
|
value: function () {
|
|
533
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
519
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
534
520
|
var cartItems;
|
|
535
|
-
return _regeneratorRuntime().wrap(function
|
|
536
|
-
while (1) switch (
|
|
521
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
522
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
537
523
|
case 0:
|
|
538
524
|
cartItems = this.store.cart.getItems(); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
539
525
|
cartItems.forEach(function (item) {
|
|
@@ -545,16 +531,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
545
531
|
return _objectSpread({}, newResourcesItem);
|
|
546
532
|
});
|
|
547
533
|
});
|
|
548
|
-
return
|
|
534
|
+
return _context14.abrupt("return", this.store.order.commitOrder({
|
|
549
535
|
query: {
|
|
550
536
|
cartItems: cartItems
|
|
551
537
|
}
|
|
552
538
|
}));
|
|
553
539
|
case 3:
|
|
554
540
|
case "end":
|
|
555
|
-
return
|
|
541
|
+
return _context14.stop();
|
|
556
542
|
}
|
|
557
|
-
},
|
|
543
|
+
}, _callee14, this);
|
|
558
544
|
}));
|
|
559
545
|
function submitOrder() {
|
|
560
546
|
return _submitOrder.apply(this, arguments);
|
|
@@ -564,14 +550,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
564
550
|
}, {
|
|
565
551
|
key: "pay",
|
|
566
552
|
value: function () {
|
|
567
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
568
|
-
return _regeneratorRuntime().wrap(function
|
|
569
|
-
while (1) switch (
|
|
553
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
554
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
555
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
570
556
|
case 0:
|
|
571
557
|
case "end":
|
|
572
|
-
return
|
|
558
|
+
return _context15.stop();
|
|
573
559
|
}
|
|
574
|
-
},
|
|
560
|
+
}, _callee15);
|
|
575
561
|
}));
|
|
576
562
|
function pay() {
|
|
577
563
|
return _pay.apply(this, arguments);
|
|
@@ -581,14 +567,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
581
567
|
}, {
|
|
582
568
|
key: "getPayInfo",
|
|
583
569
|
value: function () {
|
|
584
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
585
|
-
return _regeneratorRuntime().wrap(function
|
|
586
|
-
while (1) switch (
|
|
570
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
571
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
572
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
587
573
|
case 0:
|
|
588
574
|
case "end":
|
|
589
|
-
return
|
|
575
|
+
return _context16.stop();
|
|
590
576
|
}
|
|
591
|
-
},
|
|
577
|
+
}, _callee16);
|
|
592
578
|
}));
|
|
593
579
|
function getPayInfo() {
|
|
594
580
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -598,15 +584,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
584
|
}, {
|
|
599
585
|
key: "setOtherParams",
|
|
600
586
|
value: function () {
|
|
601
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
587
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
602
588
|
var _ref4,
|
|
603
589
|
_ref4$cover,
|
|
604
590
|
cover,
|
|
605
|
-
|
|
606
|
-
return _regeneratorRuntime().wrap(function
|
|
607
|
-
while (1) switch (
|
|
591
|
+
_args17 = arguments;
|
|
592
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
593
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
608
594
|
case 0:
|
|
609
|
-
_ref4 =
|
|
595
|
+
_ref4 = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
|
|
610
596
|
if (cover) {
|
|
611
597
|
this.otherParams = params;
|
|
612
598
|
} else {
|
|
@@ -614,11 +600,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
614
600
|
}
|
|
615
601
|
case 2:
|
|
616
602
|
case "end":
|
|
617
|
-
return
|
|
603
|
+
return _context17.stop();
|
|
618
604
|
}
|
|
619
|
-
},
|
|
605
|
+
}, _callee17, this);
|
|
620
606
|
}));
|
|
621
|
-
function setOtherParams(
|
|
607
|
+
function setOtherParams(_x9) {
|
|
622
608
|
return _setOtherParams.apply(this, arguments);
|
|
623
609
|
}
|
|
624
610
|
return setOtherParams;
|
|
@@ -626,16 +612,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
626
612
|
}, {
|
|
627
613
|
key: "getOtherParams",
|
|
628
614
|
value: function () {
|
|
629
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
630
|
-
return _regeneratorRuntime().wrap(function
|
|
631
|
-
while (1) switch (
|
|
615
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
616
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
617
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
632
618
|
case 0:
|
|
633
|
-
return
|
|
619
|
+
return _context18.abrupt("return", this.otherParams);
|
|
634
620
|
case 1:
|
|
635
621
|
case "end":
|
|
636
|
-
return
|
|
622
|
+
return _context18.stop();
|
|
637
623
|
}
|
|
638
|
-
},
|
|
624
|
+
}, _callee18, this);
|
|
639
625
|
}));
|
|
640
626
|
function getOtherParams() {
|
|
641
627
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -651,7 +637,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
651
637
|
// 删除购物车里某个商品
|
|
652
638
|
}, {
|
|
653
639
|
key: "deleteCart",
|
|
654
|
-
value: function deleteCart(
|
|
640
|
+
value: function deleteCart(cartItemId) {
|
|
641
|
+
this.store.cart.removeItem(cartItemId);
|
|
642
|
+
}
|
|
655
643
|
|
|
656
644
|
// 清空购物车
|
|
657
645
|
}, {
|
|
@@ -666,6 +654,30 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
666
654
|
value: function clearCartByAccount(account_id) {
|
|
667
655
|
this.store.cart.clearCartByAccount(account_id);
|
|
668
656
|
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* 批量更新购物车
|
|
660
|
+
*/
|
|
661
|
+
}, {
|
|
662
|
+
key: "batchUpdateCart",
|
|
663
|
+
value: function batchUpdateCart(paramsList) {
|
|
664
|
+
var _this5 = this;
|
|
665
|
+
var cartItems = [];
|
|
666
|
+
paramsList.forEach(function (params) {
|
|
667
|
+
var cartItem = _this5.store.cart.formatCartItem(params);
|
|
668
|
+
cartItems.push(cartItem);
|
|
669
|
+
});
|
|
670
|
+
this.store.cart.batchSetItems(cartItems);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* 从购物车中按类别删除信息
|
|
675
|
+
*/
|
|
676
|
+
}, {
|
|
677
|
+
key: "deleteCartItemInfo",
|
|
678
|
+
value: function deleteCartItemInfo(types) {
|
|
679
|
+
this.store.cart.deleteCartItemInfo(types);
|
|
680
|
+
}
|
|
669
681
|
}, {
|
|
670
682
|
key: "destory",
|
|
671
683
|
value: function destory() {
|
|
@@ -803,7 +815,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
803
815
|
}, {
|
|
804
816
|
key: "autoSelectAccountResources",
|
|
805
817
|
value: function autoSelectAccountResources(_ref7) {
|
|
806
|
-
var _accountCartItems$;
|
|
818
|
+
var _accountCartItems$0$_, _accountCartItems$;
|
|
807
819
|
var holder_id = _ref7.holder_id,
|
|
808
820
|
resources_code = _ref7.resources_code,
|
|
809
821
|
timeSlots = _ref7.timeSlots;
|
|
@@ -812,18 +824,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
812
824
|
// 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
|
|
813
825
|
var accountCartItems = cartItems.filter(function (n) {
|
|
814
826
|
return n.holder_id === holder_id;
|
|
815
|
-
});
|
|
827
|
+
}) || [];
|
|
828
|
+
// 账号下没商品则不用处理
|
|
829
|
+
if (!accountCartItems.length) {
|
|
830
|
+
return {
|
|
831
|
+
selectedResource: null
|
|
832
|
+
};
|
|
833
|
+
}
|
|
816
834
|
// duration=所有商品时间的集合
|
|
817
835
|
var duration = accountCartItems.reduce(function (acc, n) {
|
|
818
|
-
|
|
836
|
+
var _n$_productOrigin$dur, _n$_productOrigin;
|
|
837
|
+
return acc + ((_n$_productOrigin$dur = (_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 || (_n$_productOrigin = _n$_productOrigin.duration) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.value) !== null && _n$_productOrigin$dur !== void 0 ? _n$_productOrigin$dur : 0);
|
|
819
838
|
}, 0);
|
|
820
839
|
// 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
|
|
821
|
-
var durationType = (accountCartItems === null ||
|
|
840
|
+
var durationType = (_accountCartItems$0$_ = (_accountCartItems$ = accountCartItems[0]) === null || _accountCartItems$ === void 0 || (_accountCartItems$ = _accountCartItems$._productOrigin) === null || _accountCartItems$ === void 0 || (_accountCartItems$ = _accountCartItems$.duration) === null || _accountCartItems$ === void 0 ? void 0 : _accountCartItems$.type) !== null && _accountCartItems$0$_ !== void 0 ? _accountCartItems$0$_ : "minutes";
|
|
822
841
|
// 取出账号下所对应类型的所有的可用资源
|
|
823
842
|
var resources = [];
|
|
824
843
|
accountCartItems.forEach(function (item) {
|
|
825
|
-
var _item$_productOrigin
|
|
826
|
-
(_item$_productOrigin
|
|
844
|
+
var _item$_productOrigin;
|
|
845
|
+
(_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 || (_item$_productOrigin = _item$_productOrigin.product_resource) === null || _item$_productOrigin === void 0 || (_item$_productOrigin = _item$_productOrigin.resources) === null || _item$_productOrigin === void 0 || _item$_productOrigin.forEach(function (n) {
|
|
827
846
|
if (n.code === resources_code) {
|
|
828
847
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
829
848
|
}
|
|
@@ -895,7 +914,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
895
914
|
}, {
|
|
896
915
|
key: "autoSelectAllProductResources",
|
|
897
916
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
898
|
-
var
|
|
917
|
+
var _this6 = this;
|
|
899
918
|
var dateRange = this.store.date.getDateRange();
|
|
900
919
|
var resources = [];
|
|
901
920
|
dateRange.forEach(function (n) {
|
|
@@ -905,24 +924,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
905
924
|
// 一个账号一个账号处理
|
|
906
925
|
var errorList = [];
|
|
907
926
|
this.store.accountList.getAccounts().forEach(function (account) {
|
|
908
|
-
var cartItems =
|
|
927
|
+
var cartItems = _this6.store.cart.getCartByAccount(account.getId());
|
|
909
928
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
910
|
-
var allCartItems =
|
|
929
|
+
var allCartItems = _this6.store.cart.getItems();
|
|
911
930
|
cartItems.forEach(function (item) {
|
|
912
931
|
if (timeSlots) {
|
|
913
932
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
914
|
-
var res =
|
|
933
|
+
var res = _this6.autoSelectAccountResources({
|
|
915
934
|
holder_id: item.holder_id,
|
|
916
935
|
resources_code: resources_code,
|
|
917
936
|
timeSlots: timeSlots
|
|
918
937
|
});
|
|
919
938
|
if (res !== null && res !== void 0 && res.selectedResource) {
|
|
920
|
-
console.log(
|
|
921
|
-
|
|
939
|
+
console.log(_this6.store.cart.getItems());
|
|
940
|
+
_this6.store.cart.updateItem({
|
|
922
941
|
_id: item._id,
|
|
923
|
-
|
|
942
|
+
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
943
|
+
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
944
|
+
return existingRes.form_id !== res.selectedResource.form_id;
|
|
945
|
+
})), [res.selectedResource])
|
|
924
946
|
});
|
|
925
|
-
console.log(
|
|
947
|
+
console.log(_this6.store.cart.getItems());
|
|
926
948
|
} else {
|
|
927
949
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
928
950
|
errorList.push(item._id);
|
|
@@ -936,9 +958,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
936
958
|
return n.code === resources_code;
|
|
937
959
|
})) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
|
|
938
960
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
939
|
-
|
|
961
|
+
_this6.store.cart.updateItem({
|
|
940
962
|
_id: item._id,
|
|
941
|
-
resources: [].concat(_toConsumableArray(item._origin.resources || [])
|
|
963
|
+
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
964
|
+
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
965
|
+
})), [targetRenderList[0]])
|
|
942
966
|
});
|
|
943
967
|
} else {
|
|
944
968
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
@@ -955,15 +979,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
955
979
|
}, {
|
|
956
980
|
key: "getTimeSlotByAllResources",
|
|
957
981
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
958
|
-
var
|
|
982
|
+
var _this7 = this;
|
|
959
983
|
var dateRange = this.store.date.getDateRange();
|
|
960
984
|
// 取出购物车中所有一已选择的第一步资源
|
|
961
985
|
var resources = [];
|
|
962
986
|
var cartItems = this.store.cart.getItems();
|
|
963
987
|
var resourceIds = [];
|
|
964
988
|
cartItems.forEach(function (item) {
|
|
965
|
-
var _item$
|
|
966
|
-
(_item$
|
|
989
|
+
var _item$_productOrigin2, _item$_origin$resourc;
|
|
990
|
+
(_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.product_resource) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.resources) === null || _item$_productOrigin2 === void 0 || _item$_productOrigin2.forEach(function (n) {
|
|
967
991
|
if (n.code === resources_code) {
|
|
968
992
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
969
993
|
}
|
|
@@ -977,9 +1001,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
977
1001
|
// duration = 不同账号的最长时间
|
|
978
1002
|
this.store.accountList.getAccounts().forEach(function (account) {
|
|
979
1003
|
var accountDuration = 0;
|
|
980
|
-
var cartItems =
|
|
1004
|
+
var cartItems = _this7.store.cart.getCartByAccount(account.getId());
|
|
981
1005
|
cartItems.forEach(function (item) {
|
|
982
|
-
|
|
1006
|
+
var _item$_productOrigin$, _item$_productOrigin3;
|
|
1007
|
+
accountDuration += (_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0;
|
|
983
1008
|
});
|
|
984
1009
|
if (accountDuration > duration) {
|
|
985
1010
|
duration = accountDuration;
|
|
@@ -1024,16 +1049,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1024
1049
|
}, {
|
|
1025
1050
|
key: "submitTimeSlot",
|
|
1026
1051
|
value: function submitTimeSlot(timeSlots) {
|
|
1027
|
-
var
|
|
1052
|
+
var _this8 = this;
|
|
1028
1053
|
var cartItems = this.store.cart.getItems();
|
|
1029
1054
|
cartItems.forEach(function (item) {
|
|
1030
1055
|
var newResources = cloneDeep(item._origin.resources);
|
|
1031
1056
|
newResources.forEach(function (n) {
|
|
1057
|
+
var _item$_productOrigin$2, _item$_productOrigin4, _ref8, _item$_productOrigin5;
|
|
1032
1058
|
n.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1033
|
-
n.endTime = dayjs(n.startTime).add(item._productOrigin.duration.value, item._productOrigin.duration.type).format("YYYY-MM-DD HH:mm");
|
|
1059
|
+
n.endTime = dayjs(n.startTime).add((_item$_productOrigin$2 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref8 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref8 !== void 0 ? _ref8 : "minutes").format("YYYY-MM-DD HH:mm");
|
|
1034
1060
|
delete n.times;
|
|
1035
1061
|
});
|
|
1036
|
-
|
|
1062
|
+
_this8.store.cart.updateItem({
|
|
1037
1063
|
_id: item._id,
|
|
1038
1064
|
resources: newResources
|
|
1039
1065
|
});
|