AnIM.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  1. var newMsgBodyCount = 0; //新联系人个数
  2. //替换表情
  3. var regPlace = /(\[jie\]|\[kun\]|\[xia\]|\[shx\]|\[wx\]|\[kl\]|\[bq\]|\[lengh\]|\[pp\]|\[sa\]|\[mg\]|\[xu\]|\[lq\]|\[kk\]|\[shl\]|\[bp\]|\[yb\]|\[ruo\]|\[aini\]|\[gd\]|\[dk\]|\[xin\]|\[bangbangt\]|\[xiayu\]|\[lh\]|\[fn\]|\[fendou\]|\[qt\]|\[yhh\]|\[hq\]|\[kb\]|\[qiang\]|\[xs\]|\[db\]|\[lw\]|\[zhh\]|\[zhm\]|\[cd\]|\[fan\]|\[xig\]|\[huaix\]|\[hx\]|\[ka\]|\[yx\]|\[qiao\]|\[kel\]|\[gz\]|\[dy\]|\[jk\]|\[shuai\]|\[fd\]|\[duoyun\]|\[bu\]|\[baiy\]|\[se\]|\[gy\]|\[dx\]|\[yun\]|\[cj\]|\[ws\]|\[zt\]|\[qq\]|\[hn\]|\[jy\]|\[hanx\]|\[dg\]|\[ll\]|\[cy\]|\[kuk\]|\[ty\]|\[zk\]|\[tuu\]|\[ng\]|\[kf\]|\[bs\]|\[zhem\]|\[pz\]|\[shui\]|\[pj\]|\[gg\]|\[am\]|\[yao\]|\[cp\]|\[ch\]|\[tx\]|\[tp\]|\[wq\]|\[zj\]|\[bz\]|\[hd\]|\[yl\]|\[yiw\]|\[ic_launcher\]|\[ic_launcher_an\]|\[ic_launcher_huan\])/g;
  4. //发送图片默认大小
  5. var imgSize = "50%";
  6. //上次显示的时间
  7. var oldDatetime;
  8. //历史记录时间;
  9. var hisDateTime;
  10. var unReadCount = 0;
  11. var regCallback = function(data) {
  12. return "<img src='images/bq/" + data.replace(/\[/, '').replace(/\]/, '')
  13. + ".png'/ style='width:30px;height:30px'>";
  14. };
  15. var regCallback2 = function(data) {
  16. return "<img src='images/bq/" + data.replace(/\[/, '').replace(/\]/, '')
  17. + ".png'/ style='width:20px;height:20px'>";
  18. };
  19. function loadErrorImg() {
  20. $(".a-user-avatar > img, .a-myinfo-avatar > img, .a-myavatar > img,.user-avatar>img")
  21. .error(function() {
  22. $(this).attr("src", "images/face.png");
  23. });
  24. }
  25. //发送人信息
  26. var myInfo = {
  27. id : "",
  28. cName : "",
  29. photoUri : "",
  30. sex : 0,
  31. orgInfo : "",
  32. clientId : "",
  33. loginId : "",
  34. phone : "",
  35. email : "",
  36. birthday : "",
  37. provinceName : "",
  38. provinceID : "",
  39. cityName : "",
  40. cityID : "",
  41. orgName : "",
  42. departName : "",
  43. dutyName : ""
  44. };
  45. //消息条数
  46. var messagesize = {
  47. total : 0
  48. };
  49. //操作字典
  50. var OperaCode = {
  51. CODE_WNGG : "10000", // 院内公告
  52. CODE_DOC_TO_DOC : "11000", // 医生发送信息
  53. CODE_GROUP : "11001", // 医生对群组发送信息
  54. CODE_DOC_TO_PATIENT : "11002", // 医生对患者发送信息
  55. CODE_FRIENDS : "11003", // 好友申请
  56. CODE_SYS_GROUP : "10010", // 群组动态,退群
  57. CODE_SYS_GROUP_DEL : "10011", // 群组动态,群解散
  58. CODE_SYS_FRIENDS : "10020", // 医生同意好友申请后系统发起互相打招呼
  59. CODE_PATIENT_TO_DOC : "12000", // 患者对医生发送信息
  60. CODE_PHONE : "12001", // 预约回拨
  61. CODE_FREEBACK : "13000", // 意见反馈
  62. CODE_HEALTH_NEWS : "10001", // 健康报
  63. CODE_REFERRAL : "13004", // 转诊助手
  64. CODE_SYS_MESSAGE : "10002", // 系统公告
  65. CODE_LOVE_WEEK_NEWS : "13001", // 爱心值周排名
  66. CODE_LOVE_AWARD : "13002", // 爱心奖励
  67. CODE_PHONE_WEEK_NEWS : "13003", // 电话诊室周报
  68. CODE_HELP : "-9999" // 新手指导
  69. };
  70. //发送类型
  71. var ContentType = {
  72. CONTENT_TEXT : 0,
  73. CONTENT_MP3 : 1,
  74. CONTENT_IMG : 2,
  75. CONTENT_IMG_TEXT : 3,
  76. CONTENT_RECOMMEND : 4
  77. };
  78. //通信类
  79. function AnImClass() {
  80. this.appKey = 'drFnr1YojVjHrTfupuLDhppYLco7h6Ax';
  81. this.AnImObj = null;
  82. }
  83. //初始化通信
  84. AnImClass.prototype.initEvent = function() {
  85. AnImClass.prototype.AnImObj = new AnIM(
  86. {
  87. key : this.appKey,
  88. onStatusChanged : function(isConnected, error) {//通信状态改变
  89. if (!isConnected) {
  90. ifConnecte();
  91. }
  92. },
  93. onReceivedMessage : function(msg_id, message, from,
  94. custome_data, timestamp) {//接收消息回调方法
  95. if (Structure.tarClientId == from
  96. && $("#talking_box").css('display') == 'block') {
  97. loadMessage(custome_data, msg_id, message, false,
  98. timestampFormat(timestamp), "text", from);
  99. } else {
  100. showNewMessage(custome_data, message, from,
  101. timestampFormat(timestamp));
  102. }
  103. },
  104. onReceivedBinary : function(msg_id, fileType, from,
  105. custome_data, timestamp) {//接收二进制消息回调方法
  106. var url = "";
  107. var message = "";
  108. if (Structure.tarClientId == from&& $("#talking_box").css('display') == 'block') {
  109. if (fileType == 1) {
  110. url = AnImClass.prototype.AnImObj
  111. .getBinaryResourceURL(msg_id, "acc",
  112. "application/vnd.americandynamics.acc");
  113. message = '<audio src="'
  114. + url
  115. + '" controls="controls">您的浏览器不支持 audio 标签。</audio>';
  116. } else {
  117. url = AnImClass.prototype.AnImObj
  118. .getBinaryResourceURL(msg_id, "jpg",
  119. "image/jpg");
  120. message = "<img src='" + url + "' style='width:"
  121. + imgSize + "' ondblclick=showFullImg('" +url+ "') />";
  122. }
  123. loadMessage(custome_data, msg_id, message, false,
  124. timestampFormat(timestamp), "", from);
  125. } else {
  126. if (fileType == 1) {
  127. message = "[语音]";
  128. } else {
  129. message = "[图片]";
  130. }
  131. showNewMessage(custome_data, message, from,
  132. timestampFormat(timestamp));
  133. }
  134. },
  135. onReceivedTopicMessage : function(msg_id, message, from,
  136. topicId, cdata, timestamp) {//接收群消息回调方法
  137. if (Structure.tarClientId == topicId
  138. && $("#talking_box").css('display') == 'block') {
  139. loadMessage(cdata, msg_id, message, false,
  140. timestampFormat(timestamp), "", topicId);
  141. } else {
  142. showNewMessage(cdata, message, topicId,
  143. timestampFormat(timestamp));
  144. }
  145. memberInfos[topicId] = {
  146. "data-id" : cdata.groupId,
  147. "data-name" : cdata.groupName,
  148. "data-clientId" : cdata.groupClientId,
  149. "data-photoUri" : cdata.groupPhoto,
  150. "data-sex" : "0"
  151. };
  152. },
  153. onReceivedTopicBinary : function(msg_id, fileType, from,
  154. topicId, cdata, timestamp) {//接收二进制群消息回调方法
  155. var url = "";
  156. var message = "";
  157. if (Structure.tarClientId == topicId&& $("#talking_box").css('display') == 'block') {
  158. if (fileType == 1) {
  159. url = AnImClass.prototype.AnImObj
  160. .getBinaryResourceURL(msg_id, "acc",
  161. "application/vnd.americandynamics.acc");
  162. message = '<audio src="'
  163. + url
  164. + '" controls="controls">您的浏览器不支持 audio 标签。</audio>';
  165. } else {
  166. url = AnImClass.prototype.AnImObj
  167. .getBinaryResourceURL(msg_id, "jpg",
  168. "image/jpg");
  169. message = "<img src='" + url + "' style='width:"
  170. + imgSize + "' ondblclick=showFullImg('" +url+ "') />";
  171. }
  172. loadMessage(cdata, msg_id, message, false,
  173. timestampFormat(timestamp), "", topicId);
  174. } else {
  175. if (fileType == 1) {
  176. message = "[语音]";
  177. } else {
  178. message = "[图片]";
  179. }
  180. showNewMessage(cdata, message, topicId,
  181. timestampFormat(timestamp));
  182. }
  183. memberInfos[topicId] = {
  184. "data-id" : cdata.groupId,
  185. "data-name" : cdata.groupName,
  186. "data-clientId" : cdata.groupClientId,
  187. "data-photoUri" : cdata.groupPhoto,
  188. "data-sex" : "0"
  189. };
  190. },
  191. onMessageSent : function(error, msg_id) {//发送回调方法
  192. $("#msg_" + msg_id).hide();
  193. if (error) {
  194. $("#msg_" + msg_id).empty();
  195. $("#msg_" + msg_id).addClass("tipico tipico-err");
  196. }
  197. },
  198. onReceivedReceiveACK : function(msg_id, from) {//发送确认回调方法
  199. },
  200. onReceivedReadACK : function(msg_id, from) {
  201. },
  202. onClientsRemovedFromTopic : function(event_id, topic_id,
  203. parties, timestamp) {
  204. },
  205. onTopicRemoved : function(event_id, topic_id, timestamp) {//群组解散回调方法
  206. },
  207. onReceivedNotice : function(msg_id, message, from, topicId,
  208. custome_data, timestamp) {//接收通知回调方法
  209. //alert('接收通知回调方法');
  210. }
  211. });
  212. };
  213. //连接通信
  214. AnImClass.prototype.connect = function(clientId) {
  215. if (AnImClass.prototype.AnImObj == null) {
  216. console.log("未注册通信");
  217. } else {
  218. AnImClass.prototype.AnImObj.connect(clientId);
  219. }
  220. };
  221. //发送文本消息
  222. AnImClass.prototype.sendMessage = function(clientId, message, customData,
  223. receiveAck) {
  224. if (AnImClass.prototype.AnImObj == null) {
  225. console.log("未注册通信");
  226. } else {
  227. var msgId = "";
  228. msgId = AnImClass.prototype.AnImObj.sendMessage(clientId, message,
  229. customData, receiveAck);
  230. var customeDataObj = $.parseJSON(customData);
  231. if (msgId) {
  232. $("#text_msg").val("");
  233. }
  234. loadMessage(customeDataObj, msgId, message, true, (new Date())
  235. .format("yyyy-MM-dd hh:mm:ss"), "text", clientId);
  236. }
  237. };
  238. //发送群组消息
  239. AnImClass.prototype.sendMessageToTopic = function(topicId, message, customData,
  240. receiveAck) {
  241. if (AnImClass.prototype.AnImObj == null) {
  242. console.log("未注册通信");
  243. } else {
  244. var msgId = AnImClass.prototype.AnImObj.sendMessageToTopic(topicId,
  245. message, customData, receiveAck);
  246. var customeDataObj = $.parseJSON(customData);
  247. if (msgId) {
  248. $("#text_msg").val("");
  249. }
  250. loadMessage(customeDataObj, msgId, message, true, (new Date())
  251. .format("yyyy-MM-dd hh:mm:ss"), "text", topicId);
  252. }
  253. };
  254. //获取私聊离线消息记录
  255. AnImClass.prototype.getOfflineHistory = function(limit) {
  256. if (AnImClass.prototype.AnImObj == null) {
  257. console.log("未注册通信");
  258. } else {
  259. AnImClass.prototype.AnImObj.getOfflineHistory(myInfo.clientId, limit,
  260. function(error, messages, leftCount) {
  261. if (error) {
  262. console.log("获取私聊离线消息记录出错:"+error);
  263. } else {
  264. for ( var i in messages) {
  265. var message = messages[i];
  266. var messageStr = message.message;
  267. if (message.content_type != "text"
  268. && message.customData
  269. && message.customData.msgType == 1) {
  270. messageStr = '[语音]';
  271. } else if (message.content_type != "text"
  272. && message.customData
  273. && message.customData.msgType == 2) {
  274. messageStr = "[图片]";
  275. }
  276. showNewMessage(message.customData, messageStr,
  277. message.from,
  278. timestampFormat(message.timestamp),
  279. message.content_type, message.from);
  280. }
  281. }
  282. });
  283. }
  284. };
  285. //获取群聊离线消息记录
  286. AnImClass.prototype.getOfflineTopicHistory = function(limit) {
  287. if (AnImClass.prototype.AnImObj == null) {
  288. console.log("未注册通信");
  289. } else {
  290. AnImClass.prototype.AnImObj.getOfflineTopicHistory(myInfo.clientId,
  291. limit, "", function(error, messages, leftCount) {
  292. if (error) {
  293. console.log("获取群聊离线消息记录出错:"+error);
  294. } else {
  295. for ( var i in messages) {
  296. var message = messages[i];
  297. var messageStr = message.message;
  298. if (message.content_type != "text"
  299. && message.customData
  300. && message.customData.msgType == 1) {
  301. messageStr = '[语音]';
  302. } else if (message.content_type != "text"
  303. && message.customData
  304. && message.customData.msgType == 2) {
  305. messageStr = "[图片]";
  306. }
  307. showNewMessage(message.customData, messageStr,
  308. message.topic_id,
  309. timestampFormat(message.timestamp),
  310. message.content_type, message.topic_id);
  311. }
  312. }
  313. });
  314. }
  315. };
  316. // 获取私聊历史消息记录
  317. AnImClass.prototype.getHistory = function(tarClientId, clientId, limit,
  318. timestamp) {
  319. if (AnImClass.prototype.AnImObj == null) {
  320. console.log("未注册通信");
  321. } else {
  322. AnImClass.prototype.AnImObj
  323. .getHistory(
  324. tarClientId,
  325. clientId,
  326. limit,
  327. timestamp,
  328. function(error, messages) {
  329. if (error) {
  330. console.log("获取私聊历史消息记录出错:"+error);
  331. } else {
  332. $(".loading_box").show();
  333. $(".sec-main-con").html("");
  334. for ( var i in messages) {
  335. var message = messages[i];
  336. var url = "";
  337. var messageStr = message.message;
  338. if (message.content_type != "text"
  339. && message.customData
  340. && message.customData.msgType == 1) {
  341. url = AnImClass.prototype.AnImObj
  342. .getBinaryResourceURL(
  343. message.msg_id, "acc",
  344. "application/vnd.americandynamics.acc");
  345. messageStr = '<audio src="'
  346. + url
  347. + '" controls="controls">您的浏览器不支持 audio 标签。</audio>';
  348. } else if (message.content_type != "text"
  349. && message.customData
  350. && message.customData.msgType == 2) {
  351. url = AnImClass.prototype.AnImObj
  352. .getBinaryResourceURL(
  353. message.msg_id, "jpg",
  354. "image/jpg");
  355. messageStr = "<img src='" + url
  356. + "' class='dbimg' style='width:" + imgSize
  357. + "' />";
  358. }
  359. if (i == 0) {
  360. showMsgListMessage(
  361. message,
  362. messageStr,
  363. false,
  364. timestampFormat(message.timestamp));
  365. }
  366. if (i == messages.length - 1) {
  367. hisDateTime = message.timestamp;
  368. }
  369. loadHistoryMessage(message.customData,
  370. message.msg_id, messageStr,
  371. message.from == myInfo.clientId,
  372. timestampFormat(message.timestamp),
  373. message.content_type, message.from);
  374. }
  375. $(".dbimg").dblclick(function(){
  376. $('#show-full-img > img').attr("src",$(this).attr("src"));
  377. var contentImg=$('#show-full-img').get(0);
  378. // var contentImg='<img src="'+$(this).attr("src")+'">';
  379. var d = art.dialog({
  380. title: '图片',
  381. padding: '1px 1px',
  382. lock: true,
  383. content: contentImg
  384. });
  385. $('.aui_content').niceScroll({cursorborder:"",cursorcolor:"#cccdd1"});
  386. d.show();
  387. });
  388. setTimeout(scrollBottom, 100);
  389. $(".loading_box").hide();
  390. }
  391. });
  392. }
  393. };
  394. AnImClass.prototype.getHistory2 = function(tarClientId, clientId, limit,timestamp) {
  395. if (AnImClass.prototype.AnImObj == null) {
  396. console.log("未注册通信");
  397. } else {
  398. AnImClass.prototype.AnImObj.getHistory(tarClientId,clientId,limit,timestamp,function(error, messages) {
  399. if (error) {
  400. console.log(error);
  401. } else {
  402. for ( var i in messages) {
  403. var message = messages[i];
  404. var url = "";
  405. var messageStr = message.message;
  406. if (message.content_type != "text" && message.customData
  407. && message.customData.msgType == 1) {
  408. messageStr = '[语音]';
  409. } else if (message.content_type != "text" && message.customData
  410. && message.customData.msgType == 2) {
  411. messageStr = '[图片]';
  412. }
  413. if (message.customData.msgType == ContentType.CONTENT_IMG
  414. && message.content_type == "text") {
  415. messageStr = "[图片]";
  416. } else if (message.customData.msgType == 0) {
  417. messageStr = YiHu.Util.htmlspecialchars(messageStr).replace(regPlace, regCallback2);
  418. }
  419. var NowTime=new Date().getTime();
  420. if (NowTime-message.timestamp<=1000*60*60*24*7){
  421. showOldMessage(message.customData, messageStr,tarClientId,timestampFormat(message.timestamp),message.content_type);
  422. }
  423. }
  424. }
  425. });
  426. }
  427. };
  428. // 获取群聊历史消息记录
  429. AnImClass.prototype.getTopicHistory2 = function(topicId, clientId, limit,timestamp) {
  430. if (AnImClass.prototype.AnImObj == null) {
  431. console.log("未注册通信");
  432. } else {
  433. AnImClass.prototype.AnImObj
  434. .getTopicHistory(
  435. topicId,
  436. limit,
  437. timestamp,
  438. clientId,
  439. function(error, messages) {
  440. if (error) {
  441. console.log(error);
  442. } else {
  443. for ( var i in messages) {
  444. var message = messages[i];
  445. var url = "";
  446. var messageStr = message.message;
  447. if (message.content_type != "text" && message.customData
  448. && message.customData.msgType == 1) {
  449. messageStr = '[语音]';
  450. } else if (message.content_type != "text" && message.customData
  451. && message.customData.msgType == 2) {
  452. messageStr = '[图片]';
  453. }
  454. if (message.customData.msgType == ContentType.CONTENT_IMG
  455. && message.content_type == "text") {
  456. messageStr = "[图片]";
  457. } else if (message.customData.msgType == 0) {
  458. messageStr = YiHu.Util.htmlspecialchars(messageStr).replace(regPlace, regCallback2);
  459. }
  460. var NowTime=new Date().getTime();
  461. if (NowTime-message.timestamp<=1000*60*60*24*7){
  462. showOldMessage(message.customData, messageStr,topicId,timestampFormat(message.timestamp),message.content_type);
  463. }
  464. }
  465. }
  466. });
  467. }
  468. };
  469. //显示历史消息
  470. function showOldMessage(customData, message, from, dateStr, dataType) {
  471. var memberInfo = memberInfos[from];
  472. if(!memberInfo){
  473. return;
  474. }
  475. message = message.replace(/\n/g, "<br/>");
  476. var $linewMsg = $("#linewMsg_" + from);
  477. if ($linewMsg.length > 0) {
  478. return;
  479. }
  480. var isGroup = false;
  481. if (customData.groupId && customData.groupId != "") {
  482. isGroup = true;
  483. }
  484. var photoUri = memberInfo["data-photoUri"];
  485. photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";
  486. var str = [
  487. '<li class="boss-user" id="linewMsg_' + from + '" data-clientId="'
  488. + from + '" '
  489. + (isGroup ? "data-group='1'" : "data-group='0'") + '>',
  490. "<a href=\"javascript:;\" onclick=\"showNewChat('" + from + "',"
  491. + (isGroup ? true : false) + ");\" >",
  492. ' <div class="boss-user-face"><img class=\"c-images-block\" src="'
  493. + photoUri + '"/></div>',
  494. '<div class="boss-user-name c-nowrap c-f14 c-333"> <p class="new-c-nowrap c-f14 c-333">'
  495. + memberInfo["data-name"]
  496. + '</p>',
  497. '<p class="c-nowrap c-f12 c-909090">'
  498. + (isGroup ? customData.sourceName + ":"
  499. + message.replace(regPlace, regCallback2) : message
  500. .replace(regPlace, regCallback2)) + '</p>',
  501. '</div>',
  502. ' <div class="boss-user-time c-position-a">'
  503. + YiHu.Util.dataTimeToStr(dateStr) + '</div>',
  504. '</a>',
  505. '</li>' ];
  506. $("#msgUl").append(str.join(''));
  507. $("#newMsg_" + from).hide();
  508. //sumUnreadCount();
  509. }
  510. // 获取群聊历史消息记录
  511. AnImClass.prototype.getTopicHistory = function(topicId, limit, timestamp,
  512. clientId) {
  513. if (AnImClass.prototype.AnImObj == null) {
  514. console.log("未注册通信");
  515. } else {
  516. AnImClass.prototype.AnImObj
  517. .getTopicHistory(
  518. topicId,
  519. limit,
  520. timestamp,
  521. clientId,
  522. function(error, messages) {
  523. if (error) {
  524. console.log("获取群聊历史消息记录出错:"+error);
  525. } else {
  526. $(".loading_box").show();
  527. $(".sec-main-con").html("");
  528. for ( var i in messages) {
  529. var message = messages[i];
  530. var url = "";
  531. var messageStr = message.message;
  532. if (message.content_type != "text"
  533. && message.customData
  534. && message.customData.msgType == 1) {
  535. url = AnImClass.prototype.AnImObj
  536. .getBinaryResourceURL(
  537. message.msg_id, "acc",
  538. "application/vnd.americandynamics.acc");
  539. messageStr = '<audio src="'
  540. + url
  541. + '" controls="controls">您的浏览器不支持 audio 标签。</audio>';
  542. } else if (message.content_type != "text"
  543. && message.customData
  544. && message.customData.msgType == 2) {
  545. url = AnImClass.prototype.AnImObj
  546. .getBinaryResourceURL(
  547. message.msg_id, "jpg",
  548. "image/jpg");
  549. messageStr = "<img src='" + url
  550. + "' class='dbimg' style='width:" + imgSize
  551. + "' />";
  552. }
  553. if (i == 0) {
  554. showMsgListMessage(
  555. message,
  556. messageStr,
  557. true,
  558. timestampFormat(message.timestamp));
  559. }
  560. if (i == messages.length - 1) {
  561. hisDateTime = message.timestamp;
  562. }
  563. loadHistoryMessage(message.customData,
  564. message.msg_id, messageStr,
  565. message.from == myInfo.clientId,
  566. timestampFormat(message.timestamp),
  567. message.content_type,
  568. message.topicId);
  569. }
  570. $(".dbimg").dblclick(function(){
  571. $('#show-full-img > img').attr("src",$(this).attr("src"));
  572. var contentImg=$('#show-full-img').get(0);
  573. // var contentImg='<img src="'+$(this).attr("src")+'">';
  574. var d = art.dialog({
  575. title: '图片',
  576. padding: '1px 1px',
  577. lock: true,
  578. content: contentImg
  579. });
  580. $('.aui_content').niceScroll({cursorborder:"",cursorcolor:"#cccdd1"});
  581. d.show();
  582. });
  583. setTimeout(scrollBottom, 100);
  584. $(".loading_box").hide();
  585. }
  586. });
  587. }
  588. };
  589. function showMsgListMessage(message, messageStr, isGroup, dateStr) {
  590. // $("#linewMsg_" + Structure.tarClientId + ">.fl>.hidden>.a-msg-time").html(YiHu.Util.dataTimeToStr(timestampFormat(message.timestamp)));
  591. var msg = messageStr;
  592. if (message.content_type != "text" && message.customData
  593. && message.customData.msgType == 1) {
  594. msg = '[语音]';
  595. } else if (message.content_type != "text" && message.customData
  596. && message.customData.msgType == 2) {
  597. msg = '[图片]';
  598. }
  599. if (message.customData.msgType == ContentType.CONTENT_IMG
  600. && message.content_type == "text") {
  601. msg = "[图片]";
  602. } else if (message.customData.msgType == 0) {
  603. msg = YiHu.Util.htmlspecialchars(msg).replace(regPlace, regCallback2);
  604. }
  605. $(
  606. "#linewMsg_" + Structure.tarClientId
  607. + ">a>.boss-user-name>.c-nowrap.c-f12.c-909090").html(
  608. (isGroup ? message.customData.sourceName + ":" + msg : msg));
  609. $("#linewMsg_" + Structure.tarClientId + ">a>.boss-user-time.c-position-a")
  610. .html(YiHu.Util.dataTimeToStr(dateStr));
  611. }
  612. function showMsgMessage(content_type, customData, messageStr, isGroup, from,
  613. dateStr) {
  614. // $("#linewMsg_" + Structure.tarClientId + ">.fl>.hidden>.a-msg-time").html(YiHu.Util.dataTimeToStr(timestampFormat(message.timestamp)));
  615. var msg = messageStr;
  616. if (content_type != "text" && customData && customData.msgType == 1) {
  617. msg = '[语音]';
  618. } else if (content_type != "text" && customData && customData.msgType == 2) {
  619. msg = '[图片]';
  620. }
  621. if (customData.msgType == ContentType.CONTENT_IMG && content_type == "text") {
  622. msg = "[图片]";
  623. } else if (customData.msgType == 0) {
  624. msg = YiHu.Util.htmlspecialchars(msg).replace(regPlace, regCallback2);
  625. }
  626. $("#linewMsg_" + from + ">a>.boss-user-name>.c-nowrap.c-f12.c-909090")
  627. .html((isGroup ? customData.sourceName + ":" + msg : msg));
  628. $("#linewMsg_" + Structure.tarClientId + ">a>.boss-user-time.c-position-a")
  629. .html(YiHu.Util.dataTimeToStr(dateStr));
  630. }
  631. //加载信息
  632. function loadMessage(customData, msgId, message, isMy, dateStr, contentType,
  633. from) {
  634. showMsgMessage(contentType, customData, message,
  635. (customData.groupId && customData.groupId != ""), from, dateStr);
  636. if (customData.msgType == ContentType.CONTENT_IMG && contentType == "text") {
  637. message = "<img src='" + message + "' style='width:50%' />";
  638. } else if (customData.msgType == 0) {
  639. message = YiHu.Util.htmlspecialchars(message);
  640. }
  641. if (!message) {
  642. message = "";
  643. }
  644. message = message.replace(/\n/g, "<br/>");
  645. var showTime = false;
  646. if (!oldDatetime) {
  647. oldDatetime = new Date();
  648. showTime = true;
  649. }
  650. if (oldDatetime && YiHu.Util.addMinutes(oldDatetime, 5) < new Date()) {
  651. oldDatetime = new Date();
  652. showTime = true;
  653. }
  654. var photoUri = customData.uri;
  655. photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";
  656. var str = [
  657. '<div class="t-center">',
  658. showTime ? '<p class="msg-time">'
  659. + YiHu.Util.dataTimeToStr(dateStr) + '</p></div>' : "",
  660. '<div class="' + (isMy ? 'msg-mine' : 'msg-other') + '">',
  661. '<div class="user-avatar"><img src="'
  662. + photoUri
  663. + '" alt="" style="width:40px;height:40px;border-radius:20px 20px" /></div>',
  664. ' <div class="' + (isMy ? 'fr' : 'fl') + '">',
  665. '<div class="user-name">' + customData.sourceName + ' </div>',
  666. '<div class="msg-box">',
  667. '<p>' + message.replace(regPlace, regCallback) + '</p>',
  668. '<em class="msg-box-arr"><i></i></em>',
  669. (isMy ? '<i class="tipico" id="msg_' + msgId
  670. + '"><img src="images/022.gif"></i>' : '')
  671. + '</div>', '</div></div>' ];
  672. $(".sec-main-con").append(str.join(''));
  673. setTimeout(scrollBottom, 100);
  674. // loadErrorImg();
  675. }
  676. //加载历史信息
  677. function loadHistoryMessage(customData, msgId, message, isMy, dateStr,
  678. contentType, from) {
  679. if (customData.msgType == ContentType.CONTENT_IMG && contentType == "text") {
  680. message = "<img src='" + message + "' style='width:100%' />";
  681. } else if (customData.msgType == 0) {
  682. message = YiHu.Util.htmlspecialchars(message);
  683. }
  684. if (!message) {
  685. message = "";
  686. }
  687. message = message.replace(/\n/g, "<br/>");
  688. var photoUri = customData.uri;
  689. photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";
  690. var str = [
  691. '<div class="t-center" style="padding-top:50px;">',
  692. '<p class="msg-time">' + YiHu.Util.dataTimeToStr(dateStr)
  693. + '</p></div>',
  694. '<div class="' + (isMy ? 'msg-mine' : 'msg-other') + '">',
  695. '<div class="user-avatar"><img src="'
  696. + photoUri
  697. + '" alt="" style="width:40px;height:40px;border-radius:20px 20px" /></div>',
  698. ' <div class="' + (isMy ? 'fr' : 'fl') + '">',
  699. '<div class="user-name">' + customData.sourceName + ' </div>',
  700. '<div class="msg-box">',
  701. '<p>' + message.replace(regPlace, regCallback) + '</p>',
  702. '<em class="msg-box-arr"><i></i></em>', '</div>', '</div></div>' ];
  703. $(".sec-main-con").prepend(str.join(''));
  704. //window.frames['iframe-im-if'].contentWindow.loadMessage(str.join(''));
  705. }
  706. //显示新消息
  707. function showNewMessage(customData, message, from, dateStr, dataType) {
  708. if (customData.msgType == ContentType.CONTENT_IMG && dataType == "text") {
  709. message = "<img src='" + message + "' style='width:" + imgSize + "' />";
  710. } else if (customData.msgType == 0) {
  711. message = YiHu.Util.htmlspecialchars(message);
  712. }
  713. var memberInfo = memberInfos[from];
  714. if (!memberInfo) {
  715. if (customData.groupId && customData.groupId != "") {
  716. memberInfos[from] = {
  717. "data-id" : customData.groupId,
  718. "data-name" : customData.groupName,
  719. "data-clientId" : customData.groupClientId,
  720. "data-photoUri" : customData.groupPhoto,
  721. "data-sex" : "0"
  722. };
  723. } else {
  724. memberInfos[from] = {
  725. "data-id" : customData.sourceId,
  726. "data-name" : customData.sourceName,
  727. "data-clientId" : from,
  728. "data-photoUri" : customData.uri,
  729. "data-sex" : customData.sex
  730. };
  731. }
  732. }
  733. message = message.replace(/\n/g, "<br/>");
  734. var $newMsg = $("#newMsg_" + from);
  735. var msgCount = 1;
  736. if ($newMsg.length > 0) {
  737. var oldMsgCount = parseInt($newMsg.html());
  738. msgCount += oldMsgCount;
  739. if (msgCount > 99)
  740. msgCount = 99;
  741. $("#linewMsg_" + from).detach();
  742. } else {
  743. newMsgBodyCount += 1;
  744. }
  745. if($("#linewMsg_" + from).length > 0){
  746. $("#linewMsg_" + from).detach();
  747. }
  748. var isGroup = false;
  749. if (customData.groupId && customData.groupId != "") {
  750. isGroup = true;
  751. }
  752. var photoUri = isGroup ? customData.groupPhoto : customData.uri;
  753. photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";
  754. var str = [
  755. '<li class="boss-user" id="linewMsg_' + from + '" data-clientId="'
  756. + from + '" '
  757. + (isGroup ? "data-group='1'" : "data-group='0'") + '>',
  758. "<a href=\"javascript:;\" onclick=\"showNewChat('" + from + "',"
  759. + (isGroup ? true : false) + ");\" >",
  760. ' <div class="boss-user-face"><img class=\"c-images-block\" src="'
  761. + photoUri + '"/></div>',
  762. '<div class="boss-user-name c-nowrap c-f14 c-333"> <p class="new-c-nowrap c-f14 c-333">'
  763. + (isGroup ? customData.groupName : customData.sourceName)
  764. + '</p>',
  765. '<p class="c-nowrap c-f12 c-909090">'
  766. + (isGroup ? customData.sourceName + ":"
  767. + message.replace(regPlace, regCallback2) : message
  768. .replace(regPlace, regCallback2)) + '</p>',
  769. '</div>',
  770. ' <div class="boss-user-time c-position-a">'
  771. + YiHu.Util.dataTimeToStr(dateStr) + '</div>',
  772. '<div class="boss-user-number c-position-a" id="newMsg_' + from
  773. + '">' + msgCount + '</div>', '</a>',
  774. '</li>' ];
  775. $("#msgUl").prepend(str.join(''));
  776. sumUnreadCount();
  777. }
  778. //计算未读数据
  779. function sumUnreadCount() {
  780. unReadCount = 0;
  781. $(".boss-user-number.c-position-a").each(function(index, element) {
  782. unReadCount += parseInt($(element).html());
  783. if ($(".boss-user-number.c-position-a").length - 1 == index) {
  784. if (unReadCount > 0) {
  785. $("#im_count").html(unReadCount);
  786. $("#im_count").show();
  787. }
  788. }
  789. });
  790. }
  791. function scrollBottom() {
  792. $(".sec_scroll").scrollTop(10000);
  793. }
  794. //加载更多聊天记录
  795. function loadMoreMessage() {
  796. if (Structure.isGroup) {
  797. anImClass.getTopicHistory(Structure.tarClientId, myInfo.clientId, 30,
  798. hisDateTime);
  799. } else {
  800. anImClass.getHistory(Structure.tarClientId, myInfo.clientId, 30,
  801. hisDateTime);
  802. }
  803. }
  804. function showNewChat(clientId, isGroup) {
  805. if(clientId&&clientId!=''){
  806. if (clientId == myInfo.clientId) {
  807. showMsg("不能和自己聊天!!!");
  808. $(".loading_box").hide();
  809. return false;
  810. }
  811. var clickObj = memberInfos[clientId];
  812. var clickMsgCount = parseInt($("#newMsg_" + clientId).html());
  813. if (!clickMsgCount){
  814. clickMsgCount=0;
  815. }
  816. if (clickObj["data-clientId"] != Structure.tarClientId) {
  817. //event.stopPropagation();
  818. Structure.tarClientId = clickObj["data-clientId"];
  819. Structure.cName = clickObj["data-name"];
  820. Structure.isGroup = isGroup;
  821. Structure.id = clickObj["data-id"];
  822. Structure.photoUri = clickObj["data-photoUri"];
  823. Structure.photoUri = Structure.photoUri == "" ? "images/face.png"
  824. : Structure.photoUri;
  825. Structure.sex = clickObj["data-sex"];
  826. $(".section-header.clearfix > h4").html(Structure.cName);
  827. $("#talkingID").val(Structure.id);
  828. $("#clientId").val(Structure.tarClientId);
  829. $("#talking_box").show();
  830. $('#iframe-im').show();
  831. $(".sec-main-con").html("");
  832. $("#text_msg").val("");
  833. $('#text_msg').focus();
  834. if (clickMsgCount > 0) {
  835. $("#newMsg_" + clientId).html('0').hide();
  836. $("#newMsg_" + clientId).detach();
  837. newMsgBodyCount -= 1;
  838. }
  839. sumUnreadCount();
  840. if (newMsgBodyCount <= 0) {
  841. newMsgBodyCount = 0;
  842. $("#im_count").hide();
  843. //$(".boss-user-number.c-position-a").remove();
  844. }
  845. if (isGroup) {
  846. $("#isGroup").val(1);
  847. anImClass.getTopicHistory(Structure.tarClientId,10 + parseInt(clickMsgCount), "", myInfo.clientId);
  848. } else{
  849. $("#isGroup").val(0);
  850. anImClass.getHistory(Structure.tarClientId, myInfo.clientId,10 + parseInt(clickMsgCount), "");
  851. }
  852. }
  853. }
  854. }
  855. var newPushMsgIds = '';
  856. var limitBody = 1;
  857. var newAppMsgIds = '';
  858. var limitAppBody = 1;
  859. //加载未读推送消息
  860. function loadPushMsgList(frist) {
  861. $.ajax({
  862. url : "PushMsgListAction/getPushMsgList",
  863. dataType : "json",
  864. data : {
  865. readStatus : 1
  866. },
  867. type : 'POST',
  868. success : function(msg) {
  869. if (msg) {
  870. if (msg.Code == 10000) {
  871. //if (msg.Result && msg.Result != '') {
  872. var data = msg.Result;
  873. var sysMsgCount = 0;
  874. var appMsgCount = 0;
  875. var $newMsg = $("#newMsg_sysMessage");
  876. if ($newMsg.length > 0) {
  877. //$("#linewMsg_sysMessage").detach();
  878. var dateStr = '';
  879. var content;
  880. var title = '';
  881. var dateStrApp = '';
  882. var contentApp;
  883. var titleApp = '';
  884. var fFlag=0;
  885. var gFlag=0;
  886. newPushMsgIds = '';
  887. newAppMsgIds = '';
  888. for ( var i = 0; i < data.length; i++) {
  889. if (data[i].operCode&& data[i].operCode != 11003) {
  890. if(data[i].operCode==10020){
  891. fFlag=1;
  892. }
  893. if(data[i].operCode==10010||data[i].operCode==10011){
  894. gFlag=1;
  895. }
  896. dateStr = timestampFormat(data[i]._msg.insertTimeMillis);
  897. content = data[i].content;
  898. if (typeof (content) == 'object') {
  899. if (data[i].content.describe) {
  900. content = data[i].content.describe;
  901. } else {
  902. content = '';
  903. }
  904. } else {
  905. content = (content && content != "") ? content : "";
  906. }
  907. title = data[i].title;
  908. title = (title && title != "") ? title: "";
  909. newPushMsgIds += data[i].msgId+ ",";
  910. sysMsgCount++;
  911. if (sysMsgCount > 99)
  912. sysMsgCount = 99;
  913. }/*else if(data[i].operCode == 13006){
  914. dateStrApp = timestampFormat(data[i]._msg.insertTimeMillis);
  915. contentApp = data[i].content;
  916. if (typeof (contentApp) == 'object') {
  917. if (data[i].content.describe) {
  918. contentApp = data[i].content.describe;
  919. } else {
  920. contentApp = '';
  921. }
  922. } else {
  923. contentApp = (contentApp && contentApp != "") ? contentApp : "";
  924. }
  925. titleApp = data[i].title;
  926. titleApp = (titleApp && titleApp != "") ? titleApp: "";
  927. newAppMsgIds += data[i].msgId+ ",";
  928. appMsgCount++;
  929. if (appMsgCount > 99)
  930. appMsgCount = 99;
  931. }*/
  932. }
  933. var appObj = msg.appArray;
  934. for (var p in appObj) {
  935. // p就是得到的key值
  936. var appMessage=appObj[p];
  937. var appName='';
  938. dateStrApp = timestampFormat(appMessage[0]._msg.insertTimeMillis);
  939. contentApp = appMessage[0].content;
  940. if (typeof (contentApp) == 'object') {
  941. if (appMessage[0].content.describe) {
  942. contentApp = appMessage[0].content.describe;
  943. } else {
  944. contentApp = '';
  945. }
  946. appName=appMessage[0].content.appName;
  947. } else {
  948. contentApp = (contentApp && contentApp != "") ? contentApp : "";
  949. }
  950. titleApp = appMessage[0].title;
  951. titleApp = (titleApp && titleApp != "") ? titleApp: "";
  952. //newAppMsgIds += appMessage[0].msgId+ ",";
  953. appMsgCount = appObj[p].length;
  954. //alert(appMsgCount);
  955. // if (appMsgCount > 99)
  956. // appMsgCount = 99;
  957. var $newAppMsg = $("#newAppMsg_" + p);
  958. if ($newAppMsg.length > 0) {
  959. //var oldMsgCount = parseInt($newAppMsg.html());
  960. //appMsgCount += oldMsgCount;
  961. if (appMsgCount > 99)
  962. appMsgCount = 99;
  963. $("#lineAppMsg_" + p).detach();
  964. } else {
  965. newMsgBodyCount += 1;
  966. }
  967. if($("#lineAppMsg_" + p).length > 0){
  968. $("#lineAppMsg_" + p).detach();
  969. }
  970. var str = [
  971. '<li class="boss-user" id="lineAppMsg_' + p + '">',
  972. "<a href=\"javascript:;\" onclick=\"showAppMessage('" + p + "');\" >",
  973. ' <div class="boss-user-face"><img class=\"c-images-block\" src="images/dbsx.png"/></div>',
  974. '<div class="boss-user-name"> <p class="new-c-nowrap c-f13 c-333">'+appName+'-待办工作'+ '</p>',
  975. '<p class="c-nowrap c-f12 c-909090">'+titleApp+':'+ contentApp + '</p>',
  976. '</div>',
  977. '<div class="boss-user-time c-position-a">'+ YiHu.Util.dataTimeToStr(dateStrApp) + '</div>',
  978. '<div class="boss-user-number c-position-a" id="newAppMsg_' + p+ '">' + appMsgCount + '</div>',
  979. '</a>',
  980. '</li>' ];
  981. $("#msgUl").prepend(str.join(''));
  982. sumUnreadCount();
  983. }
  984. if (sysMsgCount > 0) {
  985. $("#newMsg_sysMessage").html(sysMsgCount).show();
  986. $("#linewMsg_sysMessage >a > .boss-user-time.c-position-a").html(YiHu.Util.dataTimeToStr(dateStr));
  987. $("#title_sysMessage").html(title);
  988. $("#content_sysMessage").html(content);
  989. newMsgBodyCount += limitBody;
  990. limitBody = 0;
  991. }
  992. /*
  993. if (appMsgCount > 0) {
  994. $("#newMsg_appMessage").html(appMsgCount).show();
  995. $("#linewMsg_appMessage >a > .boss-user-time.c-position-a").html(YiHu.Util.dataTimeToStr(dateStrApp));
  996. $("#title_appMessage").html(titleApp);
  997. $("#content_appMessage").html(contentApp);
  998. newMsgBodyCount += limitAppBody;
  999. limitAppBody = 0;
  1000. }*/
  1001. if(frist!=1){
  1002. if(gFlag==1){
  1003. loadGroups();
  1004. }
  1005. if(fFlag==1){
  1006. loadFriends();
  1007. }
  1008. }
  1009. }
  1010. sumUnreadCount();
  1011. // }
  1012. } else if (msg.Code == -8000) {
  1013. //showHideMsg(data.Message, 3);
  1014. window.location.href = "jump.jsp";
  1015. } else {
  1016. //showHideMsg("加载未读推送消息失败", 1);
  1017. }
  1018. } else {
  1019. //showHideMsg("加载未读推送消息失败", 1);
  1020. }
  1021. },
  1022. error : function() {
  1023. //showHideMsg("加载未读推送消息失败", 1);
  1024. }
  1025. });
  1026. }
  1027. //加载好友邀请中列表信息
  1028. function loadFriendInvite() {
  1029. $.ajax({
  1030. url : "UserFriendInvite/queryFriendInviteList",
  1031. dataType : "json",
  1032. type : 'POST',
  1033. success : function(msg) {
  1034. if (msg) {
  1035. if (msg.Code == 10000) {
  1036. var $newMsg = $("#newMsg_VMessage");
  1037. if ($newMsg.length > 0) {
  1038. var clickMsgCount = parseInt($(
  1039. "#newMsg_VMessage").html());
  1040. if (clickMsgCount > 0) {
  1041. $("#newMsg_VMessage").html('0').hide();
  1042. newMsgBodyCount -= 1;
  1043. }
  1044. sumUnreadCount();
  1045. if (newMsgBodyCount <= 0) {
  1046. newMsgBodyCount = 0;
  1047. $("#im_count").hide();
  1048. //$(".boss-user-number.c-position-a").remove();
  1049. }
  1050. $("#linewMsg_VMessage").detach();
  1051. }
  1052. if (msg.Result && msg.Result != '') {
  1053. var data = msg.Result;
  1054. var sysMsgCount = 0;
  1055. var VMessageCount = 0;
  1056. var str = '';
  1057. for ( var i = 0; i < data.length; i++) {
  1058. var photoUri = data[i].photoUri;
  1059. photoUri = (photoUri && photoUri != "") ? photoUri
  1060. : "images/face.png";
  1061. var dateStr = data[i].updateTime;
  1062. VMessageCount++;
  1063. if (VMessageCount > 99)
  1064. VMessageCount = 99;
  1065. str = [
  1066. '<li class="boss-user" id="linewMsg_VMessage">',
  1067. '<a href=\"javascript:;\" onclick=\"showVMessage();\">',
  1068. '<div class="boss-user-face"><img class=\"c-images-block\" src="'
  1069. + photoUri + '"/></div>',
  1070. '<div class="boss-user-name c-nowrap c-f14 c-333"> <p class="c-nowrap c-f14 c-333">'
  1071. + '您有一条验证消息' + '</p>',
  1072. '<p class="c-nowrap c-f12 c-909090">'
  1073. + data[i].userName
  1074. + '请求添加您为好友' + '</p>',
  1075. '</div>',
  1076. '<div class="boss-user-time c-position-a">'
  1077. + YiHu.Util
  1078. .dataTimeToStr(dateStr)
  1079. + '</div>',
  1080. '<div class="boss-user-number c-position-a" id="newMsg_VMessage">'
  1081. + VMessageCount + '</div>',
  1082. '</a></li>' ];
  1083. }
  1084. if (str != '') {
  1085. newMsgBodyCount += 1;
  1086. $("#msgUl").prepend(str.join(''));
  1087. }
  1088. sumUnreadCount();
  1089. }
  1090. } else if (msg.Code == -8000) {
  1091. //showHideMsg(data.Message, 3);
  1092. window.location.href = "jump.jsp";
  1093. } else {
  1094. //showHideMsg("加载好友邀请中列表信息失败", 1);
  1095. }
  1096. } else {
  1097. //showHideMsg("加载好友邀请中列表信息失败", 1);
  1098. }
  1099. },
  1100. error : function() {
  1101. //showHideMsg("加载好友邀请中列表信息失败", 1);
  1102. }
  1103. });
  1104. }
  1105. function showVMessage() {
  1106. $('#iframe-userInfo').attr("src", "");
  1107. showIframe('verificationMessage.html');
  1108. }
  1109. function showSysMessage() {
  1110. var clickMsgCount = parseInt($("#newMsg_sysMessage").html());
  1111. if (clickMsgCount > 0) {
  1112. $("#newMsg_sysMessage").html('0').hide();
  1113. newMsgBodyCount -= 1;
  1114. limitBody = 1;
  1115. }
  1116. sumUnreadCount();
  1117. if (newMsgBodyCount <= 0) {
  1118. newMsgBodyCount = 0;
  1119. $("#im_count").hide();
  1120. //$(".boss-user-number.c-position-a").remove();
  1121. }
  1122. $('#iframe-userInfo').attr("src", "");
  1123. showIframe('sysMessage.html');
  1124. }
  1125. function showAppMessage(id) {
  1126. var clickMsgCount = parseInt($("#newAppMsg_"+id).html());
  1127. if (clickMsgCount > 0) {
  1128. $("#newAppMsg_"+id).html('0').hide();
  1129. newMsgBodyCount -= 1;
  1130. //limitAppBody = 1;
  1131. }
  1132. sumUnreadCount();
  1133. if (newMsgBodyCount <= 0) {
  1134. newMsgBodyCount = 0;
  1135. $("#im_count").hide();
  1136. //$(".boss-user-number.c-position-a").remove();
  1137. }
  1138. var src='appMessage.html?appId='+id;
  1139. $('#iframe-userInfo').attr("src", "");
  1140. showIframe(src);
  1141. }
  1142. function showFullImg(url){
  1143. $('#show-full-img > img').attr("src",url);
  1144. var contentImg=$('#show-full-img').get(0);
  1145. // var contentImg='<img src="'+$(this).attr("src")+'">';
  1146. var d = art.dialog({
  1147. title: '图片',
  1148. padding: '1px 1px',
  1149. lock: true,
  1150. content: contentImg
  1151. });
  1152. $('.aui_content').niceScroll({cursorborder:"",cursorcolor:"#cccdd1"});
  1153. d.show();
  1154. }
  1155. function ifConnecte() {
  1156. art.dialog({
  1157. lock : false,
  1158. artIcon : 'ask',
  1159. opacity : 0.4,
  1160. time: 5,
  1161. width : '15%',
  1162. height: '10%',
  1163. title : '提示',
  1164. content : '已经在其他地方登入,IM会话已断开(您如果还想继续进行IM聊天,请重新登入系统)',
  1165. left: '95%', // X轴坐标
  1166. top: '100%', // Y轴坐标
  1167. init: function() {
  1168. $(".aui_close").hide();
  1169. }
  1170. });
  1171. }