Administrator
2023-04-19 40ec16bbb7c9d23df625aa31ae42ac36e901749d
提交 | 用户 | 时间
58d006 1 function toJsonForReader(str) {
A 2             //var obj = JSON.parse(str);
3             //return obj;
4             return eval('(' + str + ')');
5         }
6
7         jQuery(document).ready(function($) {
8             CertCtl=document.getElementById('CertCtl');
9         });
10
11 //var CertCtl=document.getElementById('CertCtl');
12 function certreadCard () {
13     if(CertCtl==null){
14         console.log('没有找到读卡器句柄');
15         return null;
16     }
17     var result=CertCtl.connect();
18     // console.log("connect result::"+result);
19     result=toJsonForReader(result);
20     if(result.resultFlag<0){
21         console.log(result.errorMsg)
22         CertCtl.disconnect();
23         return null;
24     }
25     var string=CertCtl.readCert();
26     CertCtl.disconnect();
27     var resultObj=toJsonForReader(string);
28     var ttobj={};
29     if (resultObj.resultFlag == 0) {
30         ttobj.partyName= resultObj.resultContent.partyName;
31         ttobj.gender   = resultObj.resultContent.gender;
32         ttobj.nation   = resultObj.resultContent.nation;
33         ttobj.bornDay  = resultObj.resultContent.bornDay;
34         ttobj.certAddress=resultObj.resultContent.certAddress;
35         ttobj.certNumber= resultObj.resultContent.certNumber;
36         ttobj.certOrg=  resultObj.resultContent.certOrg;
37         ttobj.effDate= resultObj.resultContent.effDate;
38         ttobj.expDate=resultObj.resultContent.expDate;
39         ttobj.identityPic=  "data:image/jpeg;base64," + resultObj.resultContent.identityPic;
40         ttobj.base64ID_PicFront = "data:image/jpeg;base64," + resultObj.resultContent.base64ID_PicFront;
41         ttobj.base64ID_PicBack = "data:image/jpeg;base64," + resultObj.resultContent.base64ID_PicBack;
42        }
43     return ttobj;
44 }
45
46
47
48 function setCertReaderInterval(sec,callback){
49     clearCertReaderInterval();
50     window.certreaderintervalid=setInterval(function(){
51         var readobj=certreadCard();
52         callback(readobj);
53         readobj=null;
54     },sec);
55 }
56 function clearCertReaderInterval(){
57     if(window.certreaderintervalid!=null){
58         clearInterval(window.certreaderintervalid);
59         window.certreaderintervalid=null;
60     }
61 }
62
63
64
65
66
67