|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
|
|
|
|
|
<![endif]-->
|
|
|
|
|
<!-- 自动适配移动端与pc端 -->
|
|
|
|
|
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
|
|
|
|
|
<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>
|
|
|
|
@ -19,82 +20,93 @@
|
|
|
|
|
appkey: 24960261,
|
|
|
|
|
credential: 'xxxxxx',
|
|
|
|
|
touid: window.touid,
|
|
|
|
|
pluginUrl: 'http://192.168.0.43:9001/service_contact_list.html?uid='
|
|
|
|
|
pluginUrl: 'http://192.168.0.67:9001/service_contact_list.html?uid='
|
|
|
|
|
+ window.uid,
|
|
|
|
|
onLoginSuccess: function (data) {
|
|
|
|
|
initLayout();
|
|
|
|
|
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;
|
|
|
|
|
window.sdk = document.getElementById("J_wkitPluginFrame").contentWindow;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function switchTouid(touid) {
|
|
|
|
|
window.uid = touid;
|
|
|
|
|
WKIT.switchTouid({
|
|
|
|
|
touid: touid,
|
|
|
|
|
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'
|
|
|
|
|
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({
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
window.sdk.unreadMap[touid] = 0;
|
|
|
|
|
window.sdk.loadContactList();
|
|
|
|
|
window.sdk.unreadMap[touid].msgCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initUnreadMsgAndContact() {
|
|
|
|
|
WKIT.Conn.sdk.Base.getRecentContact({
|
|
|
|
|
count: 40,
|
|
|
|
|
success: function (data) {
|
|
|
|
|
var cnts = data.data.cnts;
|
|
|
|
|
for (var i = cnts.length - 1; i >= 0; i--) {
|
|
|
|
|
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(cnts[i].to)] = 0;
|
|
|
|
|
}
|
|
|
|
|
getUnreadMsgCount();
|
|
|
|
|
},
|
|
|
|
|
error: function (error) {
|
|
|
|
|
console.log('get contact msg count fail', error);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getUnreadMsgCount() {
|
|
|
|
|
WKIT.Conn.sdk.Base.getUnreadMsgCount({
|
|
|
|
|
count: 40,
|
|
|
|
|
success: function (data) {
|
|
|
|
|
var unreads = data.data;
|
|
|
|
|
for (var i = unreads.length - 1; i >= 0; i--) {
|
|
|
|
|
window.sdk.unreadMap[ WKIT.Conn.sdk.Base.getNick(unreads[i].contact)] =
|
|
|
|
|
unreads[i].msgCount;
|
|
|
|
|
var cnts = data.data.cnts;
|
|
|
|
|
for (var i = cnts.length - 1; i >= 0; i--) {
|
|
|
|
|
var unreadmapEle = {msgCount:0};
|
|
|
|
|
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(cnts[i].to)]=unreadmapEle;
|
|
|
|
|
}
|
|
|
|
|
window.sdk.loadContactList();
|
|
|
|
|
getUnreadMsgCount();
|
|
|
|
|
},
|
|
|
|
|
error: function (error) {
|
|
|
|
|
console.log('get recent contact fail', error);
|
|
|
|
|
console.log('get contact msg count fail',
|
|
|
|
|
error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getUnreadMsgCount() {
|
|
|
|
|
WKIT.Conn.sdk.Base.getUnreadMsgCount({
|
|
|
|
|
count: 40,
|
|
|
|
|
success: function (data) {
|
|
|
|
|
var unreads = data.data;
|
|
|
|
|
var uids = "";
|
|
|
|
|
for (var i = unreads.length - 1; i >= 0; i--) {
|
|
|
|
|
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(unreads[i].contact)].msgCount =unreads[i].msgCount;
|
|
|
|
|
uids += WKIT.Conn.sdk.Base.getNick(unreads[i].contact) + ",";
|
|
|
|
|
}
|
|
|
|
|
window.sdk.loadContactList(uids);
|
|
|
|
|
},
|
|
|
|
|
error: function (error) {
|
|
|
|
|
console.log('get recent contact fail', error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateContractList(data) {
|
|
|
|
|
var msg = data.msgs[0];
|
|
|
|
|
var msg_uid = WKIT.Conn.sdk.Base.getNick(msg.from);
|
|
|
|
|
if (window.sdk.unreadMap[msg_uid]) {
|
|
|
|
|
window.sdk.unreadMap[msg_uid] = window.sdk.unreadMap[msg_uid] + 1;
|
|
|
|
|
window.sdk.unreadMap[msg_uid].msgCount = window.sdk.unreadMap[msg_uid].msgCount + 1;
|
|
|
|
|
} else {
|
|
|
|
|
window.sdk.unreadMap[msg_uid] = 1;
|
|
|
|
|
var unreadMapEle = {msgCount:1}
|
|
|
|
|
window.sdk.unreadMap[msg_uid] = unreadMapEle;
|
|
|
|
|
}
|
|
|
|
|
window.sdk.loadContactList();
|
|
|
|
|
window.sdk.loadContactList(msg_uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initLayout() {
|
|
|
|
|
$("#J_wkitUserInfo").hide();
|
|
|
|
|
$("#J_wkitPluginFrameWrap").css("height", "100%;");
|
|
|
|
|
$("#J_wkitPluginFrameWrap").css("margin", "0 0 0 0");
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
</html>
|