You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.8 KiB
Plaintext
88 lines
2.8 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
|
<link rel="stylesheet" href="${path}/static/naranja/css/naranja.min.css"/>
|
|
<script type="text/javascript" src="${path}/static/naranja/js/naranja.js"></script>
|
|
<script type="text/javascript" src="${path}/static/naranja/sockjs.js"></script>
|
|
<script>
|
|
var powerUrlHead = path;
|
|
/*********通知操作**********************************************/
|
|
$(function(){
|
|
getNoticeCount();
|
|
})
|
|
//赋值未通知数量
|
|
function getNoticeCount(){
|
|
//赋值未通知数量
|
|
$.ajax({
|
|
type:'get',
|
|
url:powerUrlHead+'/notice/getUnReadCount',
|
|
dataType:'json',
|
|
success:function(data){
|
|
if(data.code == 100){
|
|
$("#noticeCount").text(data.extend.unReadCount);
|
|
}
|
|
}
|
|
})
|
|
}
|
|
//每隔1分钟轮询一次未通知数量
|
|
setInterval(function () {
|
|
getNoticeCount();
|
|
}, 60*1000);
|
|
//每隔1秒钟轮询一次session所剩时间
|
|
var r = setInterval(function () {
|
|
$.get(path+'/getSessionRemainingTime',function(data){
|
|
if(data != null){
|
|
data /= 1000
|
|
if(data < 11 && data > 10){
|
|
toastr.warning("还有10秒将登录超时,将退出登录!")
|
|
}else if(data < 6 && data > 5){
|
|
toastr.warning("还有5秒将登录超时,将退出登录!")
|
|
}else if(data < 0){
|
|
window.location.href = path + '/login'
|
|
}
|
|
}
|
|
},'json');
|
|
}, 1000);
|
|
//跳转到通知
|
|
function noticeManage1(noticeId){
|
|
var url = powerUrlHead+"/gatewayPage?noticeId="+noticeId;
|
|
window.location.href = url;
|
|
}
|
|
/*********webSocket**********************************************/
|
|
var userId = $("#userId").val();
|
|
var strSplit = $("#strSplit").val();
|
|
var webSocketUrl = $("#webSocketUrl").val();
|
|
var ws = new WebSocket("ws://"+webSocketUrl);
|
|
ws.onopen = function(){
|
|
ws.send("power_"+userId);
|
|
console.log("连接...")
|
|
}
|
|
|
|
//处理服务器发送来的数据
|
|
ws.onmessage = function(e){
|
|
var msg = e.data.split(strSplit);
|
|
narn('warn',msg[0],msg[1],msg[2]);
|
|
}
|
|
|
|
ws.onclose = function(){
|
|
console.log("连接关闭");
|
|
}
|
|
|
|
ws.onerror = function(){
|
|
console.log('连接失败');
|
|
}
|
|
|
|
function narn (type,title,text,noticeId) {
|
|
debugger
|
|
naranja()[type]({
|
|
title: title,
|
|
text: text,
|
|
timeout: 1000*60,
|
|
buttons: [{
|
|
text: '查看详情',
|
|
click: function (e) {
|
|
noticeManage1(noticeId);
|
|
}
|
|
}]
|
|
})
|
|
}
|
|
</script>
|