Administrator
2021-12-13 9a15635cc63daba09d09fcfb33aaef4d3162ac03
身份证读卡器连接修改
1 files modified
86 ■■■■ changed files
src/views/securityGuard/sfzJS.js 86 ●●●● patch | view | raw | blame | history
src/views/securityGuard/sfzJS.js
@@ -55,9 +55,9 @@
    //compatibility for firefox and chrome
    var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
    var pc = new myPeerConnection({
        iceServers: []
    }),
        noop = function () { },
            iceServers: []
        }),
        noop = function() {},
        localIPs = {},
        ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
        key;
@@ -71,19 +71,19 @@
    pc.createDataChannel("");
    // create offer and set local description
    pc.createOffer().then(function (sdp) {
        sdp.sdp.split('\n').forEach(function (line) {
    pc.createOffer().then(function(sdp) {
        sdp.sdp.split('\n').forEach(function(line) {
            if (line.indexOf('candidate') < 0) return;
            line.match(ipRegex).forEach(iterateIP);
        });
        pc.setLocalDescription(sdp, noop, noop);
    }).catch(function (reason) {
    }).catch(function(reason) {
        // An error occurred, so handle the failure to connect
    });
    //sten for candidate events
    pc.onicecandidate = function (ice) {
    pc.onicecandidate = function(ice) {
        if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return;
        ice.candidate.candidate.match(ipRegex).forEach(iterateIP);
    };
@@ -99,14 +99,14 @@
    // console.log(baseURL, 666666);
    var result = "";
    // var iParam1 = "1";
    var urls = "http://127.0.0.1:18889/api/connect";
    var urls = "http://localhost:18889/api/connect";
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    // CertCtl.xhr.open("POST", "http://" + baseURL + ":18889/api/connect", false);
    CertCtl.xhr.open("POST", urls, false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    //返回值readyState   0: 请求未初始化
    //                    1: 服务器连接已建立
    //                    2:请求已接收
@@ -128,11 +128,11 @@
function CertCtl_disconnect() {
    var result = "";
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/disconnect", false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/disconnect", false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -143,11 +143,11 @@
function CertCtl_getStatus() {
    var result = "";
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/getStatus", false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/getStatus", false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -160,8 +160,8 @@
    var result = "";
    try {
        //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
        CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/readCard", false); //readCard读卡,不生成正反面仿复印件
        //CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/readCert", false);      //readCert读卡,生成正反面仿复印件
        CertCtl.xhr.open("POST", "http://localhost:18889/api/readCard", false); //readCard读卡,不生成正反面仿复印件
        //CertCtl.xhr.open("POST", "http://localhost:18889/api/readCert", false);      //readCert读卡,生成正反面仿复印件
        //发送请求
        CertCtl.xhr.send();
        if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
@@ -178,11 +178,11 @@
function CertCtl_readICCardSN() {
    var result = "";
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/readICCardSN", false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/readICCardSN", false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -194,11 +194,11 @@
function CertCtl_readIDCardSN() {
    var result = "";
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/readIDCardSN", false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/readIDCardSN", false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -212,11 +212,11 @@
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    //getSAMID 获取的SAMID,格式为:05032013102800015247360103645891
    //getSAMIDStr 获取SAMID,格式为:05.03-20131028-0001524736-0103645891
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/getSAMIDStr", false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/getSAMIDStr", false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -249,12 +249,12 @@
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/readM1Card?" + "SID=" + sid + "&BID=" + bid + "&KEYTYPE=" + keyType + "&KEY=" + key, false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/readM1Card?" + "SID=" + sid + "&BID=" + bid + "&KEYTYPE=" + keyType + "&KEY=" + key, false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -290,12 +290,12 @@
        data = document.getElementById("cmd").value;
    }
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/writeM1Card?" + "SID=" + sid + "&BID=" + bid + "&KEYTYPE=" + keyType + "&KEY=" + key + "&DATA=" + data, false);
    //CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/writeM1Card?"+"SID="+sid+"&BID="+bid+"&KEYTYPE="+keyType+"&KEY="+key+"&DATA="+data, false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/writeM1Card?" + "SID=" + sid + "&BID=" + bid + "&KEYTYPE=" + keyType + "&KEY=" + key + "&DATA=" + data, false);
    //CertCtl.xhr.open("POST", "http://localhost:18889/api/writeM1Card?"+"SID="+sid+"&BID="+bid+"&KEYTYPE="+keyType+"&KEY="+key+"&DATA="+data, false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -311,11 +311,11 @@
        cmd = document.getElementById("cmd").value;
    }
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/handleAPDUCMD?" + "APDUCMD=" + cmd, false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/handleAPDUCMD?" + "APDUCMD=" + cmd, false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -334,7 +334,7 @@
    }
    
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/setProgramCode?"+"PROGRAMCODE="+programData, false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/setProgramCode?"+"PROGRAMCODE="+programData, false);
    //发送请求
    try {
        CertCtl.xhr.send();
@@ -354,11 +354,11 @@
        programData = document.getElementById("programData").value;
    }
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/checkProgramCode?" + "PROGRAMCODE=" + programData, false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/checkProgramCode?" + "PROGRAMCODE=" + programData, false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -371,11 +371,11 @@
    var result = "";
    var IsMute = false; //false - 开声音(默认开), true - 关声音
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://127.0.0.1:18889/api/Routon_Mute?" + "ISMUTE=" + IsMute, false);
    CertCtl.xhr.open("POST", "http://localhost:18889/api/Routon_Mute?" + "ISMUTE=" + IsMute, false);
    //发送请求
    try {
        CertCtl.xhr.send();
    } catch (e) { }
    } catch (e) {}
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
@@ -436,7 +436,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
//断开连接方法
@@ -454,7 +454,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
//获取状态方法
@@ -472,7 +472,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
//读卡方法
@@ -541,7 +541,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
function readIDCardSN() {
@@ -558,7 +558,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
function getSAMID() {
@@ -575,7 +575,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
function readM1Card() {
@@ -592,7 +592,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
function writeM1Card() {
@@ -609,7 +609,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
function handleAPDUCMD() {
@@ -626,7 +626,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
/*
@@ -695,7 +695,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) { }
    } catch (e) {}
}
export default CertCtl;