@pisell/pisellos 0.0.44 → 0.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +19 -0
  5. package/dist/modules/AccountList/index.js +224 -70
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +5 -5
  13. package/dist/modules/Cart/index.js +32 -19
  14. package/dist/modules/Cart/types.d.ts +18 -4
  15. package/dist/modules/Cart/utils.d.ts +29 -5
  16. package/dist/modules/Cart/utils.js +72 -26
  17. package/dist/modules/Date/index.d.ts +6 -6
  18. package/dist/modules/Date/index.js +41 -55
  19. package/dist/modules/Date/types.d.ts +22 -6
  20. package/dist/modules/Date/utils.d.ts +4 -3
  21. package/dist/modules/Date/utils.js +74 -23
  22. package/dist/modules/Discount/index.d.ts +4 -4
  23. package/dist/modules/Discount/index.js +11 -11
  24. package/dist/modules/Order/index.d.ts +10 -5
  25. package/dist/modules/Order/index.js +32 -16
  26. package/dist/modules/Order/types.d.ts +10 -3
  27. package/dist/modules/Product/index.d.ts +4 -1
  28. package/dist/modules/Product/index.js +22 -0
  29. package/dist/modules/Product/types.d.ts +7 -3
  30. package/dist/modules/ProductList/index.js +11 -5
  31. package/dist/modules/Resource/utils.js +1 -1
  32. package/dist/modules/Rules/index.d.ts +4 -4
  33. package/dist/modules/Rules/index.js +11 -11
  34. package/dist/modules/Rules/types.d.ts +1 -1
  35. package/dist/modules/Schedule/index.d.ts +8 -3
  36. package/dist/modules/Schedule/index.js +45 -5
  37. package/dist/modules/Schedule/type.d.ts +7 -7
  38. package/dist/modules/Schedule/types.d.ts +8 -8
  39. package/dist/modules/Schedule/utils.d.ts +9 -3
  40. package/dist/modules/Schedule/utils.js +77 -48
  41. package/dist/modules/Step/index.d.ts +14 -3
  42. package/dist/modules/Step/index.js +54 -2
  43. package/dist/modules/Summary/index.d.ts +5 -5
  44. package/dist/modules/Summary/index.js +7 -7
  45. package/dist/modules/Summary/types.d.ts +2 -2
  46. package/dist/modules/Summary/utils.d.ts +4 -4
  47. package/dist/modules/Summary/utils.js +3 -3
  48. package/dist/plugins/index.d.ts +3 -3
  49. package/dist/plugins/request.d.ts +3 -3
  50. package/dist/plugins/request.js +30 -30
  51. package/dist/plugins/shopStore.d.ts +1 -1
  52. package/dist/solution/BookingByStep/index.d.ts +65 -16
  53. package/dist/solution/BookingByStep/index.js +553 -216
  54. package/dist/solution/BookingByStep/types.d.ts +2 -2
  55. package/dist/solution/BookingByStep/types.js +9 -9
  56. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  57. package/dist/solution/BookingByStep/utils/products.js +3 -0
  58. package/dist/solution/BookingByStep/utils/resources.d.ts +5 -5
  59. package/dist/solution/BookingByStep/utils/resources.js +11 -11
  60. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  61. package/dist/solution/ShopDiscount/index.js +16 -16
  62. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  63. package/dist/solution/ShopDiscount/utils.js +1 -1
  64. package/lib/core/index.js +7 -2
  65. package/lib/modules/Account/index.d.ts +2 -6
  66. package/lib/modules/Account/index.js +15 -30
  67. package/lib/modules/Account/types.d.ts +12 -1
  68. package/lib/modules/AccountList/index.d.ts +19 -0
  69. package/lib/modules/AccountList/index.js +109 -12
  70. package/lib/modules/AccountList/types.d.ts +33 -1
  71. package/lib/modules/AccountList/utils.d.ts +9 -0
  72. package/lib/modules/AccountList/utils.js +39 -0
  73. package/lib/modules/BaseModule.d.ts +2 -2
  74. package/lib/modules/BaseModule.js +14 -3
  75. package/lib/modules/Cart/index.d.ts +5 -5
  76. package/lib/modules/Cart/index.js +27 -6
  77. package/lib/modules/Cart/types.d.ts +18 -4
  78. package/lib/modules/Cart/utils.d.ts +29 -5
  79. package/lib/modules/Cart/utils.js +47 -3
  80. package/lib/modules/Date/index.d.ts +6 -6
  81. package/lib/modules/Date/index.js +6 -6
  82. package/lib/modules/Date/types.d.ts +22 -6
  83. package/lib/modules/Date/utils.d.ts +4 -3
  84. package/lib/modules/Date/utils.js +37 -6
  85. package/lib/modules/Discount/index.d.ts +4 -4
  86. package/lib/modules/Discount/index.js +9 -2
  87. package/lib/modules/Guests/index.js +4 -1
  88. package/lib/modules/Order/index.d.ts +10 -5
  89. package/lib/modules/Order/index.js +11 -1
  90. package/lib/modules/Order/types.d.ts +10 -3
  91. package/lib/modules/Payment/index.js +1 -6
  92. package/lib/modules/Product/index.d.ts +4 -1
  93. package/lib/modules/Product/index.js +16 -0
  94. package/lib/modules/Product/types.d.ts +7 -3
  95. package/lib/modules/ProductList/index.js +21 -7
  96. package/lib/modules/Resource/index.js +4 -1
  97. package/lib/modules/Resource/utils.js +7 -4
  98. package/lib/modules/Rules/index.d.ts +4 -4
  99. package/lib/modules/Rules/types.d.ts +1 -1
  100. package/lib/modules/Schedule/index.d.ts +8 -3
  101. package/lib/modules/Schedule/index.js +33 -2
  102. package/lib/modules/Schedule/type.d.ts +7 -7
  103. package/lib/modules/Schedule/types.d.ts +8 -8
  104. package/lib/modules/Schedule/utils.d.ts +9 -3
  105. package/lib/modules/Schedule/utils.js +32 -4
  106. package/lib/modules/Step/index.d.ts +14 -3
  107. package/lib/modules/Step/index.js +38 -1
  108. package/lib/modules/Summary/index.d.ts +5 -5
  109. package/lib/modules/Summary/types.d.ts +2 -2
  110. package/lib/modules/Summary/utils.d.ts +4 -4
  111. package/lib/plugins/index.d.ts +3 -3
  112. package/lib/plugins/request.d.ts +3 -3
  113. package/lib/plugins/request.js +48 -11
  114. package/lib/plugins/shopStore.d.ts +1 -1
  115. package/lib/solution/BookingByStep/index.d.ts +65 -16
  116. package/lib/solution/BookingByStep/index.js +351 -39
  117. package/lib/solution/BookingByStep/types.d.ts +2 -2
  118. package/lib/solution/BookingByStep/types.js +36 -9
  119. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  120. package/lib/solution/BookingByStep/utils/products.js +3 -0
  121. package/lib/solution/BookingByStep/utils/resources.d.ts +5 -5
  122. package/lib/solution/BookingByStep/utils/resources.js +103 -52
  123. package/lib/solution/BuyTickets/index.js +34 -20
  124. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  125. package/lib/solution/ShopDiscount/index.js +10 -2
  126. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  127. package/package.json +4 -2
