From 2e5389660d216dabf6ebee15e7a3fa6eab73d01d Mon Sep 17 00:00:00 2001 From: fs-danaus <danaus314@qq.com> Date: 星期一, 26 六月 2023 10:13:32 +0800 Subject: [PATCH] 会话失效时websocket发送通知 --- WebRoot/js/index/WebSocketMessage.js | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) diff --git a/WebRoot/js/index/WebSocketMessage.js b/WebRoot/js/index/WebSocketMessage.js index 57a4ed9..4c99a7e 100644 --- a/WebRoot/js/index/WebSocketMessage.js +++ b/WebRoot/js/index/WebSocketMessage.js @@ -1,6 +1,7 @@ var wsOnTimers=null; var layerMaintenanceIndex=null; -function initWebsocket(hostUrl,userCode,dbId,sessionId,userType) { +var reloginIndex=null; +function initWebsocket(hostUrl,userCode,dbId,sessionId,userType,isColseLayer) { // 鍒濆鍖杦eosocket var userFromType=1; if(userType!=undefined) userFromType=userType; @@ -8,6 +9,7 @@ var localUserCode = userCode ; var localDbId = dbId; var localSessionId = sessionId ; + var colseLayer=isColseLayer; if(localUserCode==null||localUserCode==""||localUserCode=="null") localUserCode="temp_userCode_"+Math.random(); if(localDbId==null||localDbId==""||localDbId=="null") localDbId=Math.floor(Math.random() * (10000 - 2000)) + 2000; if(localUserCode==null||localUserCode==""||localUserCode=="null") localUserCode="temp_session_"+Math.random(); @@ -22,6 +24,10 @@ //console.log("onOpen-wsOnTimers:"+wsOnTimers); clearInterval(wsOnTimers); wsOnTimers=null; + } + if(colseLayer==true){ + var index = parent.layer.getFrameIndex(window.name); //鍏堝緱鍒板綋鍓峣frame灞傜殑绱㈠紩 + parent.layer.close(index); //鍐嶆墽琛屽叧闂� } } @@ -72,6 +78,23 @@ } }); + }else if(json.info.msgType==6017){ + if(reloginIndex==null) { + reloginIndex = layui.layer.open({ + type: 2, + area: ['400px', '200px'], + closeBtn: 0, + isOutAnim: false, + title: [json.info.msg, 'font-size:18px;text-align:center;padding:0px'], + resize: false, + fixed: false, + content: '/sessionFail.jsp?userCode=' + userCode, + move: false, + success: function (layero, index) { + + } + }); + } }else if(json.info.msgType==6002){ //鍙充笅瑙掑脊绐� //console.log('鎺ユ敹娑堟伅', json); @@ -99,7 +122,7 @@ layerMaintenanceIndex=null; } } - // console.log('鎺ユ敹娑堟伅', json); + //console.log('鎺ユ敹娑堟伅', json); } } var popflag=false; -- Gitblit v1.8.0