hjg
2023-10-14 f6c2f15c37aef4675dda01fb5ec17cde4e141c3f
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
function toJsonForReader(str) {
            //var obj = JSON.parse(str);
            //return obj;
            return eval('(' + str + ')');
        }
 
        jQuery(document).ready(function($) {
            CertCtl=document.getElementById('CertCtl');
        });
 
//var CertCtl=document.getElementById('CertCtl');
function certreadCard () {
    if(CertCtl==null){
        console.log('没有找到读卡器句柄');
        return null;
    }
    var result=CertCtl.connect();
    // console.log("connect result::"+result);
    result=toJsonForReader(result);
    if(result.resultFlag<0){
        console.log(result.errorMsg)
        CertCtl.disconnect();
        return null;
    }
    var string=CertCtl.readCert();
    CertCtl.disconnect();
    var resultObj=toJsonForReader(string);
    var ttobj={};
    if (resultObj.resultFlag == 0) {
        ttobj.partyName= resultObj.resultContent.partyName;
        ttobj.gender   = resultObj.resultContent.gender;
        ttobj.nation   = resultObj.resultContent.nation;
        ttobj.bornDay  = resultObj.resultContent.bornDay;
        ttobj.certAddress=resultObj.resultContent.certAddress;
        ttobj.certNumber= resultObj.resultContent.certNumber;
        ttobj.certOrg=  resultObj.resultContent.certOrg;
        ttobj.effDate= resultObj.resultContent.effDate;
        ttobj.expDate=resultObj.resultContent.expDate;
        ttobj.identityPic=  "data:image/jpeg;base64," + resultObj.resultContent.identityPic;
        ttobj.base64ID_PicFront = "data:image/jpeg;base64," + resultObj.resultContent.base64ID_PicFront;
        ttobj.base64ID_PicBack = "data:image/jpeg;base64," + resultObj.resultContent.base64ID_PicBack;
       }
    return ttobj;
}
 
 
 
function setCertReaderInterval(sec,callback){
    clearCertReaderInterval();
    window.certreaderintervalid=setInterval(function(){
        var readobj=certreadCard();
        callback(readobj);
        readobj=null;
    },sec);
}
function clearCertReaderInterval(){
    if(window.certreaderintervalid!=null){
        clearInterval(window.certreaderintervalid);
        window.certreaderintervalid=null;
    }
}