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