@pisell/pisellos 0.0.11 → 0.0.14
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 +21 -7
- package/dist/modules/Cart/index.js +110 -108
- package/dist/modules/Cart/types.d.ts +34 -13
- package/dist/modules/Cart/types.js +3 -3
- package/dist/modules/Cart/utils.d.ts +37 -1
- package/dist/modules/Cart/utils.js +60 -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/solution/BookingByStep/index.d.ts +0 -1
- package/dist/solution/BookingByStep/index.js +146 -146
- package/dist/solution/BookingByStep/utils/resources.js +4 -2
- package/lib/modules/Cart/index.d.ts +21 -7
- package/lib/modules/Cart/index.js +50 -45
- package/lib/modules/Cart/types.d.ts +34 -13
- package/lib/modules/Cart/utils.d.ts +37 -1
- package/lib/modules/Cart/utils.js +41 -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/solution/BookingByStep/index.d.ts +0 -1
- package/lib/solution/BookingByStep/index.js +35 -16
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/package.json +2 -2
|
@@ -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);
|
|
@@ -803,7 +789,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
803
789
|
}, {
|
|
804
790
|
key: "autoSelectAccountResources",
|
|
805
791
|
value: function autoSelectAccountResources(_ref7) {
|
|
806
|
-
var _accountCartItems$;
|
|
792
|
+
var _accountCartItems$0$_, _accountCartItems$;
|
|
807
793
|
var holder_id = _ref7.holder_id,
|
|
808
794
|
resources_code = _ref7.resources_code,
|
|
809
795
|
timeSlots = _ref7.timeSlots;
|
|
@@ -812,18 +798,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
812
798
|
// 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
|
|
813
799
|
var accountCartItems = cartItems.filter(function (n) {
|
|
814
800
|
return n.holder_id === holder_id;
|
|
815
|
-
});
|
|
801
|
+
}) || [];
|
|
802
|
+
// 账号下没商品则不用处理
|
|
803
|
+
if (!accountCartItems.length) {
|
|
804
|
+
return {
|
|
805
|
+
selectedResource: null
|
|
806
|
+
};
|
|
807
|
+
}
|
|
816
808
|
// duration=所有商品时间的集合
|
|
817
809
|
var duration = accountCartItems.reduce(function (acc, n) {
|
|
818
|
-
|
|
810
|
+
var _n$_productOrigin$dur, _n$_productOrigin;
|
|
811
|
+
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
812
|
}, 0);
|
|
820
813
|
// 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
|
|
821
|
-
var durationType = (accountCartItems === null ||
|
|
814
|
+
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
815
|
// 取出账号下所对应类型的所有的可用资源
|
|
823
816
|
var resources = [];
|
|
824
817
|
accountCartItems.forEach(function (item) {
|
|
825
|
-
var _item$_productOrigin
|
|
826
|
-
(_item$_productOrigin
|
|
818
|
+
var _item$_productOrigin;
|
|
819
|
+
(_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
820
|
if (n.code === resources_code) {
|
|
828
821
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
829
822
|
}
|
|
@@ -920,7 +913,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
920
913
|
console.log(_this5.store.cart.getItems());
|
|
921
914
|
_this5.store.cart.updateItem({
|
|
922
915
|
_id: item._id,
|
|
923
|
-
|
|
916
|
+
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
917
|
+
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
918
|
+
return existingRes.resourceType !== res.selectedResource.resourceType;
|
|
919
|
+
})), [res.selectedResource])
|
|
924
920
|
});
|
|
925
921
|
console.log(_this5.store.cart.getItems());
|
|
926
922
|
} else {
|
|
@@ -938,7 +934,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
938
934
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
939
935
|
_this5.store.cart.updateItem({
|
|
940
936
|
_id: item._id,
|
|
941
|
-
resources: [].concat(_toConsumableArray(item._origin.resources || [])
|
|
937
|
+
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
938
|
+
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
939
|
+
})), [targetRenderList[0]])
|
|
942
940
|
});
|
|
943
941
|
} else {
|
|
944
942
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
@@ -962,8 +960,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
962
960
|
var cartItems = this.store.cart.getItems();
|
|
963
961
|
var resourceIds = [];
|
|
964
962
|
cartItems.forEach(function (item) {
|
|
965
|
-
var _item$
|
|
966
|
-
(_item$
|
|
963
|
+
var _item$_productOrigin2, _item$_origin$resourc;
|
|
964
|
+
(_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
965
|
if (n.code === resources_code) {
|
|
968
966
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
969
967
|
}
|
|
@@ -979,7 +977,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
979
977
|
var accountDuration = 0;
|
|
980
978
|
var cartItems = _this6.store.cart.getCartByAccount(account.getId());
|
|
981
979
|
cartItems.forEach(function (item) {
|
|
982
|
-
|
|
980
|
+
var _item$_productOrigin$, _item$_productOrigin3;
|
|
981
|
+
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
982
|
});
|
|
984
983
|
if (accountDuration > duration) {
|
|
985
984
|
duration = accountDuration;
|
|
@@ -1029,8 +1028,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1029
1028
|
cartItems.forEach(function (item) {
|
|
1030
1029
|
var newResources = cloneDeep(item._origin.resources);
|
|
1031
1030
|
newResources.forEach(function (n) {
|
|
1031
|
+
var _item$_productOrigin$2, _item$_productOrigin4, _ref8, _item$_productOrigin5;
|
|
1032
1032
|
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");
|
|
1033
|
+
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
1034
|
delete n.times;
|
|
1035
1035
|
});
|
|
1036
1036
|
_this7.store.cart.updateItem({
|
|
@@ -231,12 +231,14 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
231
231
|
}
|
|
232
232
|
return childAcc;
|
|
233
233
|
}, []);
|
|
234
|
-
|
|
235
234
|
// 合并渲染
|
|
236
235
|
item.renderList = optional_resource.concat(default_resource);
|
|
237
236
|
// renderList里 times 的每一项需要匹配一下当前时间,如果 times 里最小的end_at小于当前时间,则这个资源应该从 renderList 删除
|
|
238
237
|
item.renderList = item.renderList.filter(function (d) {
|
|
239
|
-
|
|
238
|
+
var latestTime = d.times.reduce(function (latest, current) {
|
|
239
|
+
return dayjs(current.end_at).isAfter(dayjs(latest.end_at)) ? current : latest;
|
|
240
|
+
}, d.times[0]);
|
|
241
|
+
return dayjs(latestTime.end_at).isAfter(dayjs());
|
|
240
242
|
});
|
|
241
243
|
item.form_id = form_id;
|
|
242
244
|
acc.push(item);
|