|
|
|
@ -11,10 +11,10 @@
|
|
|
|
|
<script src="https://g.alicdn.com/aliww/h5.openim.sdk/1.0.6/scripts/wsdk.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
window.onload = function () {
|
|
|
|
|
window.uid = getQueryString('uid');
|
|
|
|
|
window.touid = getQueryString('uid');
|
|
|
|
|
window.password = getQueryString('p');
|
|
|
|
|
window.appKey = getQueryString('key');
|
|
|
|
|
window.uid = getQueryString('uid');
|
|
|
|
|
window.touid = getQueryString('uid');
|
|
|
|
|
window.password = getQueryString('p');
|
|
|
|
|
window.appKey = getQueryString('key');
|
|
|
|
|
WKIT.init({
|
|
|
|
|
container: document.getElementById('J_demo'),
|
|
|
|
|
width: 700,
|
|
|
|
@ -62,8 +62,9 @@
|
|
|
|
|
var cnts = data.data.cnts;
|
|
|
|
|
for (var i = cnts.length - 1; i >= 0; i--) {
|
|
|
|
|
var unreadmapEle = {msgCount: 0};
|
|
|
|
|
window.sdk.unreadMap[getName(WKIT.Conn.sdk.Base.getNick(
|
|
|
|
|
cnts[i].from))] = unreadmapEle;
|
|
|
|
|
window.sdk.unreadMap[getName(
|
|
|
|
|
WKIT.Conn.sdk.Base.getNick(
|
|
|
|
|
cnts[i].from))] = unreadmapEle;
|
|
|
|
|
}
|
|
|
|
|
getUnreadMsgCount();
|
|
|
|
|
},
|
|
|
|
@ -81,17 +82,22 @@
|
|
|
|
|
var unreads = data.data;
|
|
|
|
|
var uids = "";
|
|
|
|
|
for (var i = unreads.length - 1; i >= 0; i--) {
|
|
|
|
|
window.sdk.unreadMap[getName(WKIT.Conn.sdk.Base.getNick(unreads[i].contact))].msgCount =
|
|
|
|
|
window.sdk.unreadMap[getName(
|
|
|
|
|
WKIT.Conn.sdk.Base.getNick(
|
|
|
|
|
unreads[i].contact))].msgCount =
|
|
|
|
|
unreads[i].msgCount;
|
|
|
|
|
var nick = getName(WKIT.Conn.sdk.Base.getNick(unreads[i].contact));
|
|
|
|
|
if(nick.length<=6){
|
|
|
|
|
uids += nick+",";
|
|
|
|
|
}else {
|
|
|
|
|
var nick = getName(
|
|
|
|
|
WKIT.Conn.sdk.Base.getNick(
|
|
|
|
|
unreads[i].contact));
|
|
|
|
|
if (nick.length <= 6) {
|
|
|
|
|
uids += nick + ",";
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
uids += nick.substring(0,uid.length-5) + ",";
|
|
|
|
|
uids +=
|
|
|
|
|
nick.substring(0, uid.length - 5)
|
|
|
|
|
+ ",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log("unreadMap",window.sdk.unreadMap);
|
|
|
|
|
window.sdk.loadContactList(uids);
|
|
|
|
|
},
|
|
|
|
|
error: function (error) {
|
|
|
|
@ -103,7 +109,17 @@
|
|
|
|
|
function updateContractList(data) {
|
|
|
|
|
var msg = data.msgs[0];
|
|
|
|
|
var msg_uid = getName(WKIT.Conn.sdk.Base.getNick(msg.from))
|
|
|
|
|
|
|
|
|
|
if (window.uid = msg_uid) {
|
|
|
|
|
WKIT.Conn.sdk.Chat.setReadState({
|
|
|
|
|
touid: msg_uid,
|
|
|
|
|
timestamp: Math.floor((+new Date()) / 1000),
|
|
|
|
|
success: function (data) {
|
|
|
|
|
},
|
|
|
|
|
error: function (error) {
|
|
|
|
|
console.log('set read state fail', error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (window.sdk.unreadMap[msg_uid]) {
|
|
|
|
|
window.sdk.unreadMap[msg_uid].msgCount = window.sdk.unreadMap[msg_uid].msgCount + 1;
|
|
|
|
@ -111,7 +127,7 @@
|
|
|
|
|
var unreadMapEle = {msgCount: 1}
|
|
|
|
|
window.sdk.unreadMap[msg_uid] = unreadMapEle;
|
|
|
|
|
}
|
|
|
|
|
window.sdk.loadContactList(msg_uid.substr(0,msg_uid-6));
|
|
|
|
|
window.sdk.loadContactList(msg_uid.substr(0, msg_uid - 6));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initLayout() {
|
|
|
|
@ -121,17 +137,21 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getName(uid) {
|
|
|
|
|
if(uid.substring(uid.length-5,uid.length-4)=='_'){
|
|
|
|
|
var prefix = uid.substring(0,uid.length-5);
|
|
|
|
|
var suffix =uid.substring(uid.length-5,uid.length).toUpperCase();
|
|
|
|
|
return prefix+suffix;
|
|
|
|
|
if (uid.substring(uid.length - 5, uid.length - 4) == '_') {
|
|
|
|
|
var prefix = uid.substring(0, uid.length - 5);
|
|
|
|
|
var suffix = uid.substring(uid.length - 5, uid.length).toUpperCase();
|
|
|
|
|
return prefix + suffix;
|
|
|
|
|
}
|
|
|
|
|
return uid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQueryString(name) {
|
|
|
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
|
|
|
var r = window.location.search.substr(1).match(reg);
|
|
|
|
|
if (r != null) return unescape(r[2]); return null;
|
|
|
|
|
if (r != null) {
|
|
|
|
|
return unescape(r[2]);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|