@pisell/pisellos 3.0.5 → 3.0.7
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 +97 -29
- 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 +29 -24
- package/dist/solution/ShopDiscount/types.d.ts +3 -2
- package/dist/solution/ShopDiscount/types.js +1 -0
- 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 +100 -25
- 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 +14 -2
- package/lib/solution/ShopDiscount/types.d.ts +3 -2
- package/lib/solution/ShopDiscount/types.js +1 -0
- package/package.json +4 -2
|
@@ -22,8 +22,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
22
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
23
|
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); }
|
|
24
24
|
import { BaseModule } from "../BaseModule";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
25
|
+
import { ECartItemCheckType, ECartItemInfoType } from "./types";
|
|
26
|
+
import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFromCartItem, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatRelationFormsToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
|
|
27
|
+
import { cloneDeep } from 'lodash-es';
|
|
27
28
|
export * from "./types";
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -37,8 +38,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
37
38
|
_classCallCheck(this, CartModule);
|
|
38
39
|
_this = _super.call(this, name, version);
|
|
39
40
|
// 提供给 baseModule 用的默认名称 和 默认版本
|
|
40
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName",
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion",
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'cart');
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
42
43
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
43
44
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
44
45
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
@@ -76,22 +77,22 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
// 获取依赖的插件
|
|
79
|
-
this.request = core.getPlugin(
|
|
80
|
-
this.window = core.getPlugin(
|
|
80
|
+
this.request = core.getPlugin('request');
|
|
81
|
+
this.window = core.getPlugin('window');
|
|
81
82
|
if (this.request) {
|
|
82
83
|
_context.next = 9;
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
85
|
-
throw new Error(
|
|
86
|
+
throw new Error('购物车模块需要 request 插件支持');
|
|
86
87
|
case 9:
|
|
87
88
|
if (this.window) {
|
|
88
89
|
_context.next = 11;
|
|
89
90
|
break;
|
|
90
91
|
}
|
|
91
|
-
throw new Error(
|
|
92
|
+
throw new Error('购物车模块需要 window 插件支持');
|
|
92
93
|
case 11:
|
|
93
94
|
// this.store.temp = {};
|
|
94
|
-
console.log(
|
|
95
|
+
console.log('[CartModule] 初始化完成');
|
|
95
96
|
case 12:
|
|
96
97
|
case "end":
|
|
97
98
|
return _context.stop();
|
|
@@ -111,17 +112,20 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
111
112
|
key: "addItem",
|
|
112
113
|
value: (function () {
|
|
113
114
|
var _addItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
114
|
-
var account, product, bundle, options, cartItem, items;
|
|
115
|
+
var account, product, bundle, options, date, cartItem, items;
|
|
115
116
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
116
117
|
while (1) switch (_context2.prev = _context2.next) {
|
|
117
118
|
case 0:
|
|
118
|
-
account = params.account, product = params.product, bundle = params.bundle, options = params.options; // 生成一个唯一的 ID
|
|
119
|
+
account = params.account, product = params.product, bundle = params.bundle, options = params.options, date = params.date; // 生成一个唯一的 ID
|
|
119
120
|
cartItem = {
|
|
120
121
|
_id: getUniqueId(),
|
|
121
122
|
_origin: createCartItemOrigin()
|
|
122
123
|
};
|
|
123
124
|
if (product) {
|
|
124
125
|
cartItem._productOrigin = cloneDeep(product);
|
|
126
|
+
cartItem._productInit = cloneDeep(product);
|
|
127
|
+
cartItem._bundleOrigin = cloneDeep(bundle);
|
|
128
|
+
cartItem._optionsOrigin = cloneDeep(options);
|
|
125
129
|
cartItem = formatProductToCartItem({
|
|
126
130
|
cartItem: cartItem,
|
|
127
131
|
product: product,
|
|
@@ -135,15 +139,21 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
135
139
|
account: account
|
|
136
140
|
});
|
|
137
141
|
}
|
|
142
|
+
if (date) {
|
|
143
|
+
cartItem = formatDateToCartItem({
|
|
144
|
+
cartItem: cartItem,
|
|
145
|
+
date: date
|
|
146
|
+
});
|
|
147
|
+
}
|
|
138
148
|
|
|
139
149
|
// 更新购物车数据
|
|
140
150
|
items = [].concat(_toConsumableArray(this.store.list), [cartItem]);
|
|
141
151
|
this.store.list = items;
|
|
142
152
|
|
|
143
153
|
// 触发事件
|
|
144
|
-
_context2.next =
|
|
154
|
+
_context2.next = 9;
|
|
145
155
|
return this.core.effects.emit("".concat(this.name, ":onAddItem"), cartItem);
|
|
146
|
-
case
|
|
156
|
+
case 9:
|
|
147
157
|
case "end":
|
|
148
158
|
return _context2.stop();
|
|
149
159
|
}
|
|
@@ -184,7 +194,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
184
194
|
case 8:
|
|
185
195
|
_context3.prev = 8;
|
|
186
196
|
_context3.t0 = _context3["catch"](0);
|
|
187
|
-
console.error(
|
|
197
|
+
console.error('[CartModule] 更新购物车商品失败', _context3.t0);
|
|
188
198
|
case 11:
|
|
189
199
|
case "end":
|
|
190
200
|
return _context3.stop();
|
|
@@ -207,23 +217,31 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
207
217
|
cartItem = params.cartItem,
|
|
208
218
|
account = params.account,
|
|
209
219
|
product = params.product,
|
|
220
|
+
bundle = params.bundle,
|
|
221
|
+
options = params.options,
|
|
210
222
|
discounts = params.discounts,
|
|
211
223
|
resources = params.resources,
|
|
212
|
-
note = params.note
|
|
224
|
+
note = params.note,
|
|
225
|
+
date = params.date,
|
|
226
|
+
relationForms = params.relationForms;
|
|
213
227
|
var tempCartItem = this.store.list.find(function (i) {
|
|
214
228
|
return i._id === _id;
|
|
215
229
|
});
|
|
216
230
|
if (!tempCartItem) {
|
|
217
|
-
throw new Error(
|
|
231
|
+
throw new Error('[CartModule] 格式化数据到购物车失败,商品不存在');
|
|
218
232
|
}
|
|
219
233
|
if (cartItem) {
|
|
220
234
|
tempCartItem = cartItem;
|
|
221
235
|
}
|
|
222
236
|
if (product) {
|
|
223
237
|
tempCartItem._productOrigin = cloneDeep(product);
|
|
238
|
+
tempCartItem._bundleOrigin = cloneDeep(bundle);
|
|
239
|
+
tempCartItem._optionsOrigin = cloneDeep(options);
|
|
224
240
|
tempCartItem = formatProductToCartItem({
|
|
225
241
|
cartItem: tempCartItem,
|
|
226
|
-
product: product
|
|
242
|
+
product: product,
|
|
243
|
+
bundle: bundle,
|
|
244
|
+
options: options
|
|
227
245
|
});
|
|
228
246
|
}
|
|
229
247
|
if (discounts) {
|
|
@@ -244,6 +262,18 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
244
262
|
resources: resources
|
|
245
263
|
});
|
|
246
264
|
}
|
|
265
|
+
if (relationForms) {
|
|
266
|
+
tempCartItem = formatRelationFormsToCartItem({
|
|
267
|
+
cartItem: tempCartItem,
|
|
268
|
+
relationForms: relationForms
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (date) {
|
|
272
|
+
tempCartItem = formatDateToCartItem({
|
|
273
|
+
cartItem: tempCartItem,
|
|
274
|
+
date: date
|
|
275
|
+
});
|
|
276
|
+
}
|
|
247
277
|
if (note) {
|
|
248
278
|
tempCartItem = formatNoteToCartItem({
|
|
249
279
|
cartItem: tempCartItem,
|
|
@@ -350,17 +380,36 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
350
380
|
|
|
351
381
|
/**
|
|
352
382
|
* 清除购物车商品中的信息
|
|
383
|
+
* @param type 清除购物车商品中的信息类型
|
|
384
|
+
* @param _id 购物车商品ID
|
|
353
385
|
*/
|
|
354
386
|
}, {
|
|
355
387
|
key: "deleteCartItemInfo",
|
|
356
|
-
value: function deleteCartItemInfo(
|
|
388
|
+
value: function deleteCartItemInfo(type, _id) {
|
|
357
389
|
var list = this.store.list.map(function (item) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
390
|
+
var needDelete = _id ? item._id === _id : true;
|
|
391
|
+
|
|
392
|
+
// 如果存在_id,则只需要操作对应的购物车数据,否则操作所有
|
|
393
|
+
if (!needDelete) {
|
|
394
|
+
return item;
|
|
395
|
+
}
|
|
396
|
+
switch (type) {
|
|
397
|
+
case ECartItemInfoType.Resource:
|
|
398
|
+
// 清除购物车商品中的资源信息
|
|
399
|
+
item = deleteResourceFromCartItem(item);
|
|
400
|
+
break;
|
|
401
|
+
case ECartItemInfoType.Time:
|
|
402
|
+
// 清除购物车商品中的时间信息
|
|
403
|
+
item = deleteTimeFromCartItem(item);
|
|
404
|
+
break;
|
|
405
|
+
case ECartItemInfoType.RelationForms:
|
|
406
|
+
// 清除购物车商品中的关联表单信息
|
|
407
|
+
item = deleteRelationFormsFromCartItem(item);
|
|
408
|
+
break;
|
|
409
|
+
case ECartItemInfoType.Holder:
|
|
410
|
+
// 清除购物车商品中的账户信息
|
|
411
|
+
item = deleteHolderFromCartItem(item);
|
|
412
|
+
break;
|
|
364
413
|
}
|
|
365
414
|
return item;
|
|
366
415
|
});
|
|
@@ -390,10 +439,37 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
390
439
|
cacheId: this.cacheId,
|
|
391
440
|
fatherModule: this.fatherModule,
|
|
392
441
|
store: store,
|
|
393
|
-
cacheKey: [
|
|
442
|
+
cacheKey: ['list']
|
|
394
443
|
});
|
|
395
444
|
}
|
|
396
445
|
}
|
|
446
|
+
}, {
|
|
447
|
+
key: "checkCartItemByType",
|
|
448
|
+
value: function checkCartItemByType(cartItem, type) {
|
|
449
|
+
var result = false;
|
|
450
|
+
var _ref = cartItem._origin || {},
|
|
451
|
+
holder = _ref.holder,
|
|
452
|
+
metadata = _ref.metadata,
|
|
453
|
+
resources = _ref.resources,
|
|
454
|
+
start_date = _ref.start_date,
|
|
455
|
+
end_date = _ref.end_date,
|
|
456
|
+
relation_forms = _ref.relation_forms;
|
|
457
|
+
switch (type) {
|
|
458
|
+
case ECartItemCheckType.Account:
|
|
459
|
+
result = !!holder || !!(metadata !== null && metadata !== void 0 && metadata.account);
|
|
460
|
+
break;
|
|
461
|
+
case ECartItemCheckType.Resources:
|
|
462
|
+
result = !!(resources !== null && resources !== void 0 && resources.length);
|
|
463
|
+
break;
|
|
464
|
+
case ECartItemCheckType.Date:
|
|
465
|
+
result = !!start_date && !!end_date;
|
|
466
|
+
break;
|
|
467
|
+
case ECartItemCheckType.RelationForms:
|
|
468
|
+
result = !!(relation_forms !== null && relation_forms !== void 0 && relation_forms.length);
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
397
473
|
}]);
|
|
398
474
|
return CartModule;
|
|
399
475
|
}(BaseModule);
|
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
import { ProductData } from
|
|
2
|
-
import { Account } from
|
|
3
|
-
import { Resource } from
|
|
1
|
+
import { ProductData } from '../Product/types';
|
|
2
|
+
import { Account } from '../Account/types';
|
|
3
|
+
import { Resource } from '../Resource/types';
|
|
4
4
|
export declare enum CartHooks {
|
|
5
5
|
OnAddItem = "card:onAddItem",
|
|
6
6
|
OnCartChange = "card:onCartChange",
|
|
7
7
|
OnCartUpdateItem = "card:onCartUpdateItem",
|
|
8
8
|
OnCartRemove = "card:onCartRemove"
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* 购物车商品信息类型
|
|
12
|
+
*/
|
|
13
|
+
export declare enum ECartItemInfoType {
|
|
14
|
+
/** 资源信息 */
|
|
15
|
+
Resource = "resource",
|
|
16
|
+
/** 时间信息 */
|
|
17
|
+
Time = "time",
|
|
18
|
+
/** 关联表单信息 */
|
|
19
|
+
RelationForms = "relationForms",
|
|
20
|
+
/** 账户信息 */
|
|
21
|
+
Holder = "holder"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 购物车商品检查类型
|
|
25
|
+
*/
|
|
26
|
+
export declare enum ECartItemCheckType {
|
|
27
|
+
/** 账户信息 */
|
|
28
|
+
Account = "account",
|
|
29
|
+
/** 资源信息 */
|
|
30
|
+
Resources = "resources",
|
|
31
|
+
/** 时间信息 */
|
|
32
|
+
Date = "date",
|
|
33
|
+
/** 关联表单信息 */
|
|
34
|
+
RelationForms = "relationForms"
|
|
35
|
+
}
|
|
10
36
|
export interface CartModuleAPI {
|
|
11
37
|
/** 添加商品到购物车 */
|
|
12
38
|
addItem: (item: IAddItemParams) => Promise<void>;
|
|
@@ -26,6 +52,10 @@ export interface CartModuleAPI {
|
|
|
26
52
|
getCartByAccount: (account_id: string) => CartItem[];
|
|
27
53
|
/** 清除购物车 */
|
|
28
54
|
clear: () => void;
|
|
55
|
+
/** 清除购物车商品中的信息 */
|
|
56
|
+
deleteCartItemInfo: (type: ECartItemInfoType, _id?: string) => void;
|
|
57
|
+
/** 检查购物车商品 */
|
|
58
|
+
checkCartItemByType: (cartItem: CartItem, type: ECartItemCheckType) => boolean;
|
|
29
59
|
}
|
|
30
60
|
/**
|
|
31
61
|
* 购物车商品接口
|
|
@@ -57,7 +87,7 @@ export interface CartItem {
|
|
|
57
87
|
/** 备注 */
|
|
58
88
|
note?: string;
|
|
59
89
|
/** 点赞状态 */
|
|
60
|
-
like_status?:
|
|
90
|
+
like_status?: 'like' | 'common';
|
|
61
91
|
/** 用户名称 */
|
|
62
92
|
holder_title?: string;
|
|
63
93
|
/** 用户ID */
|
|
@@ -84,12 +114,32 @@ export interface CartItem {
|
|
|
84
114
|
resource_id?: string | number;
|
|
85
115
|
/** 资源名称 */
|
|
86
116
|
relation_form_name?: string;
|
|
87
|
-
/**
|
|
117
|
+
/** 定金 */
|
|
118
|
+
deposit?: {
|
|
119
|
+
/** 定金总价 */
|
|
120
|
+
total: number | string;
|
|
121
|
+
/** 定金协议 */
|
|
122
|
+
protocols: {
|
|
123
|
+
/** 定金协议ID */
|
|
124
|
+
id: number;
|
|
125
|
+
/** 定金协议标题 */
|
|
126
|
+
title: string;
|
|
127
|
+
}[];
|
|
128
|
+
} | null;
|
|
129
|
+
/** 接口原始数据 */
|
|
88
130
|
_origin: any;
|
|
131
|
+
/** 商品加入购物车时初始数据 */
|
|
132
|
+
_productInit?: ProductData;
|
|
89
133
|
/** 商品原始数据 */
|
|
90
134
|
_productOrigin?: ProductData;
|
|
91
135
|
/** 资源原始数据 */
|
|
92
136
|
_resourceOrigin?: Resource[];
|
|
137
|
+
/** 容量 */
|
|
138
|
+
capacity?: any;
|
|
139
|
+
/** 商品套餐原始数据 */
|
|
140
|
+
_bundleOrigin?: any[];
|
|
141
|
+
/** 商品规格原始数据 */
|
|
142
|
+
_optionsOrigin?: any[];
|
|
93
143
|
}
|
|
94
144
|
/**
|
|
95
145
|
* 购物车状态接口
|
|
@@ -111,6 +161,13 @@ export interface IAddItemParams {
|
|
|
111
161
|
bundle?: any[];
|
|
112
162
|
/** 商品规格信息 */
|
|
113
163
|
options?: any[];
|
|
164
|
+
/** 日期 */
|
|
165
|
+
date?: {
|
|
166
|
+
/** 开始时间 */
|
|
167
|
+
startTime: string;
|
|
168
|
+
/** 结束时间 */
|
|
169
|
+
endTime: string;
|
|
170
|
+
};
|
|
114
171
|
}
|
|
115
172
|
/**
|
|
116
173
|
* 更新购物车信息参数
|
|
@@ -124,14 +181,34 @@ export interface IUpdateItemParams {
|
|
|
124
181
|
account?: Account;
|
|
125
182
|
/** 商品 */
|
|
126
183
|
product?: ProductData;
|
|
184
|
+
/** 商品套餐信息 */
|
|
185
|
+
bundle?: any[];
|
|
186
|
+
/** 商品规格信息 */
|
|
187
|
+
options?: any[];
|
|
127
188
|
/** 折扣列表 */
|
|
128
189
|
discounts?: IDiscount[];
|
|
129
190
|
/** 数量 */
|
|
130
191
|
quantity?: number;
|
|
131
192
|
/** 资源 */
|
|
132
193
|
resources?: Resource[];
|
|
194
|
+
/** 元数据 */
|
|
195
|
+
metadata?: any;
|
|
133
196
|
/** 备注 */
|
|
134
197
|
note?: string;
|
|
198
|
+
/** 日期 */
|
|
199
|
+
date?: {
|
|
200
|
+
/** 开始时间 */
|
|
201
|
+
startTime: string;
|
|
202
|
+
/** 结束时间 */
|
|
203
|
+
endTime: string;
|
|
204
|
+
};
|
|
205
|
+
/** 关联表单 */
|
|
206
|
+
relationForms?: {
|
|
207
|
+
/** 关联表单ID */
|
|
208
|
+
form_id: number;
|
|
209
|
+
/** 关联表单记录ID */
|
|
210
|
+
form_record_ids: number[];
|
|
211
|
+
}[];
|
|
135
212
|
}
|
|
136
213
|
/**
|
|
137
214
|
* 折扣
|
|
@@ -6,6 +6,28 @@ export var CartHooks = /*#__PURE__*/function (CartHooks) {
|
|
|
6
6
|
return CartHooks;
|
|
7
7
|
}({});
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* 购物车商品信息类型
|
|
11
|
+
*/
|
|
12
|
+
export var ECartItemInfoType = /*#__PURE__*/function (ECartItemInfoType) {
|
|
13
|
+
ECartItemInfoType["Resource"] = "resource";
|
|
14
|
+
ECartItemInfoType["Time"] = "time";
|
|
15
|
+
ECartItemInfoType["RelationForms"] = "relationForms";
|
|
16
|
+
ECartItemInfoType["Holder"] = "holder";
|
|
17
|
+
return ECartItemInfoType;
|
|
18
|
+
}({});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 购物车商品检查类型
|
|
22
|
+
*/
|
|
23
|
+
export var ECartItemCheckType = /*#__PURE__*/function (ECartItemCheckType) {
|
|
24
|
+
ECartItemCheckType["Account"] = "account";
|
|
25
|
+
ECartItemCheckType["Resources"] = "resources";
|
|
26
|
+
ECartItemCheckType["Date"] = "date";
|
|
27
|
+
ECartItemCheckType["RelationForms"] = "relationForms";
|
|
28
|
+
return ECartItemCheckType;
|
|
29
|
+
}({});
|
|
30
|
+
|
|
9
31
|
/**
|
|
10
32
|
* 购物车商品接口
|
|
11
33
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Account } from
|
|
2
|
-
import { ProductData } from
|
|
3
|
-
import { Resource } from
|
|
4
|
-
import { CartItem, IDiscount } from
|
|
1
|
+
import { Account } from '../Account';
|
|
2
|
+
import { ProductData } from '../Product/types';
|
|
3
|
+
import { Resource } from '../Resource/types';
|
|
4
|
+
import { CartItem, IDiscount } from './types';
|
|
5
|
+
import Decimal from 'decimal.js';
|
|
5
6
|
/**
|
|
6
7
|
* 生成一个唯一的 ID
|
|
7
8
|
*/
|
|
@@ -19,7 +20,6 @@ export declare const createCartItemOrigin: () => {
|
|
|
19
20
|
sub_type: null;
|
|
20
21
|
duration: null;
|
|
21
22
|
like_status: string;
|
|
22
|
-
relation_type: string;
|
|
23
23
|
resources: null;
|
|
24
24
|
schedule_id: number;
|
|
25
25
|
start_date: null;
|
|
@@ -28,6 +28,7 @@ export declare const createCartItemOrigin: () => {
|
|
|
28
28
|
end_time: null;
|
|
29
29
|
end_date: null;
|
|
30
30
|
metadata: {};
|
|
31
|
+
holder: null;
|
|
31
32
|
};
|
|
32
33
|
/**
|
|
33
34
|
* 格式化商品到购物车
|
|
@@ -91,17 +92,48 @@ export declare const formatResourceToCartItemOrigin: (params: {
|
|
|
91
92
|
resources: Resource[];
|
|
92
93
|
}) => any;
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @param
|
|
96
|
-
* @returns
|
|
95
|
+
* 格式化关联表单到购物车
|
|
96
|
+
* @param params 参数
|
|
97
|
+
* @returns 格式化后的购物车
|
|
97
98
|
*/
|
|
98
|
-
export declare const
|
|
99
|
+
export declare const formatRelationFormsToCartItem: (params: {
|
|
100
|
+
cartItem: CartItem;
|
|
101
|
+
relationForms: {
|
|
102
|
+
form_id: number;
|
|
103
|
+
form_record_ids: number[];
|
|
104
|
+
}[];
|
|
105
|
+
}) => CartItem;
|
|
106
|
+
export declare const formatRelationFormsToCartItemOrigin: (params: {
|
|
107
|
+
cartItem: CartItem;
|
|
108
|
+
relationForms: {
|
|
109
|
+
form_id: number;
|
|
110
|
+
form_record_ids: number[];
|
|
111
|
+
}[];
|
|
112
|
+
}) => any;
|
|
99
113
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param
|
|
102
|
-
* @returns
|
|
114
|
+
* 格式化日期到购物车
|
|
115
|
+
* @param date 开始时间和结束时间
|
|
116
|
+
* @returns 格式化后的日期
|
|
103
117
|
*/
|
|
104
|
-
export declare const
|
|
118
|
+
export declare const formatDateToCartItem: (params: {
|
|
119
|
+
cartItem: CartItem;
|
|
120
|
+
date: {
|
|
121
|
+
startTime: string;
|
|
122
|
+
endTime: string;
|
|
123
|
+
};
|
|
124
|
+
}) => CartItem;
|
|
125
|
+
/**
|
|
126
|
+
* 格式化日期到购物车原始数据
|
|
127
|
+
* @param date 开始时间和结束时间
|
|
128
|
+
* @returns 格式化后的日期原始数据
|
|
129
|
+
*/
|
|
130
|
+
export declare const formatDateToCartItemOrigin: (params: {
|
|
131
|
+
cartItem: CartItem;
|
|
132
|
+
date: {
|
|
133
|
+
startTime: string;
|
|
134
|
+
endTime: string;
|
|
135
|
+
};
|
|
136
|
+
}) => any;
|
|
105
137
|
/**
|
|
106
138
|
* 格式化备注到购物车
|
|
107
139
|
* @param params 参数
|
|
@@ -142,6 +174,7 @@ export declare const formatBundleToOrigin: (bundle: any) => any;
|
|
|
142
174
|
export declare const isNormalProduct: (product: any) => boolean;
|
|
143
175
|
/**
|
|
144
176
|
* 获取商品总价
|
|
177
|
+
* @description 当前总价计算基于商品数量为1
|
|
145
178
|
* @param item 商品
|
|
146
179
|
* @returns 商品总价
|
|
147
180
|
*/
|
|
@@ -149,9 +182,11 @@ export declare const getProductTotalPrice: (params: {
|
|
|
149
182
|
product: ProductData;
|
|
150
183
|
bundle?: any;
|
|
151
184
|
options?: any;
|
|
185
|
+
num?: number;
|
|
152
186
|
}) => number;
|
|
153
187
|
/**
|
|
154
188
|
* 获取商品原始总价
|
|
189
|
+
* @description 当前总价计算基于商品数量为1
|
|
155
190
|
* @param item 商品
|
|
156
191
|
* @returns 商品原始总价
|
|
157
192
|
*/
|
|
@@ -159,4 +194,62 @@ export declare const getProductOriginTotalPrice: (params: {
|
|
|
159
194
|
product: ProductData;
|
|
160
195
|
bundle?: any;
|
|
161
196
|
options?: any;
|
|
197
|
+
num?: number;
|
|
162
198
|
}) => number | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* 获取商品定金
|
|
201
|
+
* @description 定金基于商品售价来算,最终乘商品数量
|
|
202
|
+
* 1、如果套餐主商品有定金规则,则定金为:(套餐商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
|
|
203
|
+
* 2、如果套餐主商品没有定金规则,子商品有定金规则,则定金为:(套餐子商品售价 * 套餐子商品定金百分比 + 套餐子商品定金固定金额)* 商品数量,最终将所有子商品定金相加
|
|
204
|
+
* 3、普通商品/单规格商品/组合规则商品,定金规则:(商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
|
|
205
|
+
* @param params 参数
|
|
206
|
+
* @returns 商品定金
|
|
207
|
+
*/
|
|
208
|
+
export declare const getProductDeposit: (params: {
|
|
209
|
+
cartItem: CartItem;
|
|
210
|
+
product: ProductData;
|
|
211
|
+
bundle?: any;
|
|
212
|
+
options?: any;
|
|
213
|
+
num?: number;
|
|
214
|
+
}) => {
|
|
215
|
+
total: number;
|
|
216
|
+
protocols: {
|
|
217
|
+
id: number;
|
|
218
|
+
title: string;
|
|
219
|
+
}[];
|
|
220
|
+
} | null;
|
|
221
|
+
/**
|
|
222
|
+
* 计算商品定金
|
|
223
|
+
* @param params 参数
|
|
224
|
+
* @returns 商品定金
|
|
225
|
+
*/
|
|
226
|
+
export declare const handleProductDeposit: (params: {
|
|
227
|
+
depositData: {
|
|
228
|
+
deposit_fixed?: string;
|
|
229
|
+
deposit_percentage?: string;
|
|
230
|
+
};
|
|
231
|
+
total: string | number;
|
|
232
|
+
num: number;
|
|
233
|
+
}) => {
|
|
234
|
+
result: boolean;
|
|
235
|
+
depositTotal: Decimal;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* 从购物车中删除资源相关信息
|
|
239
|
+
* @param cartItem 购物车
|
|
240
|
+
* @returns 删除后的购物车
|
|
241
|
+
*/
|
|
242
|
+
export declare const deleteResourceFromCartItem: (cartItem: CartItem) => CartItem;
|
|
243
|
+
/**
|
|
244
|
+
* 从购物车中删除时间
|
|
245
|
+
* @param cartItem 购物车
|
|
246
|
+
* @returns 删除后的购物车
|
|
247
|
+
*/
|
|
248
|
+
export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
|
|
249
|
+
/**
|
|
250
|
+
* 从购物车中删除关联表单信息
|
|
251
|
+
* @param cartItem 购物车
|
|
252
|
+
* @returns 删除后的购物车
|
|
253
|
+
*/
|
|
254
|
+
export declare const deleteRelationFormsFromCartItem: (cartItem: CartItem) => CartItem;
|
|
255
|
+
export declare const deleteHolderFromCartItem: (cartItem: CartItem) => CartItem;
|