scanner.html
3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>添加设备</title>
<link rel="stylesheet" type="text/css" href="../css/api.css" />
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<body class="scanner-view">
</body>
</html>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
var header = $api.byId('header');
fixStatusBar_API(header);
apiready = function() {
var isEmpty = api.pageParam.isEmpty;
var FNScanner = api.require('FNScanner');
api.addEventListener({
name:'pause'
}, function(ret, err){
FNScanner.onPause();
});
api.addEventListener({
name:'resume'
}, function(ret, err){
FNScanner.onResume();
});
FNScanner.openView({
autorotation: true,
rect:{
x: 0, //(可选项)数字类型;模块左上角的 x 坐标(相对于所属的 Window 或 Frame);默认:0
y: 0, //(可选项)数字类型;模块左上角的 y 坐标(相对于所属的 Window 或 Frame);默认:0
w: 'auto', //(可选项)数字类型;模块的宽度;支持设置'auto';默认:所属的 Window 或 Frame 的宽度
h: 'auto' //(可选项)数字类型;模块的高度;支持设置'auto';默认:所属的 Window 或 Frame 的高度
}
}, function(ret, err) {
if (ret) {
if (ret.eventType == 'cancel') {
if (isEmpty) {
api.alert({
title: '添加设备',
msg: '暂无设备,请先添加设备...',
}, function(ret, err){
if( ret ){
openCanner(isEmpty);
}
});
}
} else if (ret.eventType == 'success') {
var md5Reg = /^[a-f0-9]{15}$/;
if (md5Reg.test(ret.content)) {
api.openWin({ slidBackEnabled:false,
name: 'perfectInfo',
url: 'perfectInfo.html',
pageParam: {
"code": ret.content,
"isEmpty": isEmpty
}
});
} else {
api.alert({
title: '请扫描正确的设备二维码',
msg: '当前设备二维码不正确',
}, function(ret, err) {
openCanner(isEmpty);
});
}
}else{
api.openFrame({
name: 'scannerView',
url: 'scannerView.html',
rect: {
x:0,
y:0,
w:'auto',
h:'auto',
bounces: false,
bgColor: 'rgba(0,0,0,0)'
},
});
}
} else {
//alert(JSON.stringify(err));
}
});
setTimeout(function(){
FNScanner.closeView();
api.closeWin();
},3*60*1000);
}
</script>