195 lines
6.2 KiB
Plaintext
195 lines
6.2 KiB
Plaintext
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||
<%@ page import="com.sipai.tools.SessionManager"%>
|
||
<%@ page import="com.sipai.entity.base.ServerObject"%>
|
||
<%
|
||
SessionManager sessionManager = new SessionManager();
|
||
%>
|
||
<%String contextPath = request.getContextPath();%>
|
||
<html>
|
||
<head>
|
||
<title><%= ServerObject.atttable.get("TOPTITLE")%></title>
|
||
<jsp:include page="inc.jsp"></jsp:include>
|
||
<LINK href="IMG/logo.ico" type="image/x-icon" rel="icon"/>
|
||
<LINK href="IMG/logo.ico" type="image/x-icon" rel="shortcut icon"/>
|
||
<script src="<%=contextPath%>/JS/reconnecting-websocket.min.js"></script>
|
||
<script type="text/javascript">
|
||
var mainMenu;
|
||
var mainTabs;
|
||
var restartDialog;
|
||
var websocket = null;
|
||
//判断当前浏览器是否支持WebSocket
|
||
if ('WebSocket' in window) {
|
||
websocket = new ReconnectingWebSocket(ext.basePath.replace("http","ws")+"/msgWebSocket/${cu.id}");
|
||
}
|
||
else {
|
||
alert('当前浏览器 Not support websocket')
|
||
}
|
||
|
||
//连接发生错误的回调方法
|
||
websocket.onerror = function () {
|
||
};
|
||
|
||
//连接成功建立的回调方法
|
||
websocket.onopen = function () {
|
||
console.info('消息滚动websocker开启');
|
||
}
|
||
|
||
//接收到消息的回调方法
|
||
websocket.onmessage = function (event) {
|
||
// var result= JSON.parse(event.data);
|
||
|
||
querynewmsg();
|
||
|
||
}
|
||
|
||
//连接关闭的回调方法
|
||
websocket.onclose = function () {
|
||
console.info('消息滚动websocker关闭_main');
|
||
if(restartDialog==null){
|
||
restartDialog =top.$.messager.alert('提示','服务器连接已断开,请重新登录!','info',function(){
|
||
top.location.href=ext.contextPath; //跳转到登陆页面
|
||
});
|
||
}
|
||
closeWebSocket();
|
||
}
|
||
|
||
//监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
|
||
window.onbeforeunload = function () {
|
||
closeWebSocket();
|
||
}
|
||
|
||
//关闭WebSocket连接
|
||
function closeWebSocket() {
|
||
websocket.close();
|
||
}
|
||
|
||
//发送消息
|
||
/* function send() {
|
||
var message = document.getElementById('text').value;
|
||
websocket.send(message);
|
||
} */
|
||
$(function() {
|
||
|
||
$('#passwordDialog').show().dialog({
|
||
modal : true,
|
||
closable : true,
|
||
iconCls : 'ext-icon-lock_edit',
|
||
buttons : [ {
|
||
text : '修改',
|
||
handler : function() {
|
||
if ($('#passwordDialog form').form('validate')) {
|
||
$.post("Login/resetPwd.do", {"loadNewPassword" : $("#pwd").val()}, function(data) {
|
||
if (data=="成功") {
|
||
$.messager.alert('提示', '密码修改成功!', 'info');
|
||
$('#passwordDialog').dialog('close');
|
||
}else{
|
||
$.messager.alert('提示', data, 'error');
|
||
}
|
||
});
|
||
}
|
||
}
|
||
} ],
|
||
onOpen : function() {
|
||
$('#passwordDialog form :input').val('');
|
||
}
|
||
}).dialog('close');
|
||
|
||
});
|
||
|
||
//菜单栏选择后添加tab页面
|
||
function addTab(id,name,location){
|
||
$.post("user/isOnline.do");//用于session过期后重新进入登录页面
|
||
|
||
var tabs = $('#mainTabs');
|
||
var opts = {
|
||
title : name,
|
||
closable : true,
|
||
content : '<iframe src="'+location+'" allowTransparency="true" style="border:0;width:100%;height:100%;" frameBorder="0" scrolling="auto"></iframe>',
|
||
border : false,
|
||
fit : true
|
||
};
|
||
if (tabs.tabs('exists', opts.title)) {
|
||
tabs.tabs('select', opts.title);
|
||
} else {
|
||
tabs.tabs('add', opts);
|
||
}
|
||
}
|
||
|
||
//消息
|
||
var post = "";
|
||
var unReadMsgNum = 0;
|
||
function querynewmsg(){
|
||
$.post("msg/getUnreadMsgs4main.do",function(data){
|
||
var total= data.total;
|
||
var rows =data.rows;
|
||
document.getElementById("msgcount").innerHTML = "("+total+")";
|
||
if(unReadMsgNum < total){
|
||
msgshow("24小时内,您有"+total+"条未读消息!");
|
||
unReadMsgNum = total;
|
||
}
|
||
var res="";
|
||
for(var i=0;i<rows.length;i++){
|
||
//console.info(rows[i]);
|
||
res+=rows[i].insdt.substring(0,19)+"——"+rows[i].susername.caption+":"+rows[i].content+" ";
|
||
}
|
||
$("#marquee_msg").html(res);
|
||
},'json');
|
||
}
|
||
function msgshow(a){
|
||
$.messager.show({
|
||
title:'消息',
|
||
msg:a,
|
||
showType:'show',
|
||
timeout:5000,
|
||
style:{
|
||
left:'',
|
||
right:1,
|
||
top:'',
|
||
bottom:31
|
||
}
|
||
});
|
||
}
|
||
querynewmsg();
|
||
//setInterval("querynewmsg();",5000);
|
||
</script>
|
||
</head>
|
||
<body id="mainLayout" class="easyui-layout">
|
||
<div data-options="region:'north',href:'jsp/north.jsp'" class="logo" style="height: 70px; overflow: hidden;"></div>
|
||
<div data-options="region:'west',href:'user/showMenuListByCu.do',split:true" title="${cu.caption}" style="width: 200px"></div>
|
||
<div data-options="region:'center',href:'jsp/center.jsp'" style="overflow: hidden;"></div>
|
||
<div data-options="region:'south',border:false" style="height: 30px; overflow: hidden;">
|
||
|
||
<table style="float:right;width: 100%" data-options="fit:true" >
|
||
|
||
<tr>
|
||
<td style="padding:0px 5px 0px 5px;fit:true;" >
|
||
<marquee id ="marquee_msg" behavior="scroll" >当前没有消息提醒</marquee>
|
||
</td>
|
||
<td style="width: auto;float:right" >
|
||
<%-- <%if (sessionManager.havePermission(session,"msg/getMsgrecv.do?scope=all")) {%> --%>
|
||
<a href="javascript:addTab('msgrecv','收消息','msg/showMsgrecv.do');" class="easyui-linkbutton" data-options="plain:true">
|
||
<b id="newmsg">消息</b><b id="msgcount"></b>
|
||
</a>
|
||
<%-- <%}%> --%>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div id="passwordDialog" title="修改密码" style="display: none;width: 380px;">
|
||
<form method="post" class="form" onsubmit="return false;">
|
||
<table class="table">
|
||
<tr>
|
||
<th>新密码</th>
|
||
<td><input id="pwd" name="loadNewPassword" type="password" class="easyui-validatebox" data-options="required:true,validType:'isBlank'" /></td>
|
||
</tr>
|
||
<tr>
|
||
<th>重复密码</th>
|
||
<td><input type="password" class="easyui-validatebox" data-options="required:true,validType:'eqPwd[\'#pwd\']'" /></td>
|
||
</tr>
|
||
</table>
|
||
</form>
|
||
</div>
|
||
</body>
|
||
</html> |