@@ -21,9 +21,9 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
21
21
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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
- import { cloneDeep } from "lodash-es";
25
24
  import { BaseModule } from "../BaseModule";
26
- import { createCartItemOrigin, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
25
+ import { createCartItemOrigin, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
26
+ import { cloneDeep } from 'lodash-es';
27
27
  export * from "./types";
28
28
 
29
29
  /**
@@ -37,8 +37,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
37
37
  _classCallCheck(this, CartModule);
38
38
  _this = _super.call(this, name, version);
39
39
  // 提供给 baseModule 用的默认名称 和 默认版本
40
- _defineProperty(_assertThisInitialized(_this), "defaultName", "cart");
41
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
40
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'cart');
41
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
42
42
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
43
43
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
44
44
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
@@ -76,22 +76,22 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
76
76
  }
77
77
 
78
78
  // 获取依赖的插件
79
- this.request = core.getPlugin("request");
80
- this.window = core.getPlugin("window");
79
+ this.request = core.getPlugin('request');
80
+ this.window = core.getPlugin('window');
81
81
  if (this.request) {
82
82
  _context.next = 9;
83
83
  break;
84
84
  }
85
- throw new Error("购物车模块需要 request 插件支持");
85
+ throw new Error('购物车模块需要 request 插件支持');
86
86
  case 9:
87
87
  if (this.window) {
88
88
  _context.next = 11;
89
89
  break;
90
90
  }
91
- throw new Error("购物车模块需要 window 插件支持");
91
+ throw new Error('购物车模块需要 window 插件支持');
92
92
  case 11:
93
93
  // this.store.temp = {};
94
- console.log("[CartModule] 初始化完成");
94
+ console.log('[CartModule] 初始化完成');
95
95
  case 12:
96
96
  case "end":
97
97
  return _context.stop();
@@ -111,11 +111,11 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
111
111
  key: "addItem",
112
112
  value: (function () {
113
113
  var _addItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
114
- var account, product, bundle, options, cartItem, items;
114
+ var account, product, bundle, options, date, cartItem, items;
115
115
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
116
116
  while (1) switch (_context2.prev = _context2.next) {
117
117
  case 0:
118
- account = params.account, product = params.product, bundle = params.bundle, options = params.options; // 生成一个唯一的 ID
118
+ account = params.account, product = params.product, bundle = params.bundle, options = params.options, date = params.date; // 生成一个唯一的 ID
119
119
  cartItem = {
120
120
  _id: getUniqueId(),
121
121
  _origin: createCartItemOrigin()
@@ -135,15 +135,21 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
135
135
  account: account
136
136
  });
137
137
  }
138
+ if (date) {
139
+ cartItem = formatDateToCartItem({
140
+ cartItem: cartItem,
141
+ date: date
142
+ });
143
+ }
138
144
 
139
145
  // 更新购物车数据
140
146
  items = [].concat(_toConsumableArray(this.store.list), [cartItem]);
141
147
  this.store.list = items;
142
148
 
143
149
  // 触发事件
144
- _context2.next = 8;
150
+ _context2.next = 9;
145
151
  return this.core.effects.emit("".concat(this.name, ":onAddItem"), cartItem);
146
- case 8:
152
+ case 9:
147
153
  case "end":
148
154
  return _context2.stop();
149
155
  }
@@ -184,7 +190,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
184
190
  case 8:
185
191
  _context3.prev = 8;
186
192
  _context3.t0 = _context3["catch"](0);
187
- console.error("[CartModule] 更新购物车商品失败", _context3.t0);
193
+ console.error('[CartModule] 更新购物车商品失败', _context3.t0);
188
194
  case 11:
189
195
  case "end":
190
196
  return _context3.stop();
@@ -209,12 +215,13 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
209
215
  product = params.product,
210
216
  discounts = params.discounts,
211
217
  resources = params.resources,
212
- note = params.note;
218
+ note = params.note,
219
+ date = params.date;
213
220
  var tempCartItem = this.store.list.find(function (i) {
214
221
  return i._id === _id;
215
222
  });
216
223
  if (!tempCartItem) {
217
- throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
224
+ throw new Error('[CartModule] 格式化数据到购物车失败,商品不存在');
218
225
  }
219
226
  if (cartItem) {
220
227
  tempCartItem = cartItem;
@@ -244,6 +251,12 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
244
251
  resources: resources
245
252
  });
246
253
  }
254
+ if (date) {
255
+ tempCartItem = formatDateToCartItem({
256
+ cartItem: tempCartItem,
257
+ date: date
258
+ });
259
+ }
247
260
  if (note) {
248
261
  tempCartItem = formatNoteToCartItem({
249
262
  cartItem: tempCartItem,
@@ -356,9 +369,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
356
369
  value: function deleteCartItemInfo(types) {
357
370
  var list = this.store.list.map(function (item) {
358
371
  // 清除购物车商品中的资源信息
359
- if (types === "resource") {
372
+ if (types === 'resource') {
360
373
  item = deleteResourceFromCartItem(item);
361
- } else if (types === "time") {
374
+ } else if (types === 'time') {
362
375
  // 清除购物车商品中的时间信息
363
376
  item = deleteTimeFromCartItem(item);
364
377
  }
@@ -390,7 +403,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
390
403
  cacheId: this.cacheId,
391
404
  fatherModule: this.fatherModule,
392
405
  store: store,
393
- cacheKey: ["list"]
406
+ cacheKey: ['list']
394
407
  });
395
408
  }
396
409
  }
@@ -1,6 +1,6 @@
1
- import { ProductData } from "../Product/types";
2
- import { Account } from "../Account/types";
3
- import { Resource } from "../Resource/types";
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",
@@ -57,7 +57,7 @@ export interface CartItem {
57
57
  /** 备注 */
58
58
  note?: string;
59
59
  /** 点赞状态 */
60
- like_status?: "like" | "common";
60
+ like_status?: 'like' | 'common';
61
61
  /** 用户名称 */
62
62
  holder_title?: string;
63
63
  /** 用户ID */
@@ -127,6 +127,13 @@ export interface IAddItemParams {
127
127
  bundle?: any[];
128
128
  /** 商品规格信息 */
129
129
  options?: any[];
130
+ /** 日期 */
131
+ date?: {
132
+ /** 开始时间 */
133
+ startTime: string;
134
+ /** 结束时间 */
135
+ endTime: string;
136
+ };
130
137
  }
131
138
  /**
132
139
  * 更新购物车信息参数
@@ -148,6 +155,13 @@ export interface IUpdateItemParams {
148
155
  resources?: Resource[];
149
156
  /** 备注 */
150
157
  note?: string;
158
+ /** 日期 */
159
+ date?: {
160
+ /** 开始时间 */
161
+ startTime: string;
162
+ /** 结束时间 */
163
+ endTime: string;
164
+ };
151
165
  }
152
166
  /**
153
167
  * 折扣
@@ -1,8 +1,8 @@
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";
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';
6
6
  /**
7
7
  * 生成一个唯一的 ID
8
8
  */
@@ -90,6 +90,30 @@ export declare const formatResourceToCartItemOrigin: (params: {
90
90
  cartItem: CartItem;
91
91
  resources: Resource[];
92
92
  }) => any;
93
+ /**
94
+ * 格式化日期到购物车
95
+ * @param date 开始时间和结束时间
96
+ * @returns 格式化后的日期
97
+ */
98
+ export declare const formatDateToCartItem: (params: {
99
+ cartItem: CartItem;
100
+ date: {
101
+ startTime: string;
102
+ endTime: string;
103
+ };
104
+ }) => CartItem;
105
+ /**
106
+ * 格式化日期到购物车原始数据
107
+ * @param date 开始时间和结束时间
108
+ * @returns 格式化后的日期原始数据
109
+ */
110
+ export declare const formatDateToCartItemOrigin: (params: {
111
+ cartItem: CartItem;
112
+ date: {
113
+ startTime: string;
114
+ endTime: string;
115
+ };
116
+ }) => any;
93
117
  /**
94
118
  * 从购物车中删除资源相关信息
95
119
  * @param cartItem 购物车
@@ -10,16 +10,16 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  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); }
13
- import dayjs from "dayjs";
14
- import Decimal from "decimal.js";
13
+ import dayjs from 'dayjs';
14
+ import Decimal from 'decimal.js';
15
15
 
16
16
  /**
17
17
  * 生成一个唯一的 ID
18
18
  */
19
19
  export var getUniqueId = function getUniqueId() {
20
- var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
20
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
21
21
  var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 11;
22
- return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
22
+ return prefix + (Math.random() + '').replace(/\D/g, '').substring(0, maxLength);
23
23
  };
24
24
 
25
25
  /**
@@ -32,7 +32,7 @@ export var createCartItemOrigin = function createCartItemOrigin() {
32
32
  // 数量 固定为1
33
33
  number: 1,
34
34
  // 客户端报名所有活动;
35
- registration_type: "all",
35
+ registration_type: 'all',
36
36
  // 暂时不用
37
37
  relation_products: [],
38
38
  // 固定
@@ -45,7 +45,7 @@ export var createCartItemOrigin = function createCartItemOrigin() {
45
45
  duration: null,
46
46
  // 资源相关
47
47
  // 资源状态 -固定
48
- like_status: "common",
48
+ like_status: 'common',
49
49
  // 资源类型 - 固定--谭景琳备注:马天宇说现在平行资源是不传这个的
50
50
  // relation_type: "form",
51
51
  // 所选资源
@@ -100,7 +100,7 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
100
100
  num: num
101
101
  });
102
102
  cartItem.image = product === null || product === void 0 ? void 0 : product.cover;
103
- cartItem.like_status = "common";
103
+ cartItem.like_status = 'common';
104
104
  cartItem.duration = product === null || product === void 0 ? void 0 : product.duration;
105
105
  cartItem.isNormalProduct = isNormalProduct(product);
106
106
  cartItem.is_charge_tax = product === null || product === void 0 ? void 0 : product.is_charge_tax;
@@ -206,7 +206,19 @@ export var formatAccountToCartItemOrigin = function formatAccountToCartItemOrigi
206
206
  account = params.account;
207
207
  var origin = cartItem._origin;
208
208
  if (account) {
209
- origin.metadata.account = account;
209
+ if ((account === null || account === void 0 ? void 0 : account.type) === 'holder') {
210
+ var _ref = (account === null || account === void 0 ? void 0 : account._origin) || {},
211
+ customer_id = _ref.customer_id,
212
+ form_id = _ref.form_id,
213
+ form_record_id = _ref.form_record_id;
214
+ origin.holder = {
215
+ customer_id: customer_id,
216
+ form_id: form_id,
217
+ form_record: form_record_id ? [form_record_id] : null
218
+ };
219
+ } else {
220
+ origin.metadata.account = account;
221
+ }
210
222
  }
211
223
  return origin;
212
224
  };
@@ -224,10 +236,10 @@ export var formatResourceToCartItem = function formatResourceToCartItem(params)
224
236
  cartItem.resource_id = firstResource === null || firstResource === void 0 ? void 0 : firstResource.id;
225
237
  cartItem.relation_form_name = firstResource === null || firstResource === void 0 ? void 0 : firstResource.main_field;
226
238
  if (firstResource.startTime && firstResource.endTime) {
227
- cartItem.start_date = dayjs(firstResource.startTime).format("YYYY-MM-DD");
228
- cartItem.start_time = dayjs(firstResource.startTime).format("HH:mm");
229
- cartItem.end_date = dayjs(firstResource.endTime).format("YYYY-MM-DD");
230
- cartItem.end_time = dayjs(firstResource.endTime).format("HH:mm");
239
+ cartItem.start_date = dayjs(firstResource.startTime).format('YYYY-MM-DD');
240
+ cartItem.start_time = dayjs(firstResource.startTime).format('HH:mm');
241
+ cartItem.end_date = dayjs(firstResource.endTime).format('YYYY-MM-DD');
242
+ cartItem.end_time = dayjs(firstResource.endTime).format('HH:mm');
231
243
  }
232
244
  } else {
233
245
  cartItem.resource_id = undefined;
@@ -257,8 +269,8 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
257
269
  checkResourcesFormat(resource.children, childArr);
258
270
  }
259
271
  var obj = {
260
- relation_type: "form",
261
- like_status: "common",
272
+ relation_type: 'form',
273
+ like_status: 'common',
262
274
  id: resource.id,
263
275
  main_field: resource.main_field,
264
276
  resourceType: resource.resourceType,
@@ -278,11 +290,11 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
278
290
  startTime = _resources$.startTime,
279
291
  endTime = _resources$.endTime;
280
292
  if (startTime && endTime) {
281
- origin.select_date = dayjs(startTime).format("YYYY-MM-DD");
282
- origin.start_date = dayjs(startTime).format("YYYY-MM-DD");
283
- origin.start_time = dayjs(startTime).format("HH:mm");
284
- origin.end_date = dayjs(endTime).format("YYYY-MM-DD");
285
- origin.end_time = dayjs(endTime).format("HH:mm");
293
+ origin.select_date = dayjs(startTime).format('YYYY-MM-DD');
294
+ origin.start_date = dayjs(startTime).format('YYYY-MM-DD');
295
+ origin.start_time = dayjs(startTime).format('HH:mm');
296
+ origin.end_date = dayjs(endTime).format('YYYY-MM-DD');
297
+ origin.end_time = dayjs(endTime).format('HH:mm');
286
298
  }
287
299
  } else if ((resources === null || resources === void 0 ? void 0 : resources.length) === 0) {
288
300
  origin.resources = [];
@@ -295,6 +307,40 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
295
307
  return origin;
296
308
  };
297
309
 
310
+ /**
311
+ * 格式化日期到购物车
312
+ * @param date 开始时间和结束时间
313
+ * @returns 格式化后的日期
314
+ */
315
+ export var formatDateToCartItem = function formatDateToCartItem(params) {
316
+ var cartItem = params.cartItem,
317
+ date = params.date;
318
+ cartItem.start_date = dayjs(date.startTime).format('YYYY-MM-DD');
319
+ cartItem.start_time = dayjs(date.startTime).format('HH:mm');
320
+ cartItem.end_date = dayjs(date.endTime).format('YYYY-MM-DD');
321
+ cartItem.end_time = dayjs(date.endTime).format('HH:mm');
322
+ var oringin = formatDateToCartItemOrigin(params);
323
+ cartItem._origin = oringin;
324
+ return cartItem;
325
+ };
326
+
327
+ /**
328
+ * 格式化日期到购物车原始数据
329
+ * @param date 开始时间和结束时间
330
+ * @returns 格式化后的日期原始数据
331
+ */
332
+ export var formatDateToCartItemOrigin = function formatDateToCartItemOrigin(params) {
333
+ var cartItem = params.cartItem,
334
+ date = params.date;
335
+ var origin = cartItem._origin;
336
+ origin.select_date = dayjs(date.startTime).format('YYYY-MM-DD');
337
+ origin.start_date = dayjs(date.startTime).format('YYYY-MM-DD');
338
+ origin.start_time = dayjs(date.startTime).format('HH:mm');
339
+ origin.end_date = dayjs(date.endTime).format('YYYY-MM-DD');
340
+ origin.end_time = dayjs(date.endTime).format('HH:mm');
341
+ return origin;
342
+ };
343
+
298
344
  /**
299
345
  * 从购物车中删除资源相关信息
300
346
  * @param cartItem 购物车
@@ -447,7 +493,7 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
447
493
  * @returns 是否是普通商品
448
494
  */
449
495
  export var isNormalProduct = function isNormalProduct(product) {
450
- return (product === null || product === void 0 ? void 0 : product.extension_type) !== "product_appointment";
496
+ return (product === null || product === void 0 ? void 0 : product.extension_type) !== 'product_appointment';
451
497
  };
452
498
 
453
499
  /**
@@ -528,14 +574,14 @@ export var getProductDeposit = function getProductDeposit(params) {
528
574
  if ((product === null || product === void 0 || (_product$custom_depos2 = product.custom_deposit_data) === null || _product$custom_depos2 === void 0 ? void 0 : _product$custom_depos2.has_deposit) == 1) {
529
575
  var protocols = [];
530
576
  var total = new Decimal(0);
531
- var _ref = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
532
- deposit_fixed = _ref.deposit_fixed,
533
- deposit_percentage = _ref.deposit_percentage,
534
- deposit_policy_data = _ref.deposit_policy_data;
577
+ var _ref2 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
578
+ deposit_fixed = _ref2.deposit_fixed,
579
+ deposit_percentage = _ref2.deposit_percentage,
580
+ deposit_policy_data = _ref2.deposit_policy_data;
535
581
  // 协议数据
536
582
  protocols.push.apply(protocols, _toConsumableArray(deposit_policy_data || []));
537
583
  // 判断主商品是否有定金规则
538
- if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
584
+ if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
539
585
  var _handleProductDeposit = handleProductDeposit({
540
586
  depositData: product === null || product === void 0 ? void 0 : product.custom_deposit_data,
541
587
  total: cartItem.total || 0,
@@ -582,7 +628,7 @@ export var handleProductDeposit = function handleProductDeposit(params) {
582
628
  num = params.num;
583
629
  var deposit_fixed = depositData.deposit_fixed,
584
630
  deposit_percentage = depositData.deposit_percentage;
585
- if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
631
+ if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
586
632
  var depositFixed = Decimal(deposit_fixed || 0);
587
633
  var depositPercent = Decimal(deposit_percentage || 0);
588
634
  var productTotalPrice = Decimal(total || 0);
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from './types';
4
4
  export declare class DateModule extends BaseModule implements Module, DateModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -13,9 +13,9 @@ export declare class DateModule extends BaseModule implements Module, DateModule
13
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
14
  setDateRange(dateRange: ITime[]): void;
15
15
  getDateRange(): ITime[];
16
- getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
- getDateList(): Promise<ITime[]>;
18
- getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
16
+ getResourceDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
+ getDateList(): ITime[];
18
+ getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
19
19
  clearDateRange(): void;
20
20
  storeChange(): void;
21
21
  }
@@ -15,7 +15,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
15
15
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  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); }
18
- import dayjs from "dayjs";
18
+ import dayjs from 'dayjs';
19
19
  import { BaseModule } from "../BaseModule";
20
20
  import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
21
21
  export var DateModule = /*#__PURE__*/function (_BaseModule) {
@@ -25,8 +25,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
25
25
  var _this;
26
26
  _classCallCheck(this, DateModule);
27
27
  _this = _super.call(this, name, version);
28
- _defineProperty(_assertThisInitialized(_this), "defaultName", "date");
29
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
28
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'date');
29
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
30
30
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
31
31
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
32
32
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
@@ -44,7 +44,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
44
44
  case 0:
45
45
  this.core = core;
46
46
  this.store = options.store;
47
- this.request = this.core.getPlugin("request");
47
+ this.request = this.core.getPlugin('request');
48
48
  if (options.initialState) {
49
49
  this.store.dateRange = options.initialState.dateRange;
50
50
  this.store.dateList = options.initialState.dateList;
@@ -53,7 +53,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
53
53
  _context.next = 6;
54
54
  break;
55
55
  }
56
- throw new Error("DateModule 需要 request 插件支持");
56
+ throw new Error('DateModule 需要 request 插件支持');
57
57
  case 6:
58
58
  if ((_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
59
59
  this.openCache = options.otherParams.openCache;
@@ -84,15 +84,15 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
84
84
  return this.store.dateRange;
85
85
  }
86
86
  }, {
87
- key: "getMonthDates",
87
+ key: "getResourceDates",
88
88
  value: function () {
89
- var _getMonthDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
89
+ var _getResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
90
90
  var dates;
91
91
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
92
92
  while (1) switch (_context2.prev = _context2.next) {
93
93
  case 0:
94
94
  _context2.next = 2;
95
- return this.getAvailableTimeList(params);
95
+ return this.getResourceAvailableTimeList(params);
96
96
  case 2:
97
97
  dates = _context2.sent;
98
98
  this.store.dateList = dates;
@@ -103,57 +103,43 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
103
103
  }
104
104
  }, _callee2, this);
105
105
  }));
