|
|
@ -21,10 +21,13 @@
|
|
|
|
timeout: 4000,
|
|
|
|
timeout: 4000,
|
|
|
|
success: function (data) {
|
|
|
|
success: function (data) {
|
|
|
|
initUnreadMsgAndContact();
|
|
|
|
initUnreadMsgAndContact();
|
|
|
|
console.log('login success', data);
|
|
|
|
sdk.Event.on('MSG_RECEIVED', function (data) {
|
|
|
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
sdk.Base.startListenAllMsg();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
error: function (error) {
|
|
|
|
error: function (error) {
|
|
|
|
console.log('get login msg count fail', error);
|
|
|
|
login();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -37,7 +40,8 @@
|
|
|
|
$("#contact").html(str);
|
|
|
|
$("#contact").html(str);
|
|
|
|
var contact_list = '';
|
|
|
|
var contact_list = '';
|
|
|
|
for (var key in unreadMap) {
|
|
|
|
for (var key in unreadMap) {
|
|
|
|
contact_list += "<li>" + key + ":" + unreadMap[key] + "</li>";
|
|
|
|
contact_list +=
|
|
|
|
|
|
|
|
"<li onclick=switchToUser('" + key + "')>" + key + ":" + unreadMap[key] + "</li>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("#contact_list").html(contact_list);
|
|
|
|
$("#contact_list").html(contact_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -46,8 +50,6 @@
|
|
|
|
sdk.Base.getRecentContact({
|
|
|
|
sdk.Base.getRecentContact({
|
|
|
|
count: 40,
|
|
|
|
count: 40,
|
|
|
|
success: function (data) {
|
|
|
|
success: function (data) {
|
|
|
|
console.log('get contact msg count success', data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cnts = data.data.cnts;
|
|
|
|
var cnts = data.data.cnts;
|
|
|
|
for (var i = cnts.length - 1; i >= 0; i--) {
|
|
|
|
for (var i = cnts.length - 1; i >= 0; i--) {
|
|
|
|
unreadMap[sdk.Base.getNick(cnts[i].to)] = 0;
|
|
|
|
unreadMap[sdk.Base.getNick(cnts[i].to)] = 0;
|
|
|
@ -64,7 +66,6 @@
|
|
|
|
sdk.Base.getUnreadMsgCount({
|
|
|
|
sdk.Base.getUnreadMsgCount({
|
|
|
|
count: 40,
|
|
|
|
count: 40,
|
|
|
|
success: function (data) {
|
|
|
|
success: function (data) {
|
|
|
|
console.log('get unread msg count success', data);
|
|
|
|
|
|
|
|
var unreads = data.data;
|
|
|
|
var unreads = data.data;
|
|
|
|
for (var i = unreads.length - 1; i >= 0; i--) {
|
|
|
|
for (var i = unreads.length - 1; i >= 0; i--) {
|
|
|
|
unreadMap[sdk.Base.getNick(unreads[i].contact)] =
|
|
|
|
unreadMap[sdk.Base.getNick(unreads[i].contact)] =
|
|
|
@ -83,7 +84,6 @@
|
|
|
|
touid: touid,
|
|
|
|
touid: touid,
|
|
|
|
timestamp: Math.floor((+new Date()) / 1000),
|
|
|
|
timestamp: Math.floor((+new Date()) / 1000),
|
|
|
|
success: function (data) {
|
|
|
|
success: function (data) {
|
|
|
|
console.log('set read state success', data);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
error: function (error) {
|
|
|
|
error: function (error) {
|
|
|
|
console.log('set read state fail', error);
|
|
|
|
console.log('set read state fail', error);
|
|
|
@ -116,16 +116,33 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return args;
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateContractList(data) {
|
|
|
|
function updateContractList(data) {
|
|
|
|
var msg =data.msgs[0];
|
|
|
|
var msg = data.msgs[0];
|
|
|
|
var msg_uid = sdk.Base.getNick(msg.from);
|
|
|
|
var msg_uid = sdk.Base.getNick(msg.from);
|
|
|
|
if(unreadMap[msg_uid]){
|
|
|
|
if (unreadMap[msg_uid]) {
|
|
|
|
unreadMap[msg_uid] = unreadMap[msg_uid]+1;
|
|
|
|
unreadMap[msg_uid] = unreadMap[msg_uid] + 1;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
unreadMap[msg_uid] = 1;
|
|
|
|
unreadMap[msg_uid] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loadContactList();
|
|
|
|
loadContactList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function switchToUser(touid) {
|
|
|
|
|
|
|
|
parent.switchTouid(touid);
|
|
|
|
|
|
|
|
sdk.Chat.setReadState({
|
|
|
|
|
|
|
|
touid: touid,
|
|
|
|
|
|
|
|
timestamp: Math.floor((+new Date()) / 1000),
|
|
|
|
|
|
|
|
success: function(data){
|
|
|
|
|
|
|
|
console.log('set read state success', data);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
error: function(error){
|
|
|
|
|
|
|
|
console.log('set read state fail', error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
unreadMap[touid]=0;
|
|
|
|
|
|
|
|
loadContactList();
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
window.onload = function () {
|
|
|
|
window.onload = function () {
|
|
|
|