@pisell/pisellos 0.0.326 → 0.0.328
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/effects/index.d.ts +1 -0
- package/dist/effects/index.js +29 -6
- package/dist/modules/Customer/types.d.ts +2 -2
- package/dist/modules/Customer/types.js +2 -2
- package/dist/modules/Order/index.js +1 -1
- package/dist/modules/Payment/index.js +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -0
- package/dist/solution/BookingTicket/index.js +10 -1
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
- package/dist/solution/ShopDiscount/index.js +8 -8
- package/dist/types/index.d.ts +1 -0
- package/lib/effects/index.d.ts +1 -0
- package/lib/effects/index.js +13 -0
- package/lib/modules/Customer/types.d.ts +2 -2
- package/lib/modules/Customer/types.js +2 -2
- package/lib/modules/Order/index.js +1 -1
- package/lib/modules/Payment/index.js +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
- package/lib/solution/ShopDiscount/index.js +9 -9
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/effects/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type UnsubscribeFunction = () => void;
|
|
|
6
6
|
declare class EffectsManager {
|
|
7
7
|
private listeners;
|
|
8
8
|
on(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
9
|
+
only(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
9
10
|
off(event: string, callback: EffectCallback): void;
|
|
10
11
|
offByModuleDestroy(module: string): void;
|
|
11
12
|
once(event: string, callback: EffectCallback): UnsubscribeFunction;
|
package/dist/effects/index.js
CHANGED
|
@@ -30,28 +30,51 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
30
30
|
_this.off(event, callback);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
// 设置单例监听器,只能存在一个,新的会替换旧的
|
|
35
|
+
}, {
|
|
36
|
+
key: "only",
|
|
37
|
+
value: function only(event, callback) {
|
|
38
|
+
var _this$listeners$get3,
|
|
39
|
+
_this2 = this;
|
|
40
|
+
// 清除该事件的所有现有监听器
|
|
41
|
+
if (this.listeners.has(event)) {
|
|
42
|
+
var _this$listeners$get2;
|
|
43
|
+
(_this$listeners$get2 = this.listeners.get(event)) === null || _this$listeners$get2 === void 0 || _this$listeners$get2.clear();
|
|
44
|
+
} else {
|
|
45
|
+
this.listeners.set(event, new Set());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 添加新的监听器
|
|
49
|
+
(_this$listeners$get3 = this.listeners.get(event)) === null || _this$listeners$get3 === void 0 || _this$listeners$get3.add(callback);
|
|
50
|
+
|
|
51
|
+
// 返回取消函数
|
|
52
|
+
return function () {
|
|
53
|
+
_this2.off(event, callback);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
33
56
|
}, {
|
|
34
57
|
key: "off",
|
|
35
58
|
value: function off(event, callback) {
|
|
36
|
-
var _this$listeners$
|
|
37
|
-
(_this$listeners$
|
|
59
|
+
var _this$listeners$get4;
|
|
60
|
+
(_this$listeners$get4 = this.listeners.get(event)) === null || _this$listeners$get4 === void 0 || _this$listeners$get4.delete(callback);
|
|
38
61
|
}
|
|
39
62
|
|
|
40
63
|
// 模块销毁时,删除所有以模块名开头的监听
|
|
41
64
|
}, {
|
|
42
65
|
key: "offByModuleDestroy",
|
|
43
66
|
value: function offByModuleDestroy(module) {
|
|
44
|
-
var
|
|
67
|
+
var _this3 = this;
|
|
45
68
|
Array.from(this.listeners.keys()).forEach(function (item) {
|
|
46
69
|
if (item.startsWith(module)) {
|
|
47
|
-
|
|
70
|
+
_this3.listeners.delete(item);
|
|
48
71
|
}
|
|
49
72
|
});
|
|
50
73
|
}
|
|
51
74
|
}, {
|
|
52
75
|
key: "once",
|
|
53
76
|
value: function once(event, callback) {
|
|
54
|
-
var
|
|
77
|
+
var _this4 = this;
|
|
55
78
|
var wrapper = /*#__PURE__*/function () {
|
|
56
79
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload) {
|
|
57
80
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -60,7 +83,7 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
60
83
|
_context.next = 2;
|
|
61
84
|
return callback(payload);
|
|
62
85
|
case 2:
|
|
63
|
-
|
|
86
|
+
_this4.off(event, wrapper);
|
|
64
87
|
case 3:
|
|
65
88
|
case "end":
|
|
66
89
|
return _context.stop();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ICustomer } from "../AccountList/types";
|
|
2
2
|
export declare enum CustomerHooks {
|
|
3
|
-
OnCustomerListUpdate = "customer:
|
|
3
|
+
OnCustomerListUpdate = "customer:onCustomerListUpdate",
|
|
4
4
|
OnCustomerListError = "customer:onError",
|
|
5
|
-
OnCustomerSelected = "customer:
|
|
5
|
+
OnCustomerSelected = "customer:onCustomerSelected",
|
|
6
6
|
OnPaginationChange = "customer:onPaginationChange",
|
|
7
7
|
OnScrollLoadMore = "customer:onScrollLoadMore",
|
|
8
8
|
OnScrollLoadComplete = "customer:onScrollLoadComplete"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var CustomerHooks = /*#__PURE__*/function (CustomerHooks) {
|
|
2
|
-
CustomerHooks["OnCustomerListUpdate"] = "customer:
|
|
2
|
+
CustomerHooks["OnCustomerListUpdate"] = "customer:onCustomerListUpdate";
|
|
3
3
|
CustomerHooks["OnCustomerListError"] = "customer:onError";
|
|
4
|
-
CustomerHooks["OnCustomerSelected"] = "customer:
|
|
4
|
+
CustomerHooks["OnCustomerSelected"] = "customer:onCustomerSelected";
|
|
5
5
|
CustomerHooks["OnPaginationChange"] = "customer:onPaginationChange";
|
|
6
6
|
CustomerHooks["OnScrollLoadMore"] = "customer:onScrollLoadMore";
|
|
7
7
|
CustomerHooks["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
|
|
@@ -35,7 +35,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
35
35
|
function OrderModule(name, version) {
|
|
36
36
|
var _this;
|
|
37
37
|
_classCallCheck(this, OrderModule);
|
|
38
|
-
_this = _super.call(this, name, version);
|
|
38
|
+
_this = _super.call(this, name || "order", version);
|
|
39
39
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'order');
|
|
40
40
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
41
41
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
@@ -73,7 +73,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
73
73
|
function PaymentModule(name, version) {
|
|
74
74
|
var _this;
|
|
75
75
|
_classCallCheck(this, PaymentModule);
|
|
76
|
-
_this = _super.call(this, name, version);
|
|
76
|
+
_this = _super.call(this, name || "payment", version);
|
|
77
77
|
// 初始化支付方式实例
|
|
78
78
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'pay');
|
|
79
79
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
@@ -22,6 +22,10 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
22
22
|
* @returns 商品列表
|
|
23
23
|
*/
|
|
24
24
|
loadProducts(params?: ILoadProductsParams): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* 初始化外设扫码结果监听
|
|
27
|
+
*/
|
|
28
|
+
initPeripheralsListener(): void;
|
|
25
29
|
/**
|
|
26
30
|
* 获取商品列表(不加载到模块中)
|
|
27
31
|
* @returns 商品列表
|
|
@@ -170,11 +170,20 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
170
170
|
}
|
|
171
171
|
return loadProducts;
|
|
172
172
|
}()
|
|
173
|
+
/**
|
|
174
|
+
* 初始化外设扫码结果监听
|
|
175
|
+
*/
|
|
176
|
+
)
|
|
177
|
+
}, {
|
|
178
|
+
key: "initPeripheralsListener",
|
|
179
|
+
value: function initPeripheralsListener() {
|
|
180
|
+
this.scan.initPeripheralsListener();
|
|
181
|
+
}
|
|
182
|
+
|
|
173
183
|
/**
|
|
174
184
|
* 获取商品列表(不加载到模块中)
|
|
175
185
|
* @returns 商品列表
|
|
176
186
|
*/
|
|
177
|
-
)
|
|
178
187
|
}, {
|
|
179
188
|
key: "getProducts",
|
|
180
189
|
value: (function () {
|
|
@@ -18,9 +18,6 @@ var ScanResultType = /*#__PURE__*/function (ScanResultType) {
|
|
|
18
18
|
}(ScanResultType || {});
|
|
19
19
|
var Scan = /*#__PURE__*/function () {
|
|
20
20
|
function Scan(solution, watchKey) {
|
|
21
|
-
var _this$solution,
|
|
22
|
-
_this$solution$mountF,
|
|
23
|
-
_this = this;
|
|
24
21
|
_classCallCheck(this, Scan);
|
|
25
22
|
_defineProperty(this, "solution", void 0);
|
|
26
23
|
_defineProperty(this, "watchKey", void 0);
|
|
@@ -28,24 +25,36 @@ var Scan = /*#__PURE__*/function () {
|
|
|
28
25
|
this.solution = solution;
|
|
29
26
|
this.watchKey = watchKey;
|
|
30
27
|
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
var _result = JSON.parse(strVal);
|
|
35
|
-
console.log('nativeScannerResult>>>>>>>', _result);
|
|
36
|
-
_this.handleScan(_result);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
console.error(err);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
28
|
+
// 初始化扫码监听
|
|
29
|
+
this.initPeripheralsListener();
|
|
41
30
|
}
|
|
42
31
|
|
|
43
32
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param eventKey 事件key
|
|
46
|
-
* @param value 扫码结果
|
|
33
|
+
* 初始化外设扫码结果监听
|
|
47
34
|
*/
|
|
48
35
|
_createClass(Scan, [{
|
|
36
|
+
key: "initPeripheralsListener",
|
|
37
|
+
value: function initPeripheralsListener() {
|
|
38
|
+
var _this$solution,
|
|
39
|
+
_this$solution$mountF,
|
|
40
|
+
_this = this;
|
|
41
|
+
(_this$solution = this.solution) === null || _this$solution === void 0 || (_this$solution = _this$solution.window) === null || _this$solution === void 0 || (_this$solution = _this$solution.interaction) === null || _this$solution === void 0 || (_this$solution = _this$solution.utils) === null || _this$solution === void 0 || (_this$solution$mountF = _this$solution.mountFunction) === null || _this$solution$mountF === void 0 || _this$solution$mountF.call(_this$solution, 'global', 'peripheralsResult', function (strVal) {
|
|
42
|
+
try {
|
|
43
|
+
var _result = JSON.parse(strVal);
|
|
44
|
+
console.log('nativeScannerResult>>>>>>>', _result);
|
|
45
|
+
_this.handleScan(_result);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
console.error(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 处理扫码事件
|
|
54
|
+
* @param eventKey 事件key
|
|
55
|
+
* @param value 扫码结果
|
|
56
|
+
*/
|
|
57
|
+
}, {
|
|
49
58
|
key: "handleScan",
|
|
50
59
|
value: function handleScan(result) {
|
|
51
60
|
var lastEnableEventKey = watch.getLastEnableEventKey(this.watchKey);
|
|
@@ -195,7 +195,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
195
195
|
key: "registerEventListeners",
|
|
196
196
|
value: function registerEventListeners() {
|
|
197
197
|
var _this2 = this;
|
|
198
|
-
this.core.effects.
|
|
198
|
+
this.core.effects.only("".concat(this.name, ":onCustomerChange"), function (customer) {
|
|
199
199
|
var _this2$options$otherP;
|
|
200
200
|
if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
|
|
201
201
|
return;
|
|
@@ -306,7 +306,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
306
306
|
}
|
|
307
307
|
this.store.customer = customer;
|
|
308
308
|
_context6.next = 4;
|
|
309
|
-
return this.core.effects.emit(
|
|
309
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerChange"), customer);
|
|
310
310
|
case 4:
|
|
311
311
|
case "end":
|
|
312
312
|
return _context6.stop();
|
|
@@ -531,7 +531,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
531
531
|
while (1) switch (_context8.prev = _context8.next) {
|
|
532
532
|
case 0:
|
|
533
533
|
_context8.next = 2;
|
|
534
|
-
return this.core.effects.emit(
|
|
534
|
+
return this.core.effects.emit("".concat(this.name, ":onDiscountListChange"), discountList);
|
|
535
535
|
case 2:
|
|
536
536
|
case "end":
|
|
537
537
|
return _context8.stop();
|
|
@@ -662,7 +662,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
662
662
|
customer = Object.assign({}, (_objectDestructuringEmpty(_result2.data), _result2.data));
|
|
663
663
|
this.setCustomer(customer);
|
|
664
664
|
_context9.next = 9;
|
|
665
|
-
return this.core.effects.emit(
|
|
665
|
+
return this.core.effects.emit("".concat(this.name, ":onScanCustomerChange"), customer);
|
|
666
666
|
case 9:
|
|
667
667
|
_context9.next = 14;
|
|
668
668
|
break;
|
|
@@ -699,10 +699,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
699
699
|
_result3 = this.calcDiscount(this.store.productList);
|
|
700
700
|
cb === null || cb === void 0 || cb(_result3);
|
|
701
701
|
_context10.next = 7;
|
|
702
|
-
return this.core.effects.emit(
|
|
702
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
703
703
|
case 7:
|
|
704
704
|
_context10.next = 9;
|
|
705
|
-
return this.core.effects.emit(
|
|
705
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
706
706
|
case 9:
|
|
707
707
|
case "end":
|
|
708
708
|
return _context10.stop();
|
|
@@ -759,10 +759,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
759
759
|
}
|
|
760
760
|
_result4 = this.calcDiscount(this.store.productList);
|
|
761
761
|
_context11.next = 19;
|
|
762
|
-
return this.core.effects.emit(
|
|
762
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result4);
|
|
763
763
|
case 19:
|
|
764
764
|
_context11.next = 21;
|
|
765
|
-
return this.core.effects.emit(
|
|
765
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
766
766
|
case 21:
|
|
767
767
|
_context11.next = 26;
|
|
768
768
|
break;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface PisellCore {
|
|
|
40
40
|
effects: {
|
|
41
41
|
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
42
42
|
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
|
+
only: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
44
|
off: (event: string, callback: (payload: any) => void) => void;
|
|
44
45
|
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
45
46
|
status: boolean;
|
package/lib/effects/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type UnsubscribeFunction = () => void;
|
|
|
6
6
|
declare class EffectsManager {
|
|
7
7
|
private listeners;
|
|
8
8
|
on(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
9
|
+
only(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
9
10
|
off(event: string, callback: EffectCallback): void;
|
|
10
11
|
offByModuleDestroy(module: string): void;
|
|
11
12
|
once(event: string, callback: EffectCallback): UnsubscribeFunction;
|
package/lib/effects/index.js
CHANGED
|
@@ -35,6 +35,19 @@ var EffectsManager = class {
|
|
|
35
35
|
this.off(event, callback);
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
// 设置单例监听器,只能存在一个,新的会替换旧的
|
|
39
|
+
only(event, callback) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (this.listeners.has(event)) {
|
|
42
|
+
(_a = this.listeners.get(event)) == null ? void 0 : _a.clear();
|
|
43
|
+
} else {
|
|
44
|
+
this.listeners.set(event, /* @__PURE__ */ new Set());
|
|
45
|
+
}
|
|
46
|
+
(_b = this.listeners.get(event)) == null ? void 0 : _b.add(callback);
|
|
47
|
+
return () => {
|
|
48
|
+
this.off(event, callback);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
38
51
|
off(event, callback) {
|
|
39
52
|
var _a;
|
|
40
53
|
(_a = this.listeners.get(event)) == null ? void 0 : _a.delete(callback);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ICustomer } from "../AccountList/types";
|
|
2
2
|
export declare enum CustomerHooks {
|
|
3
|
-
OnCustomerListUpdate = "customer:
|
|
3
|
+
OnCustomerListUpdate = "customer:onCustomerListUpdate",
|
|
4
4
|
OnCustomerListError = "customer:onError",
|
|
5
|
-
OnCustomerSelected = "customer:
|
|
5
|
+
OnCustomerSelected = "customer:onCustomerSelected",
|
|
6
6
|
OnPaginationChange = "customer:onPaginationChange",
|
|
7
7
|
OnScrollLoadMore = "customer:onScrollLoadMore",
|
|
8
8
|
OnScrollLoadComplete = "customer:onScrollLoadComplete"
|
|
@@ -23,9 +23,9 @@ __export(types_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
25
|
var CustomerHooks = /* @__PURE__ */ ((CustomerHooks2) => {
|
|
26
|
-
CustomerHooks2["OnCustomerListUpdate"] = "customer:
|
|
26
|
+
CustomerHooks2["OnCustomerListUpdate"] = "customer:onCustomerListUpdate";
|
|
27
27
|
CustomerHooks2["OnCustomerListError"] = "customer:onError";
|
|
28
|
-
CustomerHooks2["OnCustomerSelected"] = "customer:
|
|
28
|
+
CustomerHooks2["OnCustomerSelected"] = "customer:onCustomerSelected";
|
|
29
29
|
CustomerHooks2["OnPaginationChange"] = "customer:onPaginationChange";
|
|
30
30
|
CustomerHooks2["OnScrollLoadMore"] = "customer:onScrollLoadMore";
|
|
31
31
|
CustomerHooks2["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
|
|
@@ -39,7 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
39
39
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
40
40
|
// LoggerManager 实例
|
|
41
41
|
constructor(name, version) {
|
|
42
|
-
super(name, version);
|
|
42
|
+
super(name || "order", version);
|
|
43
43
|
this.defaultName = "order";
|
|
44
44
|
this.defaultVersion = "1.0.0";
|
|
45
45
|
}
|
|
@@ -55,7 +55,7 @@ function generateRequestUniqueId() {
|
|
|
55
55
|
}
|
|
56
56
|
var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
57
57
|
constructor(name, version) {
|
|
58
|
-
super(name, version);
|
|
58
|
+
super(name || "payment", version);
|
|
59
59
|
this.defaultName = "pay";
|
|
60
60
|
this.defaultVersion = "1.0.0";
|
|
61
61
|
// LoggerManager 实例
|
|
@@ -22,6 +22,10 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
22
22
|
* @returns 商品列表
|
|
23
23
|
*/
|
|
24
24
|
loadProducts(params?: ILoadProductsParams): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* 初始化外设扫码结果监听
|
|
27
|
+
*/
|
|
28
|
+
initPeripheralsListener(): void;
|
|
25
29
|
/**
|
|
26
30
|
* 获取商品列表(不加载到模块中)
|
|
27
31
|
* @returns 商品列表
|
|
@@ -37,9 +37,15 @@ var import_task = __toESM(require("../../../../utils/task"));
|
|
|
37
37
|
var Scan = class {
|
|
38
38
|
constructor(solution, watchKey) {
|
|
39
39
|
this.listenerConfig = /* @__PURE__ */ new Map();
|
|
40
|
-
var _a, _b, _c, _d, _e;
|
|
41
40
|
this.solution = solution;
|
|
42
41
|
this.watchKey = watchKey;
|
|
42
|
+
this.initPeripheralsListener();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 初始化外设扫码结果监听
|
|
46
|
+
*/
|
|
47
|
+
initPeripheralsListener() {
|
|
48
|
+
var _a, _b, _c, _d, _e;
|
|
43
49
|
(_e = (_d = (_c = (_b = (_a = this.solution) == null ? void 0 : _a.window) == null ? void 0 : _b.interaction) == null ? void 0 : _c.utils) == null ? void 0 : _d.mountFunction) == null ? void 0 : _e.call(
|
|
44
50
|
_d,
|
|
45
51
|
"global",
|
|
@@ -126,8 +126,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
126
126
|
this.store.rules = rules;
|
|
127
127
|
}
|
|
128
128
|
registerEventListeners() {
|
|
129
|
-
this.core.effects.
|
|
130
|
-
|
|
129
|
+
this.core.effects.only(
|
|
130
|
+
`${this.name}:onCustomerChange`,
|
|
131
131
|
(customer) => {
|
|
132
132
|
var _a;
|
|
133
133
|
if (((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) && this.getDiscountList().length) {
|
|
@@ -182,7 +182,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
182
182
|
if (((_a = this.store.customer) == null ? void 0 : _a.id) !== customer.id) {
|
|
183
183
|
this.store.customer = customer;
|
|
184
184
|
await this.core.effects.emit(
|
|
185
|
-
|
|
185
|
+
`${this.name}:onCustomerChange`,
|
|
186
186
|
customer
|
|
187
187
|
);
|
|
188
188
|
}
|
|
@@ -328,7 +328,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
328
328
|
// 触发优惠列表变更事件
|
|
329
329
|
async emitDiscountListChange(discountList) {
|
|
330
330
|
await this.core.effects.emit(
|
|
331
|
-
|
|
331
|
+
`${this.name}:onDiscountListChange`,
|
|
332
332
|
discountList
|
|
333
333
|
);
|
|
334
334
|
}
|
|
@@ -426,7 +426,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
426
426
|
const { ...customer } = result.data;
|
|
427
427
|
this.setCustomer(customer);
|
|
428
428
|
await this.core.effects.emit(
|
|
429
|
-
|
|
429
|
+
`${this.name}:onScanCustomerChange`,
|
|
430
430
|
customer
|
|
431
431
|
);
|
|
432
432
|
}
|
|
@@ -442,12 +442,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
442
442
|
const result = this.calcDiscount(this.store.productList);
|
|
443
443
|
cb == null ? void 0 : cb(result);
|
|
444
444
|
await this.core.effects.emit(
|
|
445
|
-
|
|
445
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
446
446
|
result
|
|
447
447
|
);
|
|
448
448
|
}
|
|
449
449
|
await this.core.effects.emit(
|
|
450
|
-
|
|
450
|
+
`${this.name}:onLoadDiscountList`,
|
|
451
451
|
newDiscountList
|
|
452
452
|
);
|
|
453
453
|
}
|
|
@@ -476,12 +476,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
476
476
|
if ((_e = this.store.productList) == null ? void 0 : _e.length) {
|
|
477
477
|
const result = this.calcDiscount(this.store.productList);
|
|
478
478
|
await this.core.effects.emit(
|
|
479
|
-
|
|
479
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
480
480
|
result
|
|
481
481
|
);
|
|
482
482
|
}
|
|
483
483
|
await this.core.effects.emit(
|
|
484
|
-
|
|
484
|
+
`${this.name}:onLoadDiscountList`,
|
|
485
485
|
filteredDiscountList
|
|
486
486
|
);
|
|
487
487
|
} catch (error) {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface PisellCore {
|
|
|
40
40
|
effects: {
|
|
41
41
|
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
42
42
|
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
|
+
only: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
44
|
off: (event: string, callback: (payload: any) => void) => void;
|
|
44
45
|
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
45
46
|
status: boolean;
|