-
Notifications
You must be signed in to change notification settings - Fork 1
/
scanner.js
38 lines (38 loc) · 1.18 KB
/
scanner.js
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
$(function(){
new JSScanner(function(barcode){
$("#message-name").html('');
$("#message-info").html('请稍等...');
$("#message-name").removeClass("Error").removeClass("Pass").removeClass("Manually").removeClass("Repeat");
$("#message-info").removeClass("Error").removeClass("Pass").removeClass("Manually").removeClass("Repeat");
$.post("http://接口地址/home.php?c=JobAllowance&a=nverform",{ no : barcode },function(result){
var result=JSON.parse(result);
switch(result.code){
case 0:
var ClassName = "Error";
result.data.xm = '';
break;
case 1:
var ClassName = "Pass";
break;
case 2:
var ClassName = "Manually";
break;
case 3:
var ClassName = "Repeat";
break;
default:
result.data.count = 'X';
result.data.xm = 'X';
result.message = '失去连接';
var ClassName = "Error";
break;
}
$("#count-mid").html(result.data.count);
$("#message-name").html(result.data.xm);
$("#message-name").addClass(ClassName);
$("#message-info").html(result.message);
$("#message-info").addClass(ClassName);
$("#list").prepend('<div class="' + ClassName + '">' + barcode + '</div>');
});
});
});