|
@@ -9,7 +9,6 @@ var currentList = getLocalStorage("currentList", []);
|
|
|
var pastList = getLocalStorage("pastList", []);
|
|
|
//血液中心出发打印
|
|
|
var printType = '';
|
|
|
-let hasErrorMessage = false
|
|
|
function openSocket(type) {
|
|
|
//判断当前浏览器是否支持WebSocket
|
|
|
try {
|
|
@@ -57,7 +56,7 @@ function openSocket(type) {
|
|
|
prescriptionPrintWebsocket.onclose = function (event) {
|
|
|
console.log(type + "连接prescriptionPrintSocket连接关闭 code:" + event.code + ",原因:" + event.reason + ",是否正常关闭:" + event.wasClean);
|
|
|
if (event.code == '1001' || event.code == '1006') {//1001:终端离开, 可能因为服务端错误 1006:没有发送关闭帧
|
|
|
- // openSocket(type);
|
|
|
+ openSocket(type);
|
|
|
console.log("自动关闭异常");
|
|
|
}
|
|
|
};
|
|
@@ -66,28 +65,14 @@ function openSocket(type) {
|
|
|
prescriptionPrintWebsocket.close();
|
|
|
}
|
|
|
} else if (res.code === -1) {
|
|
|
- if (hasErrorMessage) {
|
|
|
- return false
|
|
|
- }
|
|
|
- hasErrorMessage = true
|
|
|
errorMesageSimaple('自动打印连接socket失败,正尝试重连...');
|
|
|
- setTimeout(()=>{
|
|
|
- hasErrorMessage = false
|
|
|
- },4000)
|
|
|
- // openSocket(type);
|
|
|
+ openSocket(type);
|
|
|
console.log("返回异常");
|
|
|
}
|
|
|
},
|
|
|
error: function () {
|
|
|
- if (hasErrorMessage) {
|
|
|
- return false
|
|
|
- }
|
|
|
- hasErrorMessage = true
|
|
|
errorMesageSimaple('自动打印连接socket失败,正尝试重连...');
|
|
|
- setTimeout(()=>{
|
|
|
- hasErrorMessage = false
|
|
|
- },4000)
|
|
|
- // openSocket(type);
|
|
|
+ openSocket(type);
|
|
|
console.log("请求异常");
|
|
|
}
|
|
|
});
|
|
@@ -95,7 +80,7 @@ function openSocket(type) {
|
|
|
alert('当前浏览器不支持WebSocket,请更换浏览器');
|
|
|
}
|
|
|
} catch (e) {
|
|
|
- // openSocket(type);
|
|
|
+ openSocket(type);
|
|
|
console.log("捕捉异常");
|
|
|
console.log(e);
|
|
|
}
|