@pisell/pisellos 3.0.50 → 3.0.51
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 +1 -0
- package/dist/modules/Cart/index.js +42 -14
- package/dist/modules/Cart/utils/changePrice.d.ts +1 -1
- package/dist/modules/Cart/utils/changePrice.js +11 -3
- package/dist/modules/Rules/index.js +0 -2
- package/dist/solution/BookingByStep/index.js +2 -0
- package/lib/modules/Cart/index.d.ts +1 -0
- package/lib/modules/Cart/index.js +10 -0
- package/lib/modules/Cart/utils/changePrice.d.ts +1 -1
- package/lib/modules/Cart/utils/changePrice.js +9 -2
- package/lib/solution/BookingByStep/index.js +2 -1
- package/package.json +1 -1
|
@@ -211,11 +211,39 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
211
211
|
return _updateItem.apply(this, arguments);
|
|
212
212
|
}
|
|
213
213
|
return updateItem;
|
|
214
|
+
}() // 更新购物车中商品的初始信息
|
|
215
|
+
// 为什么会有这个操作,主要服务于报价单和商品券
|
|
216
|
+
// 商品券那边会使用 init 的 price 做计算,而报价单那边就需要修改 init 的 price 来辅助商品计算
|
|
217
|
+
)
|
|
218
|
+
}, {
|
|
219
|
+
key: "updateItemInitInfo",
|
|
220
|
+
value: function () {
|
|
221
|
+
var _updateItemInitInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
222
|
+
var _id, product, cartItem;
|
|
223
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
224
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
225
|
+
case 0:
|
|
226
|
+
_id = params._id, product = params.product;
|
|
227
|
+
cartItem = this.store.list.find(function (i) {
|
|
228
|
+
return i._id === _id;
|
|
229
|
+
});
|
|
230
|
+
if (cartItem) {
|
|
231
|
+
cartItem._productInit = cloneDeep(product);
|
|
232
|
+
}
|
|
233
|
+
case 3:
|
|
234
|
+
case "end":
|
|
235
|
+
return _context4.stop();
|
|
236
|
+
}
|
|
237
|
+
}, _callee4, this);
|
|
238
|
+
}));
|
|
239
|
+
function updateItemInitInfo(_x5) {
|
|
240
|
+
return _updateItemInitInfo.apply(this, arguments);
|
|
241
|
+
}
|
|
242
|
+
return updateItemInitInfo;
|
|
214
243
|
}()
|
|
215
244
|
/**
|
|
216
245
|
* 格式化数据到购物车
|
|
217
246
|
*/
|
|
218
|
-
)
|
|
219
247
|
}, {
|
|
220
248
|
key: "formatCartItem",
|
|
221
249
|
value: function formatCartItem(params) {
|
|
@@ -305,18 +333,18 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
305
333
|
}, {
|
|
306
334
|
key: "batchSetItems",
|
|
307
335
|
value: (function () {
|
|
308
|
-
var _batchSetItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
309
|
-
return _regeneratorRuntime().wrap(function
|
|
310
|
-
while (1) switch (
|
|
336
|
+
var _batchSetItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(items) {
|
|
337
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
338
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
311
339
|
case 0:
|
|
312
340
|
this.store.list = _toConsumableArray(items || []);
|
|
313
341
|
case 1:
|
|
314
342
|
case "end":
|
|
315
|
-
return
|
|
343
|
+
return _context5.stop();
|
|
316
344
|
}
|
|
317
|
-
},
|
|
345
|
+
}, _callee5, this);
|
|
318
346
|
}));
|
|
319
|
-
function batchSetItems(
|
|
347
|
+
function batchSetItems(_x6) {
|
|
320
348
|
return _batchSetItems.apply(this, arguments);
|
|
321
349
|
}
|
|
322
350
|
return batchSetItems;
|
|
@@ -359,24 +387,24 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
359
387
|
}, {
|
|
360
388
|
key: "removeItem",
|
|
361
389
|
value: (function () {
|
|
362
|
-
var _removeItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
390
|
+
var _removeItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
363
391
|
var items;
|
|
364
|
-
return _regeneratorRuntime().wrap(function
|
|
365
|
-
while (1) switch (
|
|
392
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
393
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
366
394
|
case 0:
|
|
367
395
|
items = this.store.list.filter(function (i) {
|
|
368
396
|
return i._id !== id;
|
|
369
397
|
});
|
|
370
398
|
this.store.list = items;
|
|
371
|
-
|
|
399
|
+
_context6.next = 4;
|
|
372
400
|
return this.core.effects.emit("".concat(this.name, ":onRemoveItem"), items);
|
|
373
401
|
case 4:
|
|
374
402
|
case "end":
|
|
375
|
-
return
|
|
403
|
+
return _context6.stop();
|
|
376
404
|
}
|
|
377
|
-
},
|
|
405
|
+
}, _callee6, this);
|
|
378
406
|
}));
|
|
379
|
-
function removeItem(
|
|
407
|
+
function removeItem(_x7) {
|
|
380
408
|
return _removeItem.apply(this, arguments);
|
|
381
409
|
}
|
|
382
410
|
return removeItem;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Product } from "../../Product";
|
|
2
2
|
import { CartItem, IUpdateItemParams } from "../types";
|
|
3
|
-
export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void): Promise<void>;
|
|
3
|
+
export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void, updateItemInitInfo: (item: IUpdateItemParams) => void): Promise<void>;
|
|
@@ -11,11 +11,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
13
|
import Decimal from "decimal.js";
|
|
14
|
-
export function updateAllCartItemPrice(_x, _x2, _x3, _x4) {
|
|
14
|
+
export function updateAllCartItemPrice(_x, _x2, _x3, _x4, _x5) {
|
|
15
15
|
return _updateAllCartItemPrice.apply(this, arguments);
|
|
16
16
|
}
|
|
17
17
|
function _updateAllCartItemPrice() {
|
|
18
|
-
_updateAllCartItemPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cartItems, priceData, getProduct, updateCart) {
|
|
18
|
+
_updateAllCartItemPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cartItems, priceData, getProduct, updateCart, updateItemInitInfo) {
|
|
19
19
|
var _iterator, _step, _loop;
|
|
20
20
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
21
21
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -37,6 +37,9 @@ function _updateAllCartItemPrice() {
|
|
|
37
37
|
case 4:
|
|
38
38
|
cartProduct = _context.sent;
|
|
39
39
|
productInfo = cartProduct === null || cartProduct === void 0 ? void 0 : cartProduct.getData();
|
|
40
|
+
if (!productInfo) {
|
|
41
|
+
productInfo = item._productOrigin;
|
|
42
|
+
}
|
|
40
43
|
bundle = item._bundleOrigin;
|
|
41
44
|
productInfo.price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price;
|
|
42
45
|
productInfo.base_price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price;
|
|
@@ -79,13 +82,18 @@ function _updateAllCartItemPrice() {
|
|
|
79
82
|
return n;
|
|
80
83
|
});
|
|
81
84
|
}
|
|
85
|
+
// 先把商品原始信息更新了
|
|
86
|
+
updateItemInitInfo({
|
|
87
|
+
_id: item._id,
|
|
88
|
+
product: productInfo
|
|
89
|
+
});
|
|
82
90
|
updateCart({
|
|
83
91
|
_id: item._id,
|
|
84
92
|
product: productInfo,
|
|
85
93
|
bundle: bundle,
|
|
86
94
|
options: item._optionsOrigin
|
|
87
95
|
});
|
|
88
|
-
case
|
|
96
|
+
case 15:
|
|
89
97
|
case "end":
|
|
90
98
|
return _context.stop();
|
|
91
99
|
}
|
|
@@ -165,8 +165,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
165
165
|
var _this3 = this;
|
|
166
166
|
var discountList = _ref2.discountList,
|
|
167
167
|
productList = _ref2.productList;
|
|
168
|
-
// debugger
|
|
169
|
-
|
|
170
168
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
171
169
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
172
170
|
var isEditModeAddNewProduct = productList.find(function (n) {
|
|
@@ -378,6 +378,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
378
378
|
return _this3.store.products.getProduct(id);
|
|
379
379
|
}, function (params) {
|
|
380
380
|
return _this3.store.cart.updateItem(params);
|
|
381
|
+
}, function (params) {
|
|
382
|
+
return _this3.store.cart.updateItemInitInfo(params);
|
|
381
383
|
});
|
|
382
384
|
case 10:
|
|
383
385
|
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateQuotationPrice"), {});
|
|
@@ -119,6 +119,16 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
119
119
|
console.error("[CartModule] 更新购物车商品失败", error);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
+
// 更新购物车中商品的初始信息
|
|
123
|
+
// 为什么会有这个操作,主要服务于报价单和商品券
|
|
124
|
+
// 商品券那边会使用 init 的 price 做计算,而报价单那边就需要修改 init 的 price 来辅助商品计算
|
|
125
|
+
async updateItemInitInfo(params) {
|
|
126
|
+
const { _id, product } = params;
|
|
127
|
+
const cartItem = this.store.list.find((i) => i._id === _id);
|
|
128
|
+
if (cartItem) {
|
|
129
|
+
cartItem._productInit = (0, import_lodash_es.cloneDeep)(product);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
122
132
|
/**
|
|
123
133
|
* 格式化数据到购物车
|
|
124
134
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Product } from "../../Product";
|
|
2
2
|
import { CartItem, IUpdateItemParams } from "../types";
|
|
3
|
-
export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void): Promise<void>;
|
|
3
|
+
export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void, updateItemInitInfo: (item: IUpdateItemParams) => void): Promise<void>;
|
|
@@ -33,14 +33,17 @@ __export(changePrice_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(changePrice_exports);
|
|
35
35
|
var import_decimal = __toESM(require("decimal.js"));
|
|
36
|
-
async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart) {
|
|
36
|
+
async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart, updateItemInitInfo) {
|
|
37
37
|
var _a, _b;
|
|
38
38
|
for (const item of cartItems) {
|
|
39
39
|
const targetProduct = priceData.find((n) => n.id === item.id);
|
|
40
40
|
const cartProduct = await getProduct(
|
|
41
41
|
item.id
|
|
42
42
|
);
|
|
43
|
-
|
|
43
|
+
let productInfo = cartProduct == null ? void 0 : cartProduct.getData();
|
|
44
|
+
if (!productInfo) {
|
|
45
|
+
productInfo = item._productOrigin;
|
|
46
|
+
}
|
|
44
47
|
let bundle = item._bundleOrigin;
|
|
45
48
|
productInfo.price = targetProduct == null ? void 0 : targetProduct.price;
|
|
46
49
|
productInfo.base_price = targetProduct == null ? void 0 : targetProduct.base_price;
|
|
@@ -81,6 +84,10 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
81
84
|
return n;
|
|
82
85
|
});
|
|
83
86
|
}
|
|
87
|
+
updateItemInitInfo({
|
|
88
|
+
_id: item._id,
|
|
89
|
+
product: productInfo
|
|
90
|
+
});
|
|
84
91
|
updateCart({
|
|
85
92
|
_id: item._id,
|
|
86
93
|
product: productInfo,
|
|
@@ -259,7 +259,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
259
259
|
cartItems,
|
|
260
260
|
res,
|
|
261
261
|
(id) => this.store.products.getProduct(id),
|
|
262
|
-
(params) => this.store.cart.updateItem(params)
|
|
262
|
+
(params) => this.store.cart.updateItem(params),
|
|
263
|
+
(params) => this.store.cart.updateItemInitInfo(params)
|
|
263
264
|
);
|
|
264
265
|
this.core.effects.emit(
|
|
265
266
|
`${this.store.cart.name}:onUpdateQuotationPrice`,
|