|
|
|
@ -4,8 +4,9 @@
|
|
|
|
|
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
|
|
|
|
|
<![endif]-->
|
|
|
|
|
<!-- 自动适配移动端与pc端 -->
|
|
|
|
|
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.3.3/scripts/kit.js"
|
|
|
|
|
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.4.0/scripts/kit.js"
|
|
|
|
|
charset="utf-8"></script>
|
|
|
|
|
<script src="https://g.alicdn.com/aliww/h5.openim.sdk/1.0.6/scripts/wsdk.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
window.uid = 'imuser123';
|
|
|
|
|
window.touid = 'imuser1234';
|
|
|
|
@ -20,15 +21,17 @@
|
|
|
|
|
touid: window.touid,
|
|
|
|
|
logo:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805672266&di=2b24a1579255192f7456d64872c65b39&imgtype=0&src=http%3A%2F%2Fimage.coolapk.com%2Ffeed%2F2016%2F1113%2F661664_1479013815_7771.jpg.m.jpg',
|
|
|
|
|
toAvatar:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805672266&di=2b24a1579255192f7456d64872c65b39&imgtype=0&src=http%3A%2F%2Fimage.coolapk.com%2Ffeed%2F2016%2F1113%2F661664_1479013815_7771.jpg.m.jpg',
|
|
|
|
|
Avatar:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805672266&di=2b24a1579255192f7456d64872c65b39&imgtype=0&src=http%3A%2F%2Fimage.coolapk.com%2Ffeed%2F2016%2F1113%2F661664_1479013815_7771.jpg.m.jpg',
|
|
|
|
|
|
|
|
|
|
pluginUrl: 'http://192.168.0.43:9001/service_contact_list.html?uid='
|
|
|
|
|
+ window.uid,
|
|
|
|
|
onLoginSuccess: function (data) {
|
|
|
|
|
WKIT.Conn.sdk.Event.on('MSG_RECEIVED', function (data) {
|
|
|
|
|
|
|
|
|
|
updateContractList(data.data);
|
|
|
|
|
});
|
|
|
|
|
initUnreadMsgAndContact();
|
|
|
|
|
WKIT.Conn.sdk.Base.startListenAllMsg();
|
|
|
|
|
window.sdk =document.getElementById("J_wkitPluginFrame").contentWindow;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -36,8 +39,8 @@
|
|
|
|
|
function switchTouid(touid) {
|
|
|
|
|
WKIT.switchTouid({
|
|
|
|
|
touid: touid,
|
|
|
|
|
logo:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805672266&di=2b24a1579255192f7456d64872c65b39&imgtype=0&src=http%3A%2F%2Fimage.coolapk.com%2Ffeed%2F2016%2F1113%2F661664_1479013815_7771.jpg.m.jpg',
|
|
|
|
|
// Avatar:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg',
|
|
|
|
|
logo:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg',
|
|
|
|
|
Avatar:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg',
|
|
|
|
|
toAvatar:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531805782509&di=98f7fa48980696f8eddf7eb617a834a3&imgtype=0&src=http%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F98dbd049061292bca8625caf91cff1b41ee999cd.jpg'
|
|
|
|
|
});
|
|
|
|
|
WKIT.Conn.sdk.Chat.setReadState({
|
|
|
|
@ -50,8 +53,8 @@
|
|
|
|
|
console.log('set read state fail', error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[touid] = 0;
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.loadContactList();
|
|
|
|
|
window.sdk.unreadMap[touid] = 0;
|
|
|
|
|
window.sdk.loadContactList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initUnreadMsgAndContact() {
|
|
|
|
@ -60,7 +63,7 @@
|
|
|
|
|
success: function (data) {
|
|
|
|
|
var cnts = data.data.cnts;
|
|
|
|
|
for (var i = cnts.length - 1; i >= 0; i--) {
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[WKIT.Conn.sdk.Base.getNick(cnts[i].to)] = 0;
|
|
|
|
|
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(cnts[i].to)] = 0;
|
|
|
|
|
}
|
|
|
|
|
getUnreadMsgCount();
|
|
|
|
|
},
|
|
|
|
@ -76,10 +79,10 @@
|
|
|
|
|
success: function (data) {
|
|
|
|
|
var unreads = data.data;
|
|
|
|
|
for (var i = unreads.length - 1; i >= 0; i--) {
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[ WKIT.Conn.sdk.Base.getNick(unreads[i].contact)] =
|
|
|
|
|
window.sdk.unreadMap[ WKIT.Conn.sdk.Base.getNick(unreads[i].contact)] =
|
|
|
|
|
unreads[i].msgCount;
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.loadContactList();
|
|
|
|
|
window.sdk.loadContactList();
|
|
|
|
|
},
|
|
|
|
|
error: function (error) {
|
|
|
|
|
console.log('get recent contact fail', error);
|
|
|
|
@ -90,12 +93,12 @@
|
|
|
|
|
function updateContractList(data) {
|
|
|
|
|
var msg = data.msgs[0];
|
|
|
|
|
var msg_uid = WKIT.Conn.sdk.Base.getNick(msg.from);
|
|
|
|
|
if (document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[msg_uid]) {
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[msg_uid] = document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[msg_uid] + 1;
|
|
|
|
|
if (window.sdk.unreadMap[msg_uid]) {
|
|
|
|
|
window.sdk.unreadMap[msg_uid] = window.sdk.unreadMap[msg_uid] + 1;
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[msg_uid] = 1;
|
|
|
|
|
window.sdk.unreadMap[msg_uid] = 1;
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("J_wkitPluginFrame").contentWindow.loadContactList();
|
|
|
|
|
window.sdk.loadContactList();
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</html>
|