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;
|
}
|
}
|