hjg
2024-03-18 8d48c59d5d3bcc4148ef97dc6f98e3a8cf9ca436
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
function toJsonForReader(str) {
            //var obj = JSON.parse(str);
            //return obj;
            return eval('(' + str + ')');
        }
/*
    <OBJECT classid="clsid:10946843-7507-44FE-ACE8-2B3483D179B7" id="CVR_IDCard" name="CVR_IDCard" width="0" height="0" ></OBJECT>
 
*/
        jQuery(document).ready(function($) {
            CertCtl=document.getElementById('CertCtl');
        });
 
//var CertCtl=document.getElementById('CertCtl');
function certreadCard () {
    var ttobj={};
    if(CertCtl==null){
        ttobj.code=1;
        ttobj.errmsg='没有找到读卡器句柄';
        return ttobj
    }
    try{
        var strReadResult = CertCtl.ReadCard();
        if(strReadResult=='0'){
            ttobj.code=0;
            ttobj.partyName= CertCtl.Name;
            ttobj.gender   = CertCtl.Sex;
            ttobj.nation   = CertCtl.Nation;
            ttobj.bornDay  = CertCtl.Born;
            ttobj.certAddress=CertCtl.Address;
            ttobj.certNumber= CertCtl.CardNo;
            ttobj.certOrg=  CertCtl.IssuedAt;
            ttobj.effDate= CertCtl.EffectedDate;
            ttobj.expDate=CertCtl.ExpiredDate;
            ttobj.identityPic=  CertCtl.pic;
            ttobj.base64ID_PicFront = CertCtl.Picture;
            ttobj.base64ID_PicBack = CertCtl.PictureLen;
            return ttobj;
        }else{
            ttobj.code=1;
            ttobj.errmsg=strReadResult;
            return ttobj;
        }
    }catch(e){
        console.log('read card error:'+e)
        ttobj.code=1;
        ttobj.errmsg=e;
        return ttobj;
    }
    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;
    }
}