@cniot/android-pda-components 1.1.2-beta.6 → 1.1.3
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/__test__/index.html +103 -0
- package/build/assets/{index.77abdbf5.js → index.c3ade150.js} +51 -51
- package/build/index.html +1 -1
- package/change.md +4 -0
- package/es/index.cjs.js +3 -3
- package/es/index.es.js +71 -8
- package/package.json +3 -2
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>Hello rfid</title>
|
|
8
|
+
<script src="https://g.alicdn.com/mtb/lib-windvane/3.0.6/windvane.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="root">hello</div>
|
|
13
|
+
<button onclick="location.reload()">刷新</button>
|
|
14
|
+
<script>
|
|
15
|
+
|
|
16
|
+
document.getElementById("root").innerHTML = Math.random()
|
|
17
|
+
// 扫 RFID 的逻辑
|
|
18
|
+
const START_KEYS = ["F22", "F23", "F24", "F9", "F16", 523];
|
|
19
|
+
// fn ,是否持续读取
|
|
20
|
+
function onAddEventListenrRfidRead(onRfidRead, isContinuous) {
|
|
21
|
+
let isFire = false;
|
|
22
|
+
function onRead(e) {
|
|
23
|
+
if (isContinuous) {
|
|
24
|
+
onRfidRead(e.param.rfidData, e.param.rfidHistory)
|
|
25
|
+
} else {
|
|
26
|
+
if (isFire === false) {
|
|
27
|
+
onRfidRead(e.param.rfidData, e.param.rfidHistory)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
isFire = true;
|
|
31
|
+
}
|
|
32
|
+
function onKeydown(e) {
|
|
33
|
+
// code: F23/F24; keyCode: 0; key: uniden...
|
|
34
|
+
const keyCode = e.param || e.keyCode;
|
|
35
|
+
if (START_KEYS.indexOf(keyCode) > -1) {
|
|
36
|
+
isFire = false
|
|
37
|
+
WindVane.call(
|
|
38
|
+
"WindvanePlugin",
|
|
39
|
+
"invoke",
|
|
40
|
+
"{'domain': 'rfid', 'method': 'startRfidScan', 'params': null}",
|
|
41
|
+
function (e) { },
|
|
42
|
+
function (e) { }
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function onKeyup(e) {
|
|
47
|
+
// code: F23/F24; keyCode: 0; key: uniden...
|
|
48
|
+
const keyCode = e.param || e.keyCode;
|
|
49
|
+
if (START_KEYS.indexOf(keyCode) > -1) {
|
|
50
|
+
WindVane.call(
|
|
51
|
+
"WindvanePlugin",
|
|
52
|
+
"invoke",
|
|
53
|
+
"{'domain': 'rfid', 'method': 'stopRfidScan', 'params': null}",
|
|
54
|
+
function (e) { },
|
|
55
|
+
function (e) { }
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
document.addEventListener("ContinuousRfidScan", onRead);
|
|
60
|
+
// IoT容器定制的2个事件
|
|
61
|
+
// onScanKeyDown,onScanKeyUp 是IOT的特殊事件,会抛出一个e.param = 523 的属性。
|
|
62
|
+
// PDA 不能监听 keydown, keyup
|
|
63
|
+
document.addEventListener("onScanKeyDown", onKeydown);
|
|
64
|
+
document.addEventListener("onScanKeyUp", onKeyup);
|
|
65
|
+
document.addEventListener("keydown", onKeydown);
|
|
66
|
+
document.addEventListener("keyup", onKeyup);
|
|
67
|
+
|
|
68
|
+
return function () {
|
|
69
|
+
document.removeEventListener("ContinuousRfidScan", onRead);
|
|
70
|
+
document.removeEventListener("onScanKeyDown", onKeydown);
|
|
71
|
+
document.removeEventListener("onScanKeyUp", onKeyup);
|
|
72
|
+
document.removeEventListener("keydown", onKeydown);
|
|
73
|
+
document.removeEventListener("keyup", onKeyup);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function onScanBarcode(fn) {
|
|
81
|
+
function callback(e) {
|
|
82
|
+
const barcode = String(e.param.scanData).trim();
|
|
83
|
+
fn && fn(barcode);
|
|
84
|
+
}
|
|
85
|
+
document.addEventListener("BarcodeScan", callback, false);
|
|
86
|
+
return function () {
|
|
87
|
+
document.removeEventListener("BarcodeScan", callback);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// onAddEventListenrRfidRead(function (code) {
|
|
93
|
+
// alert("rfid:" + code)
|
|
94
|
+
// }, true)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
onScanBarcode((code) => {
|
|
98
|
+
alert("barcode:" + code)
|
|
99
|
+
})
|
|
100
|
+
</script>
|
|
101
|
+
</body>
|
|
102
|
+
|
|
103
|
+
</html>
|