106
- function getMonthDates(_x3) {
107
- return _getMonthDates.apply(this, arguments);
106
+ function getResourceDates(_x3) {
107
+ return _getResourceDates.apply(this, arguments);
108
108
  }
109
- return getMonthDates;
109
+ return getResourceDates;
110
110
  }()
111
111
  }, {
112
112
  key: "getDateList",
113
+ value: function getDateList() {
114
+ return this.store.dateList;
115
+ }
116
+ }, {
117
+ key: "getResourceAvailableTimeList",
113
118
  value: function () {
114
- var _getDateList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
119
+ var _getResourceAvailableTimeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
120
+ var url, query, rules, type, fetchUrl, _ref, start_date, end_date, resource_ids, dates, _res$data, res;
115
121
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
116
122
  while (1) switch (_context3.prev = _context3.next) {
117
123
  case 0:
118
- return _context3.abrupt("return", this.store.dateList);
119
- case 1:
120
- case "end":
121
- return _context3.stop();
122
- }
123
- }, _callee3, this);
124
- }));
125
- function getDateList() {
126
- return _getDateList.apply(this, arguments);
127
- }
128
- return getDateList;
129
- }()
130
- }, {
131
- key: "getAvailableTimeList",
132
- value: function () {
133
- var _getAvailableTimeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
134
- var url, query, rules, fetchUrl, _ref, start_date, end_date, resource_ids, dates, _res$data, res;
135
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
136
- while (1) switch (_context4.prev = _context4.next) {
137
- case 0:
138
- url = params.url, query = params.query, rules = params.rules;
139
- fetchUrl = url || "/schedule/resource/list";
124
+ url = params.url, query = params.query, rules = params.rules, type = params.type;
125
+ fetchUrl = url || '/schedule/resource/list';
140
126
  _ref = query || {}, start_date = _ref.start_date, end_date = _ref.end_date, resource_ids = _ref.resource_ids;
141
127
  if (!(!start_date || !end_date)) {
142
- _context4.next = 5;
128
+ _context3.next = 5;
143
129
  break;
144
130
  }
145
- return _context4.abrupt("return", []);
131
+ return _context3.abrupt("return", []);
146
132
  case 5:
147
133
  // 1.生成当前月份的所有日期,默认都是可用的
148
- dates = generateMonthDates(start_date, end_date); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
134
+ dates = generateMonthDates(start_date, end_date, type); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
149
135
  if (!(!(resource_ids !== null && resource_ids !== void 0 && resource_ids.length) || dayjs(end_date).isBefore(dayjs()))) {
150
- _context4.next = 8;
136
+ _context3.next = 8;
151
137
  break;
152
138
  }
153
- return _context4.abrupt("return", disableAllDates(dates));
139
+ return _context3.abrupt("return", disableAllDates(dates));
154
140
  case 8:
155
- _context4.prev = 8;
156
- _context4.next = 11;
141
+ _context3.prev = 8;
142
+ _context3.next = 11;
157
143
  return this.request.get(fetchUrl, {
158
144
  start_date: start_date,
159
145
  end_date: end_date,
@@ -163,12 +149,12 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
163
149
  useCache: true
164
150
  });
165
151
  case 11:
166
- res = _context4.sent;
152
+ res = _context3.sent;
167
153
  if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.length) {
168
- _context4.next = 14;
154
+ _context3.next = 14;
169
155
  break;
170
156
  }
171
- return _context4.abrupt("return", disableAllDates(dates));
157
+ return _context3.abrupt("return", disableAllDates(dates));
172
158
  case 14:
173
159
  // 2.根据资源times判定哪些日期内存在可用资源
174
160
  dates = handleAvailableDateByResource(res.data, dates);
@@ -177,22 +163,22 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
177
163
  if (rules !== null && rules !== void 0 && rules.length) {
178
164
  dates = handleAvailableDatesByRules(dates, rules);
179
165
  }
180
- return _context4.abrupt("return", dates);
166
+ return _context3.abrupt("return", dates);
181
167
  case 19:
182
- _context4.prev = 19;
183
- _context4.t0 = _context4["catch"](8);
184
- console.log("getAvailableTimeList_error", _context4.t0);
185
- return _context4.abrupt("return", disableAllDates(dates));
168
+ _context3.prev = 19;
169
+ _context3.t0 = _context3["catch"](8);
170
+ console.log('getAvailableTimeList_error', _context3.t0);
171
+ return _context3.abrupt("return", disableAllDates(dates));
186
172
  case 23:
187
173
  case "end":
188
- return _context4.stop();
174
+ return _context3.stop();
189
175
  }
190
- }, _callee4, this, [[8, 19]]);
176
+ }, _callee3, this, [[8, 19]]);
191
177
  }));
192
- function getAvailableTimeList(_x4) {
193
- return _getAvailableTimeList.apply(this, arguments);
178
+ function getResourceAvailableTimeList(_x4) {
179
+ return _getResourceAvailableTimeList.apply(this, arguments);
194
180
  }
195
- return getAvailableTimeList;
181
+ return getResourceAvailableTimeList;
196
182
  }()
197
183
  }, {
198
184
  key: "clearDateRange",
@@ -207,7 +193,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
207
193
  cacheId: this.cacheId,
208
194
  fatherModule: this.fatherModule,
209
195
  store: this.store,
210
- cacheKey: ["dateRange", "dateList"]
196
+ cacheKey: ['dateRange', 'dateList']
211
197
  });
212
198
  }
213
199
  }