+
liuyg
2021-12-01 b19cdfd42ef26702eb00dd77e89bf9af90bc9ed4
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,41 +71,42 @@
    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);
    };
}
//连接方法
function CertCtl_connect() {
    var baseURL = "";
    getUserIP(function(ip) {
        // alert("Got IP! :" + ip);
        baseURL = ip;
    });
    console.log(baseURL, 666666);
function CertCtl_connect(fn) {
    // var baseURL = "";
    // getUserIP(function (ip) {
    //     // alert("Got IP! :" + ip);
    //     baseURL = ip;
    // });
    // console.log(baseURL, 666666);
    var result = "";
    var iParam1 = "1";
    // var iParam1 = "1";
    var urls = "http://127.0.0.1:18889/api/connect";
    //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
    CertCtl.xhr.open("POST", "http://" + baseURL + ":18889/api/connect", false);
    // CertCtl.xhr.open("POST", urls, false);
    // 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:请求已接收
@@ -114,10 +115,12 @@
    //返回值status      200: "OK"
    //               404: 未找到页面
    //当返回值readyState为4且status为200时,为查询成功
    // console.log(CertCtl.xhr);
    if (CertCtl.xhr.readyState == 4 && CertCtl.xhr.status == 200) {
        result = CertCtl.xhr.responseText;
        CertCtl.xhr.readyState = 1;
        // CertCtl.xhr.readyState = 1;
    }
    fn(CertCtl.xhr.responseText)
    return result;
}
@@ -129,7 +132,7 @@
    //发送请求
    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;
@@ -144,7 +147,7 @@
    //发送请求
    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;
@@ -179,7 +182,7 @@
    //发送请求
    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;
@@ -195,7 +198,7 @@
    //发送请求
    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;
@@ -213,7 +216,7 @@
    //发送请求
    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;
@@ -251,7 +254,7 @@
    //发送请求
    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;
@@ -292,7 +295,7 @@
    //发送请求
    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;
@@ -312,7 +315,7 @@
    //发送请求
    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;
@@ -355,7 +358,7 @@
    //发送请求
    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;
@@ -372,7 +375,7 @@
    //发送请求
    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;
@@ -433,7 +436,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
//断开连接方法
@@ -451,7 +454,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
//获取状态方法
@@ -469,7 +472,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
//读卡方法
@@ -538,7 +541,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
function readIDCardSN() {
@@ -555,7 +558,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
function getSAMID() {
@@ -572,7 +575,7 @@
            //result页面回显
            document.getElementById("result").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
function readM1Card() {
@@ -589,7 +592,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
function writeM1Card() {
@@ -606,7 +609,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
function handleAPDUCMD() {
@@ -623,7 +626,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
/*
@@ -692,7 +695,7 @@
            //result页面回显
            document.getElementById("ACardResult").value = result;
        }
    } catch (e) {}
    } catch (e) { }
}
export default CertCtl;