@pisell/pisellos 0.0.13 → 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 +1 -1
|
@@ -5,13 +5,12 @@ export * from "./types";
|
|
|
5
5
|
/**
|
|
6
6
|
* 购物车模块实现
|
|
7
7
|
*/
|
|
8
|
-
export declare class CartModule extends BaseModule implements Module {
|
|
8
|
+
export declare class CartModule extends BaseModule implements Module, CartModuleAPI {
|
|
9
9
|
protected defaultName: string;
|
|
10
10
|
protected defaultVersion: string;
|
|
11
11
|
private request;
|
|
12
12
|
private window;
|
|
13
13
|
private store;
|
|
14
|
-
exports: CartModuleAPI;
|
|
15
14
|
constructor(name?: string, version?: string);
|
|
16
15
|
/**
|
|
17
16
|
* 初始化购物车模块
|
|
@@ -25,17 +24,32 @@ export declare class CartModule extends BaseModule implements Module {
|
|
|
25
24
|
* 更新购物车信息
|
|
26
25
|
*/
|
|
27
26
|
updateItem(params: IUpdateItemParams): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* 格式化数据到购物车
|
|
29
|
+
*/
|
|
30
|
+
formatCartItem(params: IUpdateItemParams): CartItem;
|
|
28
31
|
/**
|
|
29
32
|
* 批量设置购物车数据
|
|
30
33
|
*/
|
|
31
34
|
batchSetItems(items: CartItem[]): Promise<void>;
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 获取购物车商品
|
|
37
|
+
*/
|
|
34
38
|
getItems(): CartItem[];
|
|
39
|
+
/**
|
|
40
|
+
* 移除购物车商品
|
|
41
|
+
*/
|
|
35
42
|
removeItem(id: string): Promise<void>;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
/**
|
|
44
|
+
* 根据账户ID清除购物车
|
|
45
|
+
*/
|
|
39
46
|
clearCartByAccount(account_id: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* 根据账户ID获取购物车
|
|
49
|
+
*/
|
|
40
50
|
getCartByAccount(account_id: string | number): CartItem[];
|
|
51
|
+
/**
|
|
52
|
+
* 清除购物车
|
|
53
|
+
*/
|
|
54
|
+
clear(): void;
|
|
41
55
|
}
|
|
@@ -23,7 +23,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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
25
|
import { CartHooks } from "./types";
|
|
26
|
-
import { createCartItemOrigin, formatAccountToCartItem, formatProductToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
|
|
26
|
+
import { createCartItemOrigin, formatAccountToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
|
|
27
|
+
import { cloneDeep } from "lodash-es";
|
|
27
28
|
export * from "./types";
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -42,15 +43,6 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
42
43
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
43
44
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
44
45
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
45
|
-
// 导出的模块 API
|
|
46
|
-
_defineProperty(_assertThisInitialized(_this), "exports", {
|
|
47
|
-
addItem: _this.addItem.bind(_assertThisInitialized(_this)),
|
|
48
|
-
getItemCount: _this.getItemCount.bind(_assertThisInitialized(_this)),
|
|
49
|
-
getTotalPrice: _this.getTotalPrice.bind(_assertThisInitialized(_this)),
|
|
50
|
-
getItems: _this.getItems.bind(_assertThisInitialized(_this)),
|
|
51
|
-
updateItem: _this.updateItem.bind(_assertThisInitialized(_this)),
|
|
52
|
-
removeItem: _this.removeItem.bind(_assertThisInitialized(_this))
|
|
53
|
-
});
|
|
54
46
|
return _this;
|
|
55
47
|
}
|
|
56
48
|
|
|
@@ -111,10 +103,10 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
111
103
|
account = params.account, product = params.product, bundle = params.bundle, options = params.options; // 生成一个唯一的 ID
|
|
112
104
|
cartItem = {
|
|
113
105
|
_id: getUniqueId(),
|
|
114
|
-
_origin: createCartItemOrigin()
|
|
115
|
-
_productOrigin: product
|
|
106
|
+
_origin: createCartItemOrigin()
|
|
116
107
|
};
|
|
117
108
|
if (product) {
|
|
109
|
+
cartItem._productOrigin = cloneDeep(product);
|
|
118
110
|
cartItem = formatProductToCartItem({
|
|
119
111
|
cartItem: cartItem,
|
|
120
112
|
product: product,
|
|
@@ -158,66 +150,37 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
158
150
|
key: "updateItem",
|
|
159
151
|
value: (function () {
|
|
160
152
|
var _updateItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
161
|
-
var
|
|
162
|
-
var _id, cartItem, account, product, resources, note, tempCartItem, items;
|
|
153
|
+
var tempCartItem, items;
|
|
163
154
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
164
155
|
while (1) switch (_context3.prev = _context3.next) {
|
|
165
156
|
case 0:
|
|
166
|
-
|
|
167
|
-
tempCartItem = this.
|
|
168
|
-
return i._id === _id;
|
|
169
|
-
});
|
|
170
|
-
if (tempCartItem) {
|
|
171
|
-
_context3.next = 5;
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
console.warn("[CartModule] 更新购物车商品失败,商品不存在");
|
|
175
|
-
return _context3.abrupt("return");
|
|
176
|
-
case 5:
|
|
177
|
-
if (cartItem) {
|
|
178
|
-
tempCartItem = cartItem;
|
|
179
|
-
}
|
|
180
|
-
if (product) {
|
|
181
|
-
tempCartItem = formatProductToCartItem({
|
|
182
|
-
cartItem: tempCartItem,
|
|
183
|
-
product: product
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
if (account) {
|
|
187
|
-
tempCartItem = formatAccountToCartItem({
|
|
188
|
-
cartItem: tempCartItem,
|
|
189
|
-
account: account
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
if (resources) {
|
|
193
|
-
tempCartItem = formatResourceToCartItem({
|
|
194
|
-
cartItem: tempCartItem,
|
|
195
|
-
resources: resources
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
if (note && (_tempCartItem$_origin = tempCartItem._origin) !== null && _tempCartItem$_origin !== void 0 && _tempCartItem$_origin.product) {
|
|
199
|
-
tempCartItem.note = note;
|
|
200
|
-
tempCartItem._origin.product.note = note;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// 更新购物车数据
|
|
157
|
+
_context3.prev = 0;
|
|
158
|
+
tempCartItem = this.formatCartItem(params); // 更新购物车数据
|
|
204
159
|
items = this.store.list.map(function (item) {
|
|
205
|
-
|
|
206
|
-
if (item._id === ((_tempCartItem = tempCartItem) === null || _tempCartItem === void 0 ? void 0 : _tempCartItem._id)) {
|
|
160
|
+
if (item._id === (tempCartItem === null || tempCartItem === void 0 ? void 0 : tempCartItem._id)) {
|
|
207
161
|
return tempCartItem;
|
|
208
162
|
}
|
|
209
163
|
return item;
|
|
210
164
|
});
|
|
211
|
-
this.store.list = items;
|
|
212
|
-
|
|
165
|
+
this.store.list = _toConsumableArray(items);
|
|
213
166
|
// 触发事件
|
|
214
|
-
_context3.next =
|
|
167
|
+
_context3.next = 6;
|
|
168
|
+
return this.core.effects.emit(CartHooks.OnCartUpdateItem, tempCartItem);
|
|
169
|
+
case 6:
|
|
170
|
+
_context3.next = 8;
|
|
215
171
|
return this.core.effects.emit("".concat(this.name, ":changed"), items);
|
|
216
|
-
case
|
|
172
|
+
case 8:
|
|
173
|
+
_context3.next = 13;
|
|
174
|
+
break;
|
|
175
|
+
case 10:
|
|
176
|
+
_context3.prev = 10;
|
|
177
|
+
_context3.t0 = _context3["catch"](0);
|
|
178
|
+
console.error("[CartModule] 更新购物车商品失败", _context3.t0);
|
|
179
|
+
case 13:
|
|
217
180
|
case "end":
|
|
218
181
|
return _context3.stop();
|
|
219
182
|
}
|
|
220
|
-
}, _callee3, this);
|
|
183
|
+
}, _callee3, this, [[0, 10]]);
|
|
221
184
|
}));
|
|
222
185
|
function updateItem(_x4) {
|
|
223
186
|
return _updateItem.apply(this, arguments);
|
|
@@ -225,9 +188,65 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
225
188
|
return updateItem;
|
|
226
189
|
}()
|
|
227
190
|
/**
|
|
228
|
-
*
|
|
191
|
+
* 格式化数据到购物车
|
|
229
192
|
*/
|
|
230
193
|
)
|
|
194
|
+
}, {
|
|
195
|
+
key: "formatCartItem",
|
|
196
|
+
value: function formatCartItem(params) {
|
|
197
|
+
var _id = params._id,
|
|
198
|
+
cartItem = params.cartItem,
|
|
199
|
+
account = params.account,
|
|
200
|
+
product = params.product,
|
|
201
|
+
discounts = params.discounts,
|
|
202
|
+
resources = params.resources,
|
|
203
|
+
note = params.note;
|
|
204
|
+
var tempCartItem = this.store.list.find(function (i) {
|
|
205
|
+
return i._id === _id;
|
|
206
|
+
});
|
|
207
|
+
if (!tempCartItem) {
|
|
208
|
+
throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
|
|
209
|
+
}
|
|
210
|
+
if (cartItem) {
|
|
211
|
+
tempCartItem = cartItem;
|
|
212
|
+
}
|
|
213
|
+
if (product) {
|
|
214
|
+
tempCartItem._productOrigin = cloneDeep(product);
|
|
215
|
+
tempCartItem = formatProductToCartItem({
|
|
216
|
+
cartItem: tempCartItem,
|
|
217
|
+
product: product
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (discounts) {
|
|
221
|
+
tempCartItem = formatDiscountToCartItem({
|
|
222
|
+
cartItem: tempCartItem,
|
|
223
|
+
discounts: discounts
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (account) {
|
|
227
|
+
tempCartItem = formatAccountToCartItem({
|
|
228
|
+
cartItem: tempCartItem,
|
|
229
|
+
account: account
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (resources) {
|
|
233
|
+
tempCartItem = formatResourceToCartItem({
|
|
234
|
+
cartItem: tempCartItem,
|
|
235
|
+
resources: resources
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (note) {
|
|
239
|
+
tempCartItem = formatNoteToCartItem({
|
|
240
|
+
cartItem: tempCartItem,
|
|
241
|
+
note: note
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return tempCartItem;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 批量设置购物车数据
|
|
249
|
+
*/
|
|
231
250
|
}, {
|
|
232
251
|
key: "batchSetItems",
|
|
233
252
|
value: (function () {
|
|
@@ -236,7 +255,10 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
236
255
|
while (1) switch (_context4.prev = _context4.next) {
|
|
237
256
|
case 0:
|
|
238
257
|
this.store.list = items || [];
|
|
239
|
-
|
|
258
|
+
// 触发事件
|
|
259
|
+
_context4.next = 3;
|
|
260
|
+
return this.core.effects.emit("".concat(this.name, ":changed"), items);
|
|
261
|
+
case 3:
|
|
240
262
|
case "end":
|
|
241
263
|
return _context4.stop();
|
|
242
264
|
}
|
|
@@ -246,26 +268,23 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
246
268
|
return _batchSetItems.apply(this, arguments);
|
|
247
269
|
}
|
|
248
270
|
return batchSetItems;
|
|
249
|
-
}()
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
}, {
|
|
256
|
-
key: "getTotalPrice",
|
|
257
|
-
value: function getTotalPrice() {
|
|
258
|
-
// return this.store.list.reduce((total: number, item: CartItem) => total + item.price * item.quantity, 0);
|
|
259
|
-
return 0;
|
|
260
|
-
}
|
|
271
|
+
}()
|
|
272
|
+
/**
|
|
273
|
+
* 获取购物车商品
|
|
274
|
+
*/
|
|
275
|
+
)
|
|
261
276
|
}, {
|
|
262
277
|
key: "getItems",
|
|
263
278
|
value: function getItems() {
|
|
264
279
|
return this.store.list;
|
|
265
280
|
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 移除购物车商品
|
|
284
|
+
*/
|
|
266
285
|
}, {
|
|
267
286
|
key: "removeItem",
|
|
268
|
-
value: function () {
|
|
287
|
+
value: (function () {
|
|
269
288
|
var _removeItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
|
|
270
289
|
var items;
|
|
271
290
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
@@ -288,40 +307,10 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
288
307
|
}
|
|
289
308
|
return removeItem;
|
|
290
309
|
}()
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
296
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
297
|
-
case 0:
|
|
298
|
-
this.store.temp[key] = value;
|
|
299
|
-
_context6.next = 3;
|
|
300
|
-
return this.core.effects.emit("".concat(this.name, ":changed"), this.store.temp);
|
|
301
|
-
case 3:
|
|
302
|
-
case "end":
|
|
303
|
-
return _context6.stop();
|
|
304
|
-
}
|
|
305
|
-
}, _callee6, this);
|
|
306
|
-
}));
|
|
307
|
-
function storeTemp(_x7, _x8) {
|
|
308
|
-
return _storeTemp.apply(this, arguments);
|
|
309
|
-
}
|
|
310
|
-
return storeTemp;
|
|
311
|
-
}()
|
|
312
|
-
}, {
|
|
313
|
-
key: "getTemp",
|
|
314
|
-
value: function getTemp(key) {
|
|
315
|
-
if (!key) {
|
|
316
|
-
return this.store.temp;
|
|
317
|
-
}
|
|
318
|
-
return this.store.temp[key];
|
|
319
|
-
}
|
|
320
|
-
}, {
|
|
321
|
-
key: "clear",
|
|
322
|
-
value: function clear() {
|
|
323
|
-
this.store.list = [];
|
|
324
|
-
}
|
|
310
|
+
/**
|
|
311
|
+
* 根据账户ID清除购物车
|
|
312
|
+
*/
|
|
313
|
+
)
|
|
325
314
|
}, {
|
|
326
315
|
key: "clearCartByAccount",
|
|
327
316
|
value: function clearCartByAccount(account_id) {
|
|
@@ -329,6 +318,10 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
318
|
return item.holder_id !== account_id;
|
|
330
319
|
});
|
|
331
320
|
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* 根据账户ID获取购物车
|
|
324
|
+
*/
|
|
332
325
|
}, {
|
|
333
326
|
key: "getCartByAccount",
|
|
334
327
|
value: function getCartByAccount(account_id) {
|
|
@@ -336,6 +329,15 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
336
329
|
return item.holder_id === account_id;
|
|
337
330
|
});
|
|
338
331
|
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 清除购物车
|
|
335
|
+
*/
|
|
336
|
+
}, {
|
|
337
|
+
key: "clear",
|
|
338
|
+
value: function clear() {
|
|
339
|
+
this.store.list = [];
|
|
340
|
+
}
|
|
339
341
|
}]);
|
|
340
342
|
return CartModule;
|
|
341
343
|
}(BaseModule);
|
|
@@ -7,6 +7,26 @@ export declare enum CartHooks {
|
|
|
7
7
|
OnCartUpdateItem = "card:onCartUpdateItem",
|
|
8
8
|
OnCartRemove = "card:onCartRemove"
|
|
9
9
|
}
|
|
10
|
+
export interface CartModuleAPI {
|
|
11
|
+
/** 添加商品到购物车 */
|
|
12
|
+
addItem: (item: IAddItemParams) => Promise<void>;
|
|
13
|
+
/** 获取购物车商品 */
|
|
14
|
+
getItems: () => CartItem[];
|
|
15
|
+
/** 更新购物车商品 */
|
|
16
|
+
updateItem: (params: IUpdateItemParams) => Promise<void>;
|
|
17
|
+
/** 格式化购物车商品 */
|
|
18
|
+
formatCartItem: (params: IUpdateItemParams) => CartItem;
|
|
19
|
+
/** 批量设置购物车商品 */
|
|
20
|
+
batchSetItems: (items: CartItem[]) => Promise<void>;
|
|
21
|
+
/** 移除购物车商品 */
|
|
22
|
+
removeItem: (id: string) => Promise<void>;
|
|
23
|
+
/** 根据账户ID清除购物车 */
|
|
24
|
+
clearCartByAccount: (account_id: string) => void;
|
|
25
|
+
/** 根据账户ID获取购物车 */
|
|
26
|
+
getCartByAccount: (account_id: string) => CartItem[];
|
|
27
|
+
/** 清除购物车 */
|
|
28
|
+
clear: () => void;
|
|
29
|
+
}
|
|
10
30
|
/**
|
|
11
31
|
* 购物车商品接口
|
|
12
32
|
*/
|
|
@@ -67,7 +87,7 @@ export interface CartItem {
|
|
|
67
87
|
/** 原始数据 */
|
|
68
88
|
_origin: any;
|
|
69
89
|
/** 商品原始数据 */
|
|
70
|
-
_productOrigin
|
|
90
|
+
_productOrigin?: ProductData;
|
|
71
91
|
}
|
|
72
92
|
/**
|
|
73
93
|
* 购物车状态接口
|
|
@@ -77,17 +97,6 @@ export interface CartState {
|
|
|
77
97
|
total: number;
|
|
78
98
|
temp: Record<string, any>;
|
|
79
99
|
}
|
|
80
|
-
/**
|
|
81
|
-
* 购物车模块 API
|
|
82
|
-
*/
|
|
83
|
-
export interface CartModuleAPI {
|
|
84
|
-
addItem: (item: IAddItemParams) => Promise<void>;
|
|
85
|
-
getItemCount: () => number;
|
|
86
|
-
getTotalPrice: () => number;
|
|
87
|
-
getItems: () => CartItem[];
|
|
88
|
-
updateItem: (params: IUpdateItemParams) => Promise<void>;
|
|
89
|
-
removeItem: (id: string) => Promise<void>;
|
|
90
|
-
}
|
|
91
100
|
/**
|
|
92
101
|
* 添加商品到购物车参数
|
|
93
102
|
*/
|
|
@@ -108,13 +117,15 @@ export interface IAddItemParams {
|
|
|
108
117
|
*/
|
|
109
118
|
export interface IUpdateItemParams {
|
|
110
119
|
/** 购物车_id字段 */
|
|
111
|
-
_id
|
|
120
|
+
_id: string;
|
|
112
121
|
/** 购物车商品 */
|
|
113
122
|
cartItem?: CartItem;
|
|
114
123
|
/** 账户 */
|
|
115
124
|
account?: Account;
|
|
116
125
|
/** 商品 */
|
|
117
126
|
product?: ProductData;
|
|
127
|
+
/** 折扣列表 */
|
|
128
|
+
discounts?: IDiscount[];
|
|
118
129
|
/** 数量 */
|
|
119
130
|
quantity?: number;
|
|
120
131
|
/** 资源 */
|
|
@@ -122,3 +133,13 @@ export interface IUpdateItemParams {
|
|
|
122
133
|
/** 备注 */
|
|
123
134
|
note?: string;
|
|
124
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* 折扣
|
|
138
|
+
*/
|
|
139
|
+
export interface IDiscount {
|
|
140
|
+
amount?: number;
|
|
141
|
+
type?: string;
|
|
142
|
+
resource_id?: string;
|
|
143
|
+
title?: any;
|
|
144
|
+
original_amount?: number;
|
|
145
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account } from "../Account";
|
|
2
2
|
import { ProductData } from "../Product/types";
|
|
3
3
|
import { Resource } from "../Resource/types";
|
|
4
|
-
import { CartItem } from "./types";
|
|
4
|
+
import { CartItem, IDiscount } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* 生成一个唯一的 ID
|
|
7
7
|
*/
|
|
@@ -46,6 +46,24 @@ export declare const formatProductToCartItemOrigin: (params: {
|
|
|
46
46
|
bundle?: any;
|
|
47
47
|
options?: any;
|
|
48
48
|
}) => any;
|
|
49
|
+
/**
|
|
50
|
+
* 格式化折扣到购物车
|
|
51
|
+
* @param params 参数
|
|
52
|
+
* @returns 格式化后的购物车
|
|
53
|
+
*/
|
|
54
|
+
export declare const formatDiscountToCartItem: (params: {
|
|
55
|
+
cartItem: CartItem;
|
|
56
|
+
discounts: IDiscount[];
|
|
57
|
+
}) => CartItem;
|
|
58
|
+
/**
|
|
59
|
+
* 格式化折扣到购物车原始数据
|
|
60
|
+
* @param params 参数
|
|
61
|
+
* @returns 格式化后的购物车原始数据
|
|
62
|
+
*/
|
|
63
|
+
export declare const formatDiscountToCartItemOrigin: (params: {
|
|
64
|
+
cartItem: CartItem;
|
|
65
|
+
discounts: IDiscount[];
|
|
66
|
+
}) => any;
|
|
49
67
|
/**
|
|
50
68
|
* 格式化账户到购物车
|
|
51
69
|
* @param account 账户
|
|
@@ -72,6 +90,24 @@ export declare const formatResourceToCartItemOrigin: (params: {
|
|
|
72
90
|
cartItem: CartItem;
|
|
73
91
|
resources: Resource[];
|
|
74
92
|
}) => any;
|
|
93
|
+
/**
|
|
94
|
+
* 格式化备注到购物车
|
|
95
|
+
* @param params 参数
|
|
96
|
+
* @returns 格式化后的购物车
|
|
97
|
+
*/
|
|
98
|
+
export declare const formatNoteToCartItem: (params: {
|
|
99
|
+
cartItem: CartItem;
|
|
100
|
+
note: string;
|
|
101
|
+
}) => CartItem;
|
|
102
|
+
/**
|
|
103
|
+
* 格式化备注到购物车原始数据
|
|
104
|
+
* @param params 参数
|
|
105
|
+
* @returns 格式化后的购物车原始数据
|
|
106
|
+
*/
|
|
107
|
+
export declare const formatNoteToCartItemOrigin: (params: {
|
|
108
|
+
cartItem: CartItem;
|
|
109
|
+
note: string;
|
|
110
|
+
}) => any;
|
|
75
111
|
/**
|
|
76
112
|
* 格式化套餐规格信息
|
|
77
113
|
* @param options 套餐规格信息
|
|
@@ -132,6 +132,36 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
|
|
|
132
132
|
return origin;
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* 格式化折扣到购物车
|
|
137
|
+
* @param params 参数
|
|
138
|
+
* @returns 格式化后的购物车
|
|
139
|
+
*/
|
|
140
|
+
export var formatDiscountToCartItem = function formatDiscountToCartItem(params) {
|
|
141
|
+
var cartItem = params.cartItem;
|
|
142
|
+
var oringin = formatDiscountToCartItemOrigin(params);
|
|
143
|
+
cartItem._origin = oringin;
|
|
144
|
+
return cartItem;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 格式化折扣到购物车原始数据
|
|
149
|
+
* @param params 参数
|
|
150
|
+
* @returns 格式化后的购物车原始数据
|
|
151
|
+
*/
|
|
152
|
+
export var formatDiscountToCartItemOrigin = function formatDiscountToCartItemOrigin(params) {
|
|
153
|
+
var cartItem = params.cartItem,
|
|
154
|
+
discounts = params.discounts;
|
|
155
|
+
var origin = cartItem._origin;
|
|
156
|
+
if (discounts && discounts !== null && discounts !== void 0 && discounts.length) {
|
|
157
|
+
if (!origin.product) {
|
|
158
|
+
origin.product = {};
|
|
159
|
+
}
|
|
160
|
+
origin.product.discount_list = discounts;
|
|
161
|
+
}
|
|
162
|
+
return origin;
|
|
163
|
+
};
|
|
164
|
+
|
|
135
165
|
/**
|
|
136
166
|
* 格式化账户到购物车
|
|
137
167
|
* @param account 账户
|
|
@@ -214,6 +244,36 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
|
|
|
214
244
|
return origin;
|
|
215
245
|
};
|
|
216
246
|
|
|
247
|
+
/**
|
|
248
|
+
* 格式化备注到购物车
|
|
249
|
+
* @param params 参数
|
|
250
|
+
* @returns 格式化后的购物车
|
|
251
|
+
*/
|
|
252
|
+
export var formatNoteToCartItem = function formatNoteToCartItem(params) {
|
|
253
|
+
var cartItem = params.cartItem,
|
|
254
|
+
note = params.note;
|
|
255
|
+
cartItem.note = note;
|
|
256
|
+
var oringin = formatNoteToCartItemOrigin(params);
|
|
257
|
+
cartItem._origin = oringin;
|
|
258
|
+
return cartItem;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 格式化备注到购物车原始数据
|
|
263
|
+
* @param params 参数
|
|
264
|
+
* @returns 格式化后的购物车原始数据
|
|
265
|
+
*/
|
|
266
|
+
export var formatNoteToCartItemOrigin = function formatNoteToCartItemOrigin(params) {
|
|
267
|
+
var cartItem = params.cartItem,
|
|
268
|
+
note = params.note;
|
|
269
|
+
var origin = cartItem._origin;
|
|
270
|
+
if (!origin.product) {
|
|
271
|
+
origin.product = {};
|
|
272
|
+
}
|
|
273
|
+
origin.product.note = note;
|
|
274
|
+
return origin;
|
|
275
|
+
};
|
|
276
|
+
|
|
217
277
|
/**
|
|
218
278
|
* 格式化套餐规格信息
|
|
219
279
|
* @param options 套餐规格信息
|
|
@@ -41,7 +41,12 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
41
41
|
this.core = core;
|
|
42
42
|
this.store = options.store;
|
|
43
43
|
this.request = this.core.getPlugin("request");
|
|
44
|
-
|
|
44
|
+
if (this.request) {
|
|
45
|
+
_context.next = 5;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("DateModule 需要 request 插件支持");
|
|
49
|
+
case 5:
|
|
45
50
|
case "end":
|
|
46
51
|
return _context.stop();
|
|
47
52
|
}
|
|
@@ -280,10 +280,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
280
280
|
var discountDetail = {
|
|
281
281
|
amount: product.price,
|
|
282
282
|
type: selectedDiscount.tag,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
discount: {
|
|
284
|
+
resource_id: selectedDiscount.id,
|
|
285
|
+
title: selectedDiscount.format_title,
|
|
286
|
+
original_amount: product.origin_total,
|
|
287
|
+
product_id: selectedDiscount.product_id
|
|
288
|
+
}
|
|
287
289
|
};
|
|
288
290
|
appliedProducts.push(discountDetail);
|
|
289
291
|
appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
|
|
@@ -40,7 +40,12 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
40
40
|
this.core = core;
|
|
41
41
|
this.store = options.store;
|
|
42
42
|
this.shopStore = this.core.getPlugin("shopStore");
|
|
43
|
-
|
|
43
|
+
if (this.shopStore) {
|
|
44
|
+
_context.next = 5;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
48
|
+
case 5:
|
|
44
49
|
case "end":
|
|
45
50
|
return _context.stop();
|
|
46
51
|
}
|
|
@@ -25,7 +25,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
25
25
|
back(): void;
|
|
26
26
|
gotoStep(index: number): void;
|
|
27
27
|
getStepList(): IStep[];
|
|
28
|
-
getStoreCart(key?: string): Promise<any>;
|
|
29
28
|
loadProducts({ category_ids, product_ids, collection, }: {
|
|
30
29
|
category_ids?: number[];
|
|
31
30
|
product_ids?: number[];
|