...
|
...
|
@@ -509,6 +509,11 @@ function pageInit() { |
|
|
|
|
|
console.log('客户收到消息!', rec);
|
|
|
|
|
|
// 删除上个定时器
|
|
|
if (titleInterval) {
|
|
|
clearInterval(titleInterval);
|
|
|
}
|
|
|
|
|
|
if (isHidden) {
|
|
|
titleInterval = setInterval(function() {
|
|
|
document.title = '您有新消息!';
|
...
|
...
|
@@ -580,16 +585,27 @@ function pageInit() { |
|
|
* 连接socket
|
|
|
*/
|
|
|
function connectSocket() {
|
|
|
socketChat.init(Object.assign(originConf, {
|
|
|
|
|
|
// 获取上次会话id
|
|
|
var lastSessionId = window.cookie('sessionId');
|
|
|
|
|
|
originConf.conversationMessage.sessionId = lastSessionId || 0;
|
|
|
socketChat.init(Object.assign(originConf, {
|
|
|
onMessage: function onMessage(e) {
|
|
|
var jsonString = e.data;
|
|
|
var received = JSON.parse(jsonString);
|
|
|
|
|
|
socketConfCM.conversationId = received.newConversationId !== 0 ? received.newConversationId : received.conversationId;
|
|
|
|
|
|
// 保存会话id
|
|
|
window.setCookie('conversationId', socketConfCM.conversationId, {expires: 60 * 15});
|
|
|
window.setCookie('sessionId', received.sessionId, {expires: 60 * 15});
|
|
|
getMessage(received);
|
|
|
},
|
|
|
|
|
|
onOpen: function onClose(e) {
|
|
|
},
|
|
|
|
|
|
onClose: function onClose() {
|
|
|
$('.connect-fail').fadeIn();
|
|
|
},
|
...
|
...
|
@@ -730,6 +746,7 @@ function pageInit() { |
|
|
|
|
|
// tab页title重置
|
|
|
tab.tabVisible(function() {
|
|
|
console.log('reset tab');
|
|
|
document.title = docTitle;
|
|
|
clearInterval(titleInterval);
|
|
|
});
|
...
|
...
|
|