lookPicture.html
9.78 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
.picdiv{
width:45%;
height:200px;
margin: 15px;
border: 1px solid #ddd;
white-space: nowrap;
float: left;
}
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<div class="container-fluid">
<div class="row-fluid">
<div class="col-sm-12">
<ul class="thumbnails">
<li class="col-sm-6">
<div class="thumbnail">
<img alt="车辆入厂照片" id="carIn" >
<div class="caption">
<p>
<span>车辆入厂拍照</span><a class="btn btn-primary" onclick="scan(1)">拍照</a>
</p>
</div>
</div>
</li>
<li class="col-sm-6">
<div class="thumbnail">
<img alt="身份证拍照" id="file2">
<div class="caption">
<p>
<span>身份证拍照</span><button class="btn btn-primary" onclick="scan(2)">拍照</button>
</p>
</div>
</div>
</li>
</ul>
</div>
<div class="col-sm-12">
<ul class="thumbnails">
<li class="col-sm-6">
<div class="thumbnail">
<img alt="驾驶证拍照" id="file3">
<div class="caption">
<p>
<span>驾驶证拍照</span><button class="btn btn-primary" onclick="scan(3)">拍照</button>
</p>
</div>
</div>
</li>
<li class="col-sm-6">
<div class="thumbnail">
<img alt="行驶证拍照" id="file4">
<div class="caption">
<p>
<span>行驶证拍照</span><button class="btn btn-primary" onclick="scan(4)">拍照</button>
</p>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<!-- <form class="form-horizontal m" id="form-camera-cameraReset">-->
<!-- <input name="id" type="hidden" />-->
<!-- -->
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<input id="vehicleName" name="vehicleName" class="form-control" type="hidden" th:value="${vehicleName}" >
<input id="cardNumber" name="cardNumber" class="form-control" type="hidden" th:value="${cardNumber}" >
<input id="carNumber" name="carNumber" class="form-control" type="hidden" th:value="${carNumber}" >
<input id="driverNumber" name="driverNumber" class="form-control" type="hidden" th:value="${driverNumber}" >
<button type="submit" class="btn btn-primary" onclick="select()">提交</button>
<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
</div>
</div>
<!-- </form>-->
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript">
$("#file2").attr("src", "http://127.0.0.1:38088/video=stream&camidx=0");
$("#file3").attr("src", "http://127.0.0.1:38088/video=stream&camidx=0");
$("#file4").attr("src", "http://127.0.0.1:38088/video=stream&camidx=0");
// $("#view2").attr("src", "http://127.0.0.1:38088/video=stream&camidx=1");
// 加载主头视频模式
view1_mode_data1 = { "camidx": "0", "mode": "0" };
view1_mode_data2 = { "camidx": "0", "mode": "1" };
$.post("http://127.0.0.1:38088/device=getresolution", JSON.stringify(view1_mode_data2), function(res){
})
// 加载副头视频模式
view2_mode_data1 = { "camidx": "1", "mode": "0" };
view2_mode_data2 = { "camidx": "1", "mode": "1" };
$.post("http://127.0.0.1:38088/device=getresolution", JSON.stringify(view2_mode_data2), function(res){
})
function getData(){
let url = "/wms/img/Capture/carIn.jpg?" + Date.parse(new Date());
if (!CheckImgExists(url)) {
window.setTimeout(function(){getData();},2000);
};
$("#carIn").attr('src',url);
}
//判断图片是否存在
function CheckImgExists(imgurl) {
var ImgObj = new Image(); //判断图片是否存在
ImgObj.src = imgurl;
//没有图片,则返回-1
if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
return true;
} else {
return false;
}
}
function scan(num){
if(num==1){
$.ajax({
cache : false,
type : "POST",
url : ctx + "API/WMS/v2/cameraLogin",
dataType: 'json',
data : {
"cameraId": "1"
},
async : false,
error : function(request) {
$.modal.alertError("请求失败!");
},
success : function(result) {
if (result.code == web_status.SUCCESS) {
getData();
}else{
$.modal.alertError(result.data);
}
}
});
}
if(num==2){
$.ajax({
cache : false,
type : "POST",
url : "http://127.0.0.1:38088/card=idcard",
dataType: 'json',
data : {},
async : false,
error : function(request) {
$.modal.alertError("请求失败!");
},
success : function(result) {
if(result.code == '0'){
downloadIamge("data:image/png;base64," + result.IDCardInfo.photoBase64_Z,$("#cardNumber").val())
$.modal.msgSuccess("下载成功");
}else{
$.modal.msgError("请将证件放对位置!!!")
}
}
});
}else if(num==3){
$.ajax({
cache : false,
type : "POST",
url : "http://127.0.0.1:38088/video=grabimage",
dataType: 'json',
data : {
"filepath": "base64",
"rotate": "0",
"deskew": "0",
"camidx": "0",
"ColorMode": "3",
"quality": "0"
},
async : false,
error : function(request) {
$.modal.alertError("请求失败!");
},
success : function(result) {
if(result.code == '1' ){
$.modal.msgError(result.message)
}else{
downloadIamge("data:image/png;base64," + result['photoBase64'],$("#carNumber").val())
$.modal.msgSuccess("下载成功");
}
}
});
}else if(num==4){
$.ajax({
cache : false,
type : "POST",
url : "http://127.0.0.1:38088/video=grabimage",
dataType: 'json',
data : {
"filepath": "base64",
"rotate": "0",
"deskew": "0",
"camidx": "0",
"ColorMode": "3",
"quality": "0"
},
async : false,
error : function(request) {
$.modal.alertError("请求失败!");
},
success : function(result) {
if(result.code == '1' ){
$.modal.msgError(result.message)
}else{
downloadIamge("data:image/png;base64," + result['photoBase64'],$("#driverNumber").val())
$.modal.msgSuccess("下载成功");
}
}
});
}
}
function select() {
$.modal.close();
}
function downloadIamge(selector, name) {
var image = new Image()
// 解决跨域 Canvas 污染问题
image.setAttribute('crossOrigin', 'anonymous')
image.onload = function () {
var canvas = document.createElement('canvas')
canvas.width = image.width
canvas.height = image.height
var context = canvas.getContext('2d')
context.drawImage(image, 0, 0, image.width, image.height)
var url = canvas.toDataURL('image/png')
// 生成一个a元素
var a = document.createElement('a')
// 创建一个单击事件
var event = new MouseEvent('click')
// 将a的download属性设置为我们想要下载的图片名称,若name不存在则使用‘下载图片名称’作为默认名称
a.download = name || new Date()
// 将生成的URL设置为a.href属性
a.href = url
// 触发a的单击事件
a.dispatchEvent(event)
}
image.src = selector
}
</script>
</body>
</html>