function getOneYsy(devs, cb, who) { let _opts = { url: ys7Url + "/api/lapp/device/info", type: "POST" }; let _data = { deviceSerial: devs, accessToken: getCookie("ylToken") }; let _hea = { "Content-Type": "application/x-www-form-urlencoded" }; postAxios(_opts, _data, _hea).then((res) => { let _acb = res.data; if (who != undefined) { cb(_acb); } else { let ysysData = { icon: "../imgs/ship.png", position: [113.207453, 21.976270], prod: _acb.deviceName, sn: _acb.deviceSerial, sog: 0, time: getTime(new Date())[0] + getTime(new Date())[1], online: _acb.status, devVer: 4, }; cb(ysysData); } }) } function getCctvYsy(devs, cb) { let _opts = { url: ys7Url + "/api/lapp/device/info", type: "POST" }; let _data = { accessToken: getCookie("ylToken"), pageStart: 0, pageSize: 50 }; let _hea = { "Content-Type": "application/x-www-form-urlencoded" }; postAxios(_opts, _data, _hea).then((res) => { let _acb = result.data, _arr = []; devs.forEach(item => { let sd = _acb.filter(subitem => subitem.deviceSerial == item.sn)[0] _arr.push({ prod: sd.deviceName, sn: sd.deviceSerial, time: getTime(new Date())[0] + getTime(new Date())[1], online: sd.status, mmsi: item.mmsi, devVer: 4 }) }) cb(_arr); }); } function getCctvAis(_ais, cb) { $.ajax({ url: "https://www.enstation.com:8083/ruico-ais/open/ais/getAisInfo", type: "POST", traditional: true, async: false, data: { key: "7b581bc63821b05b2870456fbb6f47df", mmsi: _ais }, error: function(XMLHttpRequest) {}, success: function(data) { let _data = "" if (data.data != undefined) { _data = data.data; localStorage.setItem("Histroy-List", _data); } else { if (localStorage.getItem("Histroy-List") != undefined && localStorage.getItem( "Histroy-List") != null) { _data = localStorage.getItem("Histroy-List"); } else { _data = ""; } } if (_data != "") { let _obj = deCoded(_data); cb(_obj); } } }) } function getHisMap(query, cb) { $.ajax({ url: "https://www.enstation.com:8083/ruico-ais/open/getAisTrack", type: "POST", traditional: true, async: false, data: query, error: function(XMLHttpRequest) {}, success: function(data) { if (data.result) { let _obj = deCoded(data.data); cb(_obj); } else { let mmsi = query.mmsi; let _obj = {}; _obj[mmsi] = [] cb(_obj); } } }) } function deCoded(key) { let decodedData = atob(key); let charData = decodedData.split('').map(x => x.charCodeAt(0)); let binData = new Uint8Array(charData); let data = pako.inflate(binData); let _dhj = Utf8ArrayToStr(data); return _dhj } function Utf8ArrayToStr(array) { var out, i, len, c; var char2, char3; out = ""; len = array.length; i = 0; while (i < len) { c = array[i++]; switch (c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: out += String.fromCharCode(c); break; case 12: case 13: char2 = array[i++]; out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); break; case 14: char2 = array[i++]; char3 = array[i++]; out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)); break; } } return JSON.parse(out) }; function duToGpsDM(duStr, duDir) { // console.log(duStr, duDir); duStr = (duStr + '').toLowerCase(); duStr = duStr.replace(/\s+/g, ""); duDir = duDir.toUpperCase(); var strLength = duStr.length; var tempString = ""; var tempStrArray = new Array(); var tempCount = 0; var tempPointFlag = 0; var gpsDM; for (var i = 0; i <= strLength; i++) { if (duStr[i] >= '0' && duStr[i] <= '9') { tempString += duStr[i]; continue; } else if (duStr[i] == '.') { tempStrArray[tempCount] = tempString; tempString = ""; tempCount++; tempStrArray[tempCount] = '.'; tempPointFlag = 1; tempCount++; } else if (tempString.length > 0) { tempStrArray[tempCount] = tempString; tempString = ""; tempCount++; } } if (tempPointFlag == 1) { var num1 = tempStrArray[0]; var num2 = parseFloat('0' + tempStrArray[1] + tempStrArray[2], 10) * 60; gpsDM = num1 + "°" + num2.toFixed(4) + " " + duDir; //gpsDM=+num1+"°"+num2+"′"+" "+duDir; // console.log(gpsDM); } return gpsDM; } function getFormattedAddress(_obj, _calbcl) { $.ajax({ url: "https://restapi.amap.com/v3/geocode/regeo", type: "POST", dataType: "json", data: { output: "json", location: _obj.toString(), key: "b7123477fa51cba7b47769d2e7b4b9d7", radius: 1000, extensions: "base" }, error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(dart) { if (dart.status == 1 && dart.regeocode.formatted_address.length) { _calbcl(dart.regeocode.formatted_address); } else { _calbcl("获取位置失败"); } } }); }