@pisell/pisellos 0.0.138 → 0.0.140
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.
|
@@ -10,6 +10,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
10
10
|
private window;
|
|
11
11
|
private store;
|
|
12
12
|
private options;
|
|
13
|
+
private hooks?;
|
|
13
14
|
constructor(name?: string, version?: string);
|
|
14
15
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
15
16
|
destroy(): Promise<void>;
|
|
@@ -43,6 +43,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
43
43
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
44
44
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
45
45
|
_defineProperty(_assertThisInitialized(_this), "options", {});
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "hooks", void 0);
|
|
46
47
|
_this.store = {
|
|
47
48
|
customer: null,
|
|
48
49
|
productList: [],
|
|
@@ -57,12 +58,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
57
58
|
key: "initialize",
|
|
58
59
|
value: function () {
|
|
59
60
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
61
|
+
var _options$otherParams;
|
|
60
62
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
61
63
|
while (1) switch (_context.prev = _context.next) {
|
|
62
64
|
case 0:
|
|
63
65
|
this.core = core;
|
|
64
66
|
this.options = options;
|
|
65
67
|
this.store = _objectSpread(_objectSpread({}, this.store), options.store || {});
|
|
68
|
+
this.hooks = (_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 || (_options$otherParams = _options$otherParams.discount) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.hooks;
|
|
66
69
|
console.log('[ShopDiscount] 初始化完成');
|
|
67
70
|
|
|
68
71
|
// 获取依赖的插件
|
|
@@ -73,7 +76,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
73
76
|
|
|
74
77
|
// 注册事件监听
|
|
75
78
|
this.registerEventListeners();
|
|
76
|
-
case
|
|
79
|
+
case 8:
|
|
77
80
|
case "end":
|
|
78
81
|
return _context.stop();
|
|
79
82
|
}
|
|
@@ -428,18 +431,21 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
431
|
}, {
|
|
429
432
|
key: "setDiscountList",
|
|
430
433
|
value: function setDiscountList(discountList) {
|
|
431
|
-
var
|
|
434
|
+
var _this3 = this,
|
|
435
|
+
_this$store$discount5;
|
|
432
436
|
var productList = this.store.productList || [];
|
|
433
437
|
var editModeDiscountList = [];
|
|
434
438
|
productList.forEach(function (item) {
|
|
435
439
|
if (item.booking_id) {
|
|
440
|
+
var _this3$hooks;
|
|
441
|
+
var product = (_this3$hooks = _this3.hooks) === null || _this3$hooks === void 0 ? void 0 : _this3$hooks.getProduct(item);
|
|
436
442
|
(item.discount_list || []).forEach(function (discount) {
|
|
437
443
|
if (discount.id && ['good_pass', 'discount_card'].includes(discount.type)) {
|
|
438
444
|
var _discount$discount, _discount$discount2, _discount$discount3;
|
|
439
445
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
440
446
|
isEditMode: true,
|
|
441
447
|
limited_relation_product_data: {},
|
|
442
|
-
savedAmount: discount.amount,
|
|
448
|
+
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
443
449
|
isAvailable: true,
|
|
444
450
|
id: ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id,
|
|
445
451
|
format_title: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.title) || discount.format_title,
|
|
@@ -10,6 +10,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
10
10
|
private window;
|
|
11
11
|
private store;
|
|
12
12
|
private options;
|
|
13
|
+
private hooks?;
|
|
13
14
|
constructor(name?: string, version?: string);
|
|
14
15
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
15
16
|
destroy(): Promise<void>;
|
|
@@ -43,9 +43,11 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
43
43
|
}
|
|
44
44
|
// =========== 生命周期方法 ===========
|
|
45
45
|
async initialize(core, options) {
|
|
46
|
+
var _a, _b;
|
|
46
47
|
this.core = core;
|
|
47
48
|
this.options = options;
|
|
48
49
|
this.store = { ...this.store, ...options.store || {} };
|
|
50
|
+
this.hooks = (_b = (_a = options.otherParams) == null ? void 0 : _a.discount) == null ? void 0 : _b.hooks;
|
|
49
51
|
console.log("[ShopDiscount] 初始化完成");
|
|
50
52
|
this.initializePlugins();
|
|
51
53
|
this.registerDependentModules();
|
|
@@ -268,17 +270,19 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
268
270
|
const productList = this.store.productList || [];
|
|
269
271
|
const editModeDiscountList = [];
|
|
270
272
|
productList.forEach((item) => {
|
|
273
|
+
var _a2;
|
|
271
274
|
if (item.booking_id) {
|
|
275
|
+
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
272
276
|
(item.discount_list || []).forEach((discount) => {
|
|
273
|
-
var
|
|
277
|
+
var _a3, _b, _c;
|
|
274
278
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
275
279
|
editModeDiscountList.push({
|
|
276
280
|
...discount,
|
|
277
281
|
isEditMode: true,
|
|
278
282
|
limited_relation_product_data: {},
|
|
279
|
-
savedAmount: discount.amount,
|
|
283
|
+
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|
|
280
284
|
isAvailable: true,
|
|
281
|
-
id: ((
|
|
285
|
+
id: ((_a3 = discount.discount) == null ? void 0 : _a3.resource_id) || discount.id,
|
|
282
286
|
format_title: ((_b = discount.discount) == null ? void 0 : _b.title) || discount.format_title,
|
|
283
287
|
isDisabled: true,
|
|
284
288
|
isSelected: true,
|