SocialIMInclude.jsp
9.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.hrm.*" %>
<%@ page import="weaver.systeminfo.*" %>
<%@ page import="org.apache.commons.logging.Log"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%@page import="weaver.social.service.SocialIMService" %>
<%@page import="weaver.social.im.SocialImLogin" %>
<%
Log logger= LogFactory.getLog(this.getClass());
User user = HrmUserVarify.getUser(request, response);
String userid = "" + user.getUID();
SocialIMService.rootPath = application.getRealPath("/");
// 是否使用emessage4
boolean isE4 = SocialIMService.checkE4Version();
// 是否启用了emessage web版本
boolean isUseWeb = SocialIMService.isUseWebEmessage();
// 是否允许使用emessage
boolean isAccessLogin = SocialImLogin.checkForbitLogin(userid);
String websessionkey = java.util.UUID.randomUUID().toString().trim();
// 是否被网段策略禁止登录
boolean permitLoginByNetworkSeg = SocialImLogin.checkIpSegByForbidLogin(request, user.getLoginid());
if (!isE4 || !isUseWeb) {
logger.info("emessage日志-web版被禁用");
return;
}
logger.info("emessage日志-可以使用web版");
if (!isAccessLogin) {
logger.info("emessage日志-禁止登录");
return;
}
logger.info("emessage日志-检测网段策略");
if (!permitLoginByNetworkSeg){
logger.info("网段策略被禁止");
return; // 被网段策略禁止使用web版emessage
}
int checkLicense = SocialImLogin.checkLience();
logger.info("emessage日志-检测license");
if (checkLicense == 0) {
logger.info("license有错误");
return; // 没启用不显示
} else if (checkLicense == 1) { // 授权正常,在人数正常,且pc不在线--》显示
%>
<style>
.IMbg {
position: fixed;
opacity: 0.4;
width: 100%;
height: 100%;
background-color: rgb(51, 51, 51);
z-index: 1001
}
#immsgdiv {
height: 40px;
background: url('/social/images/im_msg.png') #4ba9df no-repeat 15px center;
padding-left: 40px;
padding-right: 10px;
position: fixed;
right: 0px;
bottom: 45px;
z-index: 1000;
color: #fff;
line-height: 40px;
cursor: pointer;
}
</style>
<script>
/*
* 判断浏览器版本
* */
function IEVersion() {
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
// var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
if (isIE) {
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]);
if (fIEVersion == 7) {
return 7;
} else if (fIEVersion == 8) {
return 8;
} else if (fIEVersion == 9) {
return 9;
} else if (fIEVersion == 10) {
return 10;
} else {
return 6;//IE版本<=7
}
} else if (isIE11) {
return 11; //IE11
} else {
return -1;//不是ie浏览器
}
}
var versionNO = IEVersion();
//禁止IE9以下浏览器访问,并提示安装IE8
if (versionNO >= 10 || versionNO < 0) {
//初始化中间区域高度
jQuery.ajax({
url: "/social/im/ServerStatus.jsp?p=CheckpcOnline&websessionkey=<%=websessionkey%>",
type: "post",
dataType: "json",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function (isonline) {
if (typeof isonline == 'string') {
isonline = parseInt($.trim(isonline));
} else {
isonline = !!isonline;
}
if (!isonline) {
$("#socialIMFrm").load(function () {
initIMBox();
});
$("#socialIMFrm").attr("src", "/social/im/SocialIMMain.jsp?from=main&websessionkey=<%=websessionkey%>&sessionkey=<%=websessionkey%>");
//设置web登录状态
$.get('/social/im/ServerStatus.jsp?p=webLogin&websessionkey=<%=websessionkey%>');
} else {
$("#IMbg").remove();
$("#immsgdiv").remove();
$("#addressdiv").remove();
}
}
});
}
var IMCarousel = null, ChatUtil = null;
function initIMBox() {
// 刷新或关闭页面时,退出IM
window.onbeforeunload = function () {
$.get('/social/im/ServerStatus.jsp?p=logout&websessionkey=<%=websessionkey%>');
};
if (!IMCarousel)
IMCarousel = $('#socialIMFrm')[0].contentWindow.IMCarousel;
if (!ChatUtil)
ChatUtil = $('#socialIMFrm')[0].contentWindow.ChatUtil;
//展示浮动框
$("#immsgdiv").show();
}
/*
* 点击浮动框时间 flag: 1 显示 0 隐藏
* */
function showIMdiv(flag) {
var imRightdiv = $("#socialIMFrm").contents().find(".imRightdiv");
var imLeftdiv = $("#socialIMFrm").contents().find(".imLeftdiv");
var imCenterdiv = $("#socialIMFrm").contents().find(".imCenterdiv");
var imSlideDiv = $("#socialIMFrm").contents().find(".imSlideDiv");
var recenttab = $("#socialIMFrm").contents().find(".imToptab .tabitem:first");
var _thiswin = $("#socialIMFrm")[0].contentWindow;
var leftMenuScrollbar = $("#ascrail" + ($("#leftMenu").attr("tabindex") - 5000 + 2000)); //左侧菜单滚动条,会产生遮盖
var recentListdiv = $("#socialIMFrm").contents().find("#recentListdiv");
if (flag == 1) {
//使socialIMMain.jsp为聚焦状态,消息提醒bug 1203 by wyw
if (_thiswin.IMUtil)
_thiswin.IMUtil.cache.isWindowFocus = 1;
$("#IMbg").show();
$("#addressdiv").show();
$("#immsgdiv").hide();
leftMenuScrollbar.hide();//隐藏左侧菜单滚动条
imRightdiv.animate({
'width': '281px',
'height': '600px'
}, 400, function () {
if (imCenterdiv.find(".chatWin").length > 0) {
imCenterdiv.show();
}
if (imLeftdiv.find(".chatIMTabItem").length > 0) {
imLeftdiv.show();
//以下代码会引起bug,事实上showIMChatpanel中的click方法是异步的,
//这里的代码在尚未进入handler前被调用,这样会导致点击通知跳转到窗口时左边的tab页会被还原为上次隐藏前的状态 1127 by wyw
var chatIMTabActiveItem = $("#socialIMFrm").contents().find(".chatIMTabActiveItem");
if (chatIMTabActiveItem.length > 0) {
chatIMTabActiveItem.click();
}
}
var unreadMsgCount = Number($("#unreadMsgCount").html());
if (unreadMsgCount > 0) {
recenttab.click();
}
if (recentListdiv.perfectScrollbar) {
recentListdiv.perfectScrollbar("update");
}
})
} else {
if (_thiswin.IMUtil)
_thiswin.IMUtil.cache.isWindowFocus = 0;
imLeftdiv.hide();
imCenterdiv.hide();
imSlideDiv.css({
"display": "none",
"width": "0px"
});
$("#IMbg").hide();
imRightdiv.animate({
'width': '0px',
'height': '0px'
}, 400, function () {
$("#addressdiv").hide();
$("#immsgdiv").show();
leftMenuScrollbar.show();//显示左侧菜单滚动条
})
}
}
</script>
<div id="IMbg" class="IMbg" style="display:none;" onclick="showIMdiv(0)"></div>
<div id="addressdiv" style="display:none;position:fixed;width:963px;height:600px;z-index:1002;right:0px;bottom:0px">
<iframe name="socialIMFrm" id="socialIMFrm" scrolling="no" border="0"
style="width:963px;height:600px;border:0px;"></iframe>
</div>
<div id="immsgdiv" style="display:none;" onclick="showIMdiv(1)">
<span id="unreadMsgSpan" style="display:none;">
<%=SystemEnv.getHtmlLabelName(126880, user.getLanguage())%>(<span
id="unreadMsgCount">0</span>)
</span><!-- 您有新的消息 -->
</div>
<%
} else { //授权不正常或超过最大人数--》给出灰色并提示
%>
<!-- <div id="immsgdiv" style="background-color: #ccc;" onclick="javascript:top.Dialog.alert('<%=SocialImLogin.getCheckLienceMsg(checkLicense, 7) %>');"></div>-->
<%
}
%>