添加消息提醒
This commit is contained in:
parent
70e82ee93a
commit
4895dfe4d2
@ -9,6 +9,7 @@ layui.use(['layer', 'form', 'jquery'], function () {
|
|||||||
var socket = io.connect('http://'+document.domain+':9010');
|
var socket = io.connect('http://'+document.domain+':9010');
|
||||||
|
|
||||||
var uuids = [];
|
var uuids = [];
|
||||||
|
var online_num = 0;
|
||||||
|
|
||||||
//页面初始化函数
|
//页面初始化函数
|
||||||
function init() {
|
function init() {
|
||||||
@ -95,6 +96,14 @@ layui.use(['layer', 'form', 'jquery'], function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_online_status() {
|
||||||
|
var num = uuids.length;
|
||||||
|
if(online_num > num){
|
||||||
|
num = online_num;
|
||||||
|
}
|
||||||
|
$(".friend-head-right").html( online_num + ' / ' + num + ' 人' );
|
||||||
|
}
|
||||||
|
|
||||||
function getUsers() {
|
function getUsers() {
|
||||||
$.get('/users',function (data) {
|
$.get('/users',function (data) {
|
||||||
if(data.code == 200){
|
if(data.code == 200){
|
||||||
@ -117,6 +126,7 @@ layui.use(['layer', 'form', 'jquery'], function () {
|
|||||||
$(".user-section").hide();
|
$(".user-section").hide();
|
||||||
msg_sender_status(true);
|
msg_sender_status(true);
|
||||||
$("#section-"+currentUUID).show();
|
$("#section-"+currentUUID).show();
|
||||||
|
update_online_status();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -161,7 +171,7 @@ layui.use(['layer', 'form', 'jquery'], function () {
|
|||||||
if(msg.type == 'offline'){
|
if(msg.type == 'offline'){
|
||||||
//arrayRemove(uuids,msg.uid);
|
//arrayRemove(uuids,msg.uid);
|
||||||
$(".chat-user #"+msg.uid+" .user-avatar img").attr("src","/images/server/mine_fill.png");
|
$(".chat-user #"+msg.uid+" .user-avatar img").attr("src","/images/server/mine_fill.png");
|
||||||
//$("#section-" + msg.uid).remove();
|
$("#section-" + msg.uid).hide();
|
||||||
//$(".chat-user").find("#"+msg.uid).remove();
|
//$(".chat-user").find("#"+msg.uid).remove();
|
||||||
msg_sender_status(false);
|
msg_sender_status(false);
|
||||||
}else if(msg.type == 'online'){
|
}else if(msg.type == 'online'){
|
||||||
@ -189,12 +199,13 @@ layui.use(['layer', 'form', 'jquery'], function () {
|
|||||||
|
|
||||||
$(".chat-user #"+msg.uid+" .user-avatar img").attr("src","/images/server/mine_fill_blue.png");
|
$(".chat-user #"+msg.uid+" .user-avatar img").attr("src","/images/server/mine_fill_blue.png");
|
||||||
}
|
}
|
||||||
|
update_online_status();
|
||||||
});
|
});
|
||||||
|
|
||||||
//更新用户在线数
|
//更新用户在线数
|
||||||
socket.on('update_online_count', function(msg){
|
socket.on('update_online_count', function(msg){
|
||||||
var count = (msg.online_count - 1) >= 0 ? (msg.online_count - 1) : 0;
|
online_num = (msg.online_count - 1) >= 0 ? (msg.online_count - 1) : 0;
|
||||||
$(".friend-head-right").html( count + '人' );
|
update_online_status();
|
||||||
});
|
});
|
||||||
|
|
||||||
//切换用户
|
//切换用户
|
||||||
@ -209,7 +220,6 @@ layui.use(['layer', 'form', 'jquery'], function () {
|
|||||||
$(".chat-user #"+uid+" .msg-tips").hide();
|
$(".chat-user #"+uid+" .msg-tips").hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
getUsers();
|
getUsers();
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user