diff --git a/src/main/ui/service_client.html b/src/main/ui/service_client.html index a29071d07..31accb325 100644 --- a/src/main/ui/service_client.html +++ b/src/main/ui/service_client.html @@ -1,5 +1,6 @@ @@ -17,14 +18,16 @@ appkey: 24960261, credential: 'xxxxxx', touid: window.touid, - logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png', + 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', 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) { - document.getElementById("J_wkitPluginFrame").contentWindow - .updateContractList(data.data); + + updateContractList(data.data); }); + initUnreadMsgAndContact(); WKIT.Conn.sdk.Base.startListenAllMsg(); } }); @@ -33,7 +36,66 @@ 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', + 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); + } + }); + document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[touid] = 0; + document.getElementById("J_wkitPluginFrame").contentWindow.loadContactList(); + } + + 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--) { + document.getElementById("J_wkitPluginFrame").contentWindow.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--) { + document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[ WKIT.Conn.sdk.Base.getNick(unreads[i].contact)] = + unreads[i].msgCount; + } + document.getElementById("J_wkitPluginFrame").contentWindow.loadContactList(); + }, + 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 (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; + } else { + document.getElementById("J_wkitPluginFrame").contentWindow.unreadMap[msg_uid] = 1; + } + document.getElementById("J_wkitPluginFrame").contentWindow.loadContactList(); } \ No newline at end of file diff --git a/src/main/ui/service_contact_list.html b/src/main/ui/service_contact_list.html index 5b4fecb6f..9266dce0e 100644 --- a/src/main/ui/service_contact_list.html +++ b/src/main/ui/service_contact_list.html @@ -1,43 +1,35 @@ - + diff --git a/src/main/ui/service_customer.html b/src/main/ui/service_customer.html index eba9ba8d6..04369672d 100644 --- a/src/main/ui/service_customer.html +++ b/src/main/ui/service_customer.html @@ -1,5 +1,6 @@