| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360 | var newMsgBodyCount = 0; //新联系人个数//替换表情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;//发送图片默认大小var imgSize = "50%";//上次显示的时间var oldDatetime;//历史记录时间;var hisDateTime;var unReadCount = 0;var regCallback = function(data) {	return "<img src='images/bq/" + data.replace(/\[/, '').replace(/\]/, '')			+ ".png'/ style='width:30px;height:30px'>";};var regCallback2 = function(data) {	return "<img src='images/bq/" + data.replace(/\[/, '').replace(/\]/, '')			+ ".png'/ style='width:20px;height:20px'>";};function loadErrorImg() {	$(".a-user-avatar > img, .a-myinfo-avatar > img, .a-myavatar > img,.user-avatar>img")			.error(function() {				$(this).attr("src", "images/face.png");			});}//发送人信息var myInfo = {	id : "",	cName : "",	photoUri : "",	sex : 0,	orgInfo : "",	clientId : "",	loginId : "",	phone : "",	email : "",	birthday : "",	provinceName : "",	provinceID : "",	cityName : "",	cityID : "",	orgName : "",	departName : "",	dutyName : ""};//消息条数var messagesize = {	total : 0};//操作字典var OperaCode = {	CODE_WNGG : "10000", // 院内公告	CODE_DOC_TO_DOC : "11000", // 医生发送信息	CODE_GROUP : "11001", // 医生对群组发送信息	CODE_DOC_TO_PATIENT : "11002", // 医生对患者发送信息	CODE_FRIENDS : "11003", // 好友申请	CODE_SYS_GROUP : "10010", // 群组动态,退群	CODE_SYS_GROUP_DEL : "10011", // 群组动态,群解散	CODE_SYS_FRIENDS : "10020", // 医生同意好友申请后系统发起互相打招呼	CODE_PATIENT_TO_DOC : "12000", // 患者对医生发送信息	CODE_PHONE : "12001", // 预约回拨	CODE_FREEBACK : "13000", // 意见反馈	CODE_HEALTH_NEWS : "10001", // 健康报	CODE_REFERRAL : "13004", // 转诊助手	CODE_SYS_MESSAGE : "10002", // 系统公告	CODE_LOVE_WEEK_NEWS : "13001", // 爱心值周排名	CODE_LOVE_AWARD : "13002", // 爱心奖励	CODE_PHONE_WEEK_NEWS : "13003", // 电话诊室周报	CODE_HELP : "-9999" // 新手指导};//发送类型var ContentType = {	CONTENT_TEXT : 0,	CONTENT_MP3 : 1,	CONTENT_IMG : 2,	CONTENT_IMG_TEXT : 3,	CONTENT_RECOMMEND : 4};//通信类function AnImClass() {	this.appKey = 'drFnr1YojVjHrTfupuLDhppYLco7h6Ax';	this.AnImObj = null;}//初始化通信AnImClass.prototype.initEvent = function() {	AnImClass.prototype.AnImObj = new AnIM(			{				key : this.appKey,				onStatusChanged : function(isConnected, error) {//通信状态改变					if (!isConnected) {						ifConnecte();					}				},				onReceivedMessage : function(msg_id, message, from,						custome_data, timestamp) {//接收消息回调方法					if (Structure.tarClientId == from							&& $("#talking_box").css('display') == 'block') {						loadMessage(custome_data, msg_id, message, false,								timestampFormat(timestamp), "text", from);					} else {						showNewMessage(custome_data, message, from,								timestampFormat(timestamp));					}				},				onReceivedBinary : function(msg_id, fileType, from,						custome_data, timestamp) {//接收二进制消息回调方法					var url = "";					var message = "";					if (Structure.tarClientId == from&& $("#talking_box").css('display') == 'block') {						if (fileType == 1) {							url = AnImClass.prototype.AnImObj									.getBinaryResourceURL(msg_id, "acc",											"application/vnd.americandynamics.acc");							message = '<audio src="'									+ url									+ '"  controls="controls">您的浏览器不支持 audio 标签。</audio>';						} else {							url = AnImClass.prototype.AnImObj									.getBinaryResourceURL(msg_id, "jpg",											"image/jpg");							message = "<img src='" + url + "' style='width:"									+ imgSize + "' ondblclick=showFullImg('" +url+ "') />";						}						loadMessage(custome_data, msg_id, message, false,								timestampFormat(timestamp), "", from);					} else {						if (fileType == 1) {							message = "[语音]";						} else {							message = "[图片]";						}						showNewMessage(custome_data, message, from,								timestampFormat(timestamp));					}				},				onReceivedTopicMessage : function(msg_id, message, from,						topicId, cdata, timestamp) {//接收群消息回调方法					if (Structure.tarClientId == topicId							&& $("#talking_box").css('display') == 'block') {						loadMessage(cdata, msg_id, message, false,								timestampFormat(timestamp), "", topicId);					} else {						showNewMessage(cdata, message, topicId,								timestampFormat(timestamp));					}					memberInfos[topicId] = {						"data-id" : cdata.groupId,						"data-name" : cdata.groupName,						"data-clientId" : cdata.groupClientId,						"data-photoUri" : cdata.groupPhoto,						"data-sex" : "0"					};				},				onReceivedTopicBinary : function(msg_id, fileType, from,						topicId, cdata, timestamp) {//接收二进制群消息回调方法					var url = "";					var message = "";										if (Structure.tarClientId == topicId&& $("#talking_box").css('display') == 'block') {						if (fileType == 1) {							url = AnImClass.prototype.AnImObj									.getBinaryResourceURL(msg_id, "acc",											"application/vnd.americandynamics.acc");							message = '<audio src="'									+ url									+ '"  controls="controls">您的浏览器不支持 audio 标签。</audio>';						} else {							url = AnImClass.prototype.AnImObj									.getBinaryResourceURL(msg_id, "jpg",											"image/jpg");							message = "<img src='" + url + "' style='width:"									+ imgSize + "' ondblclick=showFullImg('" +url+ "') />";						}						loadMessage(cdata, msg_id, message, false,								timestampFormat(timestamp), "", topicId);					} else {						if (fileType == 1) {							message = "[语音]";						} else {							message = "[图片]";						}						showNewMessage(cdata, message, topicId,								timestampFormat(timestamp));					}					memberInfos[topicId] = {						"data-id" : cdata.groupId,						"data-name" : cdata.groupName,						"data-clientId" : cdata.groupClientId,						"data-photoUri" : cdata.groupPhoto,						"data-sex" : "0"					};				},				onMessageSent : function(error, msg_id) {//发送回调方法					$("#msg_" + msg_id).hide();					if (error) {						$("#msg_" + msg_id).empty();						$("#msg_" + msg_id).addClass("tipico tipico-err");					}				},				onReceivedReceiveACK : function(msg_id, from) {//发送确认回调方法				},				onReceivedReadACK : function(msg_id, from) {				},				onClientsRemovedFromTopic : function(event_id, topic_id,						parties, timestamp) {				},				onTopicRemoved : function(event_id, topic_id, timestamp) {//群组解散回调方法				},				onReceivedNotice : function(msg_id, message, from, topicId,						custome_data, timestamp) {//接收通知回调方法					//alert('接收通知回调方法');				}			});};//连接通信AnImClass.prototype.connect = function(clientId) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		AnImClass.prototype.AnImObj.connect(clientId);	}};//发送文本消息AnImClass.prototype.sendMessage = function(clientId, message, customData,		receiveAck) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		var msgId = "";				msgId = AnImClass.prototype.AnImObj.sendMessage(clientId, message,				customData, receiveAck);			var customeDataObj = $.parseJSON(customData);		if (msgId) {			$("#text_msg").val("");		}		loadMessage(customeDataObj, msgId, message, true, (new Date())				.format("yyyy-MM-dd hh:mm:ss"), "text", clientId);	}};//发送群组消息AnImClass.prototype.sendMessageToTopic = function(topicId, message, customData,		receiveAck) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		var msgId = AnImClass.prototype.AnImObj.sendMessageToTopic(topicId,				message, customData, receiveAck);		var customeDataObj = $.parseJSON(customData);		if (msgId) {			$("#text_msg").val("");		}		loadMessage(customeDataObj, msgId, message, true, (new Date())				.format("yyyy-MM-dd hh:mm:ss"), "text", topicId);	}};//获取私聊离线消息记录AnImClass.prototype.getOfflineHistory = function(limit) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		AnImClass.prototype.AnImObj.getOfflineHistory(myInfo.clientId, limit,				function(error, messages, leftCount) {					if (error) {						console.log("获取私聊离线消息记录出错:"+error);					} else {						for ( var i in messages) {							var message = messages[i];							var messageStr = message.message;							if (message.content_type != "text"									&& message.customData									&& message.customData.msgType == 1) {								messageStr = '[语音]';							} else if (message.content_type != "text"									&& message.customData									&& message.customData.msgType == 2) {								messageStr = "[图片]";							}							showNewMessage(message.customData, messageStr,									message.from,									timestampFormat(message.timestamp),									message.content_type, message.from);						}											}				});	}};//获取群聊离线消息记录AnImClass.prototype.getOfflineTopicHistory = function(limit) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		AnImClass.prototype.AnImObj.getOfflineTopicHistory(myInfo.clientId,				limit, "", function(error, messages, leftCount) {					if (error) {						console.log("获取群聊离线消息记录出错:"+error);					} else {						for ( var i in messages) {							var message = messages[i];							var messageStr = message.message;							if (message.content_type != "text"									&& message.customData									&& message.customData.msgType == 1) {								messageStr = '[语音]';							} else if (message.content_type != "text"									&& message.customData									&& message.customData.msgType == 2) {								messageStr = "[图片]";							}							showNewMessage(message.customData, messageStr,									message.topic_id,									timestampFormat(message.timestamp),									message.content_type, message.topic_id);						}											}				});	}};// 获取私聊历史消息记录AnImClass.prototype.getHistory = function(tarClientId, clientId, limit,		timestamp) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		AnImClass.prototype.AnImObj				.getHistory(						tarClientId,						clientId,						limit,						timestamp,						function(error, messages) {							if (error) {								console.log("获取私聊历史消息记录出错:"+error);							} else {								$(".loading_box").show();								$(".sec-main-con").html("");								for ( var i in messages) {									var message = messages[i];									var url = "";									var messageStr = message.message;									if (message.content_type != "text"											&& message.customData											&& message.customData.msgType == 1) {										url = AnImClass.prototype.AnImObj												.getBinaryResourceURL(														message.msg_id, "acc",														"application/vnd.americandynamics.acc");										messageStr = '<audio src="'												+ url												+ '"  controls="controls">您的浏览器不支持 audio 标签。</audio>';									} else if (message.content_type != "text"											&& message.customData											&& message.customData.msgType == 2) {										url = AnImClass.prototype.AnImObj												.getBinaryResourceURL(														message.msg_id, "jpg",														"image/jpg");										messageStr = "<img src='" + url												+ "' class='dbimg' style='width:" + imgSize												+ "' />";									}									if (i == 0) {										showMsgListMessage(												message,												messageStr,												false,												timestampFormat(message.timestamp));									}									if (i == messages.length - 1) {										hisDateTime = message.timestamp;									}									loadHistoryMessage(message.customData,											message.msg_id, messageStr,											message.from == myInfo.clientId,											timestampFormat(message.timestamp),											message.content_type, message.from);								}								$(".dbimg").dblclick(function(){																		    								    $('#show-full-img > img').attr("src",$(this).attr("src"));								    var contentImg=$('#show-full-img').get(0);								    								   // var  contentImg='<img src="'+$(this).attr("src")+'">';								    var d = art.dialog({									    title: '图片',									    padding: '1px 1px',										    lock: true,									    content: contentImg										});										$('.aui_content').niceScroll({cursorborder:"",cursorcolor:"#cccdd1"});																				d.show();								    								    								  });								setTimeout(scrollBottom, 100);								$(".loading_box").hide();							}						});	}};AnImClass.prototype.getHistory2 = function(tarClientId, clientId, limit,timestamp) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		AnImClass.prototype.AnImObj.getHistory(tarClientId,clientId,limit,timestamp,function(error, messages) {							if (error) {								console.log(error);							} else {																for ( var i in messages) {																		var message = messages[i];									var url = "";									var messageStr = message.message;									if (message.content_type != "text" && message.customData											&& message.customData.msgType == 1) {										messageStr = '[语音]';									} else if (message.content_type != "text" && message.customData											&& message.customData.msgType == 2) {										messageStr = '[图片]';									}									if (message.customData.msgType == ContentType.CONTENT_IMG											&& message.content_type == "text") {										messageStr = "[图片]";									} else if (message.customData.msgType == 0) {										messageStr = YiHu.Util.htmlspecialchars(messageStr).replace(regPlace, regCallback2);									}																		var NowTime=new Date().getTime();									if (NowTime-message.timestamp<=1000*60*60*24*7){																			showOldMessage(message.customData, messageStr,tarClientId,timestampFormat(message.timestamp),message.content_type);																			}																	}													}						});	}};// 获取群聊历史消息记录AnImClass.prototype.getTopicHistory2 = function(topicId, clientId, limit,timestamp) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {				AnImClass.prototype.AnImObj				.getTopicHistory(						topicId,						limit,						timestamp,						clientId,						function(error, messages) {							if (error) {								console.log(error);							} else {																for ( var i in messages) {									var message = messages[i];									var url = "";									var messageStr = message.message;									if (message.content_type != "text" && message.customData											&& message.customData.msgType == 1) {										messageStr = '[语音]';									} else if (message.content_type != "text" && message.customData											&& message.customData.msgType == 2) {										messageStr = '[图片]';									}									if (message.customData.msgType == ContentType.CONTENT_IMG											&& message.content_type == "text") {										messageStr = "[图片]";									} else if (message.customData.msgType == 0) {										messageStr = YiHu.Util.htmlspecialchars(messageStr).replace(regPlace, regCallback2);									}																		var NowTime=new Date().getTime();									if (NowTime-message.timestamp<=1000*60*60*24*7){																			showOldMessage(message.customData, messageStr,topicId,timestampFormat(message.timestamp),message.content_type);																			}								}								}						});					}	};//显示历史消息function showOldMessage(customData, message, from, dateStr, dataType) {		var memberInfo = memberInfos[from];	if(!memberInfo){		return;	}		message = message.replace(/\n/g, "<br/>");	var $linewMsg = $("#linewMsg_" + from);		if ($linewMsg.length > 0) {		return;	}	var isGroup = false;		if (customData.groupId && customData.groupId != "") {		isGroup = true;	}	var photoUri = memberInfo["data-photoUri"];	photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";	var str = [			'<li class="boss-user" id="linewMsg_' + from + '" data-clientId="'					+ from + '" '					+ (isGroup ? "data-group='1'" : "data-group='0'") + '>',			"<a href=\"javascript:;\" onclick=\"showNewChat('" + from + "',"					+ (isGroup ? true : false) + ");\" >",			' <div class="boss-user-face"><img class=\"c-images-block\" src="'					+ photoUri + '"/></div>',					'<div class="boss-user-name c-nowrap c-f14 c-333"> <p class="new-c-nowrap c-f14 c-333">'					+ memberInfo["data-name"]					+ '</p>',			'<p class="c-nowrap c-f12 c-909090">'					+ (isGroup ? customData.sourceName + ":"							+ message.replace(regPlace, regCallback2) : message							.replace(regPlace, regCallback2)) + '</p>',			'</div>',			' <div class="boss-user-time c-position-a">'					+ YiHu.Util.dataTimeToStr(dateStr) + '</div>',												'</a>',			'</li>' ];		$("#msgUl").append(str.join(''));	$("#newMsg_" + from).hide();	//sumUnreadCount();}// 获取群聊历史消息记录AnImClass.prototype.getTopicHistory = function(topicId, limit, timestamp,		clientId) {	if (AnImClass.prototype.AnImObj == null) {		console.log("未注册通信");	} else {		AnImClass.prototype.AnImObj				.getTopicHistory(						topicId,						limit,						timestamp,						clientId,						function(error, messages) {							if (error) {								console.log("获取群聊历史消息记录出错:"+error);							} else {								$(".loading_box").show();																$(".sec-main-con").html("");								for ( var i in messages) {									var message = messages[i];									var url = "";									var messageStr = message.message;									if (message.content_type != "text"											&& message.customData											&& message.customData.msgType == 1) {										url = AnImClass.prototype.AnImObj												.getBinaryResourceURL(														message.msg_id, "acc",														"application/vnd.americandynamics.acc");										messageStr = '<audio src="'												+ url												+ '"  controls="controls">您的浏览器不支持 audio 标签。</audio>';									} else if (message.content_type != "text"											&& message.customData											&& message.customData.msgType == 2) {										url = AnImClass.prototype.AnImObj												.getBinaryResourceURL(														message.msg_id, "jpg",														"image/jpg");										messageStr = "<img src='" + url												+ "' class='dbimg' style='width:" + imgSize												+ "' />";									}									if (i == 0) {										showMsgListMessage(												message,												messageStr,												true,												timestampFormat(message.timestamp));									}									if (i == messages.length - 1) {										hisDateTime = message.timestamp;									}									loadHistoryMessage(message.customData,											message.msg_id, messageStr,											message.from == myInfo.clientId,											timestampFormat(message.timestamp),											message.content_type,											message.topicId);								}									$(".dbimg").dblclick(function(){																		    								    $('#show-full-img > img').attr("src",$(this).attr("src"));								    var contentImg=$('#show-full-img').get(0);								    								   // var  contentImg='<img src="'+$(this).attr("src")+'">';								    var d = art.dialog({									    title: '图片',									    padding: '1px 1px',										    lock: true,									    content: contentImg										});										$('.aui_content').niceScroll({cursorborder:"",cursorcolor:"#cccdd1"});																				d.show();								    								    								  });								setTimeout(scrollBottom, 100);								$(".loading_box").hide();							}						});	}};function showMsgListMessage(message, messageStr, isGroup, dateStr) {	//                        $("#linewMsg_" + Structure.tarClientId + ">.fl>.hidden>.a-msg-time").html(YiHu.Util.dataTimeToStr(timestampFormat(message.timestamp)));	var msg = messageStr;	if (message.content_type != "text" && message.customData			&& message.customData.msgType == 1) {		msg = '[语音]';	} else if (message.content_type != "text" && message.customData			&& message.customData.msgType == 2) {		msg = '[图片]';	}	if (message.customData.msgType == ContentType.CONTENT_IMG			&& message.content_type == "text") {		msg = "[图片]";	} else if (message.customData.msgType == 0) {		msg = YiHu.Util.htmlspecialchars(msg).replace(regPlace, regCallback2);	}	$(			"#linewMsg_" + Structure.tarClientId					+ ">a>.boss-user-name>.c-nowrap.c-f12.c-909090").html(			(isGroup ? message.customData.sourceName + ":" + msg : msg));	$("#linewMsg_" + Structure.tarClientId + ">a>.boss-user-time.c-position-a")			.html(YiHu.Util.dataTimeToStr(dateStr));}function showMsgMessage(content_type, customData, messageStr, isGroup, from,		dateStr) {	//                        $("#linewMsg_" + Structure.tarClientId + ">.fl>.hidden>.a-msg-time").html(YiHu.Util.dataTimeToStr(timestampFormat(message.timestamp)));	var msg = messageStr;	if (content_type != "text" && customData && customData.msgType == 1) {		msg = '[语音]';	} else if (content_type != "text" && customData && customData.msgType == 2) {		msg = '[图片]';	}	if (customData.msgType == ContentType.CONTENT_IMG && content_type == "text") {		msg = "[图片]";	} else if (customData.msgType == 0) {		msg = YiHu.Util.htmlspecialchars(msg).replace(regPlace, regCallback2);	}	$("#linewMsg_" + from + ">a>.boss-user-name>.c-nowrap.c-f12.c-909090")			.html((isGroup ? customData.sourceName + ":" + msg : msg));	$("#linewMsg_" + Structure.tarClientId + ">a>.boss-user-time.c-position-a")			.html(YiHu.Util.dataTimeToStr(dateStr));}//加载信息function loadMessage(customData, msgId, message, isMy, dateStr, contentType,		from) {		showMsgMessage(contentType, customData, message,			(customData.groupId && customData.groupId != ""), from, dateStr);	if (customData.msgType == ContentType.CONTENT_IMG && contentType == "text") {		message = "<img src='" + message + "'  style='width:50%' />";	} else if (customData.msgType == 0) {		message = YiHu.Util.htmlspecialchars(message);	}	if (!message) {		message = "";	}	message = message.replace(/\n/g, "<br/>");	var showTime = false;	if (!oldDatetime) {		oldDatetime = new Date();		showTime = true;	}	if (oldDatetime && YiHu.Util.addMinutes(oldDatetime, 5) < new Date()) {		oldDatetime = new Date();		showTime = true;	}	var photoUri = customData.uri;	photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";	var str = [			'<div class="t-center">',			showTime ? '<p class="msg-time">'					+ YiHu.Util.dataTimeToStr(dateStr) + '</p></div>' : "",			'<div class="' + (isMy ? 'msg-mine' : 'msg-other') + '">',			'<div class="user-avatar"><img src="'					+ photoUri					+ '" alt="" style="width:40px;height:40px;border-radius:20px 20px" /></div>',			' <div class="' + (isMy ? 'fr' : 'fl') + '">',			'<div class="user-name">' + customData.sourceName + ' </div>',			'<div class="msg-box">',			'<p>' + message.replace(regPlace, regCallback) + '</p>',			'<em class="msg-box-arr"><i></i></em>',			(isMy ? '<i class="tipico" id="msg_' + msgId					+ '"><img src="images/022.gif"></i>' : '')					+ '</div>', '</div></div>' ];	$(".sec-main-con").append(str.join(''));		setTimeout(scrollBottom, 100);	// loadErrorImg();}//加载历史信息function loadHistoryMessage(customData, msgId, message, isMy, dateStr,		contentType, from) {	if (customData.msgType == ContentType.CONTENT_IMG && contentType == "text") {		message = "<img src='" + message + "'  style='width:100%' />";	} else if (customData.msgType == 0) {		message = YiHu.Util.htmlspecialchars(message);	}	if (!message) {		message = "";	}	message = message.replace(/\n/g, "<br/>");	var photoUri = customData.uri;	photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";	var str = [			'<div class="t-center" style="padding-top:50px;">',			'<p class="msg-time">' + YiHu.Util.dataTimeToStr(dateStr)					+ '</p></div>',			'<div class="' + (isMy ? 'msg-mine' : 'msg-other') + '">',			'<div class="user-avatar"><img src="'					+ photoUri					+ '" alt="" style="width:40px;height:40px;border-radius:20px 20px" /></div>',			' <div class="' + (isMy ? 'fr' : 'fl') + '">',			'<div class="user-name">' + customData.sourceName + ' </div>',			'<div class="msg-box">',			'<p>' + message.replace(regPlace, regCallback) + '</p>',			'<em class="msg-box-arr"><i></i></em>', '</div>', '</div></div>' ];	$(".sec-main-con").prepend(str.join(''));	//window.frames['iframe-im-if'].contentWindow.loadMessage(str.join(''));	}//显示新消息function showNewMessage(customData, message, from, dateStr, dataType) {	if (customData.msgType == ContentType.CONTENT_IMG && dataType == "text") {		message = "<img src='" + message + "' style='width:" + imgSize + "' />";	} else if (customData.msgType == 0) {		message = YiHu.Util.htmlspecialchars(message);	}	var memberInfo = memberInfos[from];	if (!memberInfo) {		if (customData.groupId && customData.groupId != "") {			memberInfos[from] = {				"data-id" : customData.groupId,				"data-name" : customData.groupName,				"data-clientId" : customData.groupClientId,				"data-photoUri" : customData.groupPhoto,				"data-sex" : "0"			};		} else {			memberInfos[from] = {				"data-id" : customData.sourceId,				"data-name" : customData.sourceName,				"data-clientId" : from,				"data-photoUri" : customData.uri,				"data-sex" : customData.sex			};		}	}	message = message.replace(/\n/g, "<br/>");		var $newMsg = $("#newMsg_" + from);	var msgCount = 1;		if ($newMsg.length > 0) {		var oldMsgCount = parseInt($newMsg.html());		msgCount += oldMsgCount;		if (msgCount > 99)			msgCount = 99;		$("#linewMsg_" + from).detach();	} else {		newMsgBodyCount += 1;	}	if($("#linewMsg_" + from).length > 0){		$("#linewMsg_" + from).detach();	}			var isGroup = false;		if (customData.groupId && customData.groupId != "") {		isGroup = true;	}	var photoUri = isGroup ? customData.groupPhoto : customData.uri;	photoUri = (photoUri && photoUri != "") ? photoUri : "images/face.png";	var str = [			'<li class="boss-user" id="linewMsg_' + from + '" data-clientId="'					+ from + '" '					+ (isGroup ? "data-group='1'" : "data-group='0'") + '>',			"<a href=\"javascript:;\" onclick=\"showNewChat('" + from + "',"					+ (isGroup ? true : false) + ");\" >",			' <div class="boss-user-face"><img class=\"c-images-block\" src="'					+ photoUri + '"/></div>',					'<div class="boss-user-name c-nowrap c-f14 c-333"> <p class="new-c-nowrap c-f14 c-333">'					+ (isGroup ? customData.groupName : customData.sourceName)					+ '</p>',			'<p class="c-nowrap c-f12 c-909090">'					+ (isGroup ? customData.sourceName + ":"							+ message.replace(regPlace, regCallback2) : message							.replace(regPlace, regCallback2)) + '</p>',			'</div>',			' <div class="boss-user-time c-position-a">'					+ YiHu.Util.dataTimeToStr(dateStr) + '</div>',												'<div class="boss-user-number c-position-a" id="newMsg_' + from					+ '">' + msgCount + '</div>', '</a>',			'</li>' ];		$("#msgUl").prepend(str.join(''));	sumUnreadCount();}//计算未读数据function sumUnreadCount() {	unReadCount = 0;	$(".boss-user-number.c-position-a").each(function(index, element) {		unReadCount += parseInt($(element).html());		if ($(".boss-user-number.c-position-a").length - 1 == index) {			if (unReadCount > 0) {				$("#im_count").html(unReadCount);				$("#im_count").show();			}		}	});}function scrollBottom() {		$(".sec_scroll").scrollTop(10000);}//加载更多聊天记录function loadMoreMessage() {	if (Structure.isGroup) {		anImClass.getTopicHistory(Structure.tarClientId, myInfo.clientId, 30,				hisDateTime);	} else {		anImClass.getHistory(Structure.tarClientId, myInfo.clientId, 30,				hisDateTime);	}}function showNewChat(clientId, isGroup) {	if(clientId&&clientId!=''){		if (clientId == myInfo.clientId) {        showMsg("不能和自己聊天!!!");        $(".loading_box").hide();        return false;    }				var clickObj = memberInfos[clientId];		var clickMsgCount = parseInt($("#newMsg_" + clientId).html());		if (!clickMsgCount){						clickMsgCount=0;		}				if (clickObj["data-clientId"] != Structure.tarClientId) {			//event.stopPropagation();			Structure.tarClientId = clickObj["data-clientId"];			Structure.cName = clickObj["data-name"];			Structure.isGroup = isGroup;			Structure.id = clickObj["data-id"];			Structure.photoUri = clickObj["data-photoUri"];			Structure.photoUri = Structure.photoUri == "" ? "images/face.png"					: Structure.photoUri;			Structure.sex = clickObj["data-sex"];			$(".section-header.clearfix > h4").html(Structure.cName);			$("#talkingID").val(Structure.id);			$("#clientId").val(Structure.tarClientId);   			$("#talking_box").show();			$('#iframe-im').show();			$(".sec-main-con").html("");			$("#text_msg").val("");			$('#text_msg').focus(); 			if (clickMsgCount > 0) {					$("#newMsg_" + clientId).html('0').hide();				$("#newMsg_" + clientId).detach();				newMsgBodyCount -= 1;			}						sumUnreadCount();			if (newMsgBodyCount <= 0) {				newMsgBodyCount = 0;				$("#im_count").hide();				//$(".boss-user-number.c-position-a").remove();			}			if (isGroup) {				$("#isGroup").val(1);				anImClass.getTopicHistory(Structure.tarClientId,10 + parseInt(clickMsgCount), "", myInfo.clientId);			} else{				$("#isGroup").val(0);				anImClass.getHistory(Structure.tarClientId, myInfo.clientId,10 + parseInt(clickMsgCount), "");			}		}	}}var newPushMsgIds = '';var limitBody = 1;var newAppMsgIds = '';var limitAppBody = 1;//加载未读推送消息function loadPushMsgList(frist) {	$.ajax({		url : "PushMsgListAction/getPushMsgList",		dataType : "json",		data : {			readStatus : 1		},		type : 'POST',		success : function(msg) {			if (msg) {				if (msg.Code == 10000) {					//if (msg.Result && msg.Result != '') {						var data = msg.Result;						var sysMsgCount = 0;						var appMsgCount = 0;						var $newMsg = $("#newMsg_sysMessage");						if ($newMsg.length > 0) {							//$("#linewMsg_sysMessage").detach();							var dateStr = '';							var content;							var title = '';							var dateStrApp = '';							var contentApp;							var titleApp = '';							var fFlag=0;							var gFlag=0;							newPushMsgIds = '';							newAppMsgIds = '';																																										for ( var i = 0; i < data.length; i++) {								if (data[i].operCode&& data[i].operCode != 11003) {									if(data[i].operCode==10020){										fFlag=1;									}									if(data[i].operCode==10010||data[i].operCode==10011){										gFlag=1;									}									dateStr = timestampFormat(data[i]._msg.insertTimeMillis);									content = data[i].content;									if (typeof (content) == 'object') {										if (data[i].content.describe) {											content = data[i].content.describe;										} else {											content = '';										}									} else {										content = (content && content != "") ? content	: "";									}									title = data[i].title;									title = (title && title != "") ? title: "";									newPushMsgIds += data[i].msgId+ ",";									sysMsgCount++;									if (sysMsgCount > 99)										sysMsgCount = 99;								}/*else if(data[i].operCode == 13006){									dateStrApp = timestampFormat(data[i]._msg.insertTimeMillis);									contentApp = data[i].content;									if (typeof (contentApp) == 'object') {										if (data[i].content.describe) {											contentApp = data[i].content.describe;										} else {											contentApp = '';										}									} else {										contentApp = (contentApp && contentApp != "") ? contentApp : "";									}									titleApp = data[i].title;									titleApp = (titleApp && titleApp != "") ? titleApp: "";									newAppMsgIds += data[i].msgId+ ",";																											appMsgCount++;									if (appMsgCount > 99)										appMsgCount = 99;								}*/							}														var appObj = msg.appArray; 														for (var p in appObj) { 							    // p就是得到的key值 							  							   var  appMessage=appObj[p];							   var  appName='';							   dateStrApp = timestampFormat(appMessage[0]._msg.insertTimeMillis);									contentApp = appMessage[0].content;																		if (typeof (contentApp) == 'object') {										if (appMessage[0].content.describe) {																						contentApp = appMessage[0].content.describe;																																											} else {											contentApp = '';										}																				appName=appMessage[0].content.appName;									} else {										contentApp = (contentApp && contentApp != "") ? contentApp : "";									}									titleApp = appMessage[0].title;																		titleApp = (titleApp && titleApp != "") ? titleApp: "";									//newAppMsgIds += appMessage[0].msgId+ ",";											appMsgCount	=	appObj[p].length;														//alert(appMsgCount);								//	if (appMsgCount > 99)								//		appMsgCount = 99;							   														   							var $newAppMsg = $("#newAppMsg_" + p);									if ($newAppMsg.length > 0) {								//var oldMsgCount = parseInt($newAppMsg.html());								//appMsgCount += oldMsgCount;								if (appMsgCount > 99)									appMsgCount = 99;								$("#lineAppMsg_" + p).detach();															} else {								newMsgBodyCount += 1;							}							if($("#lineAppMsg_" + p).length > 0){																$("#lineAppMsg_" + p).detach();							}																				var str = [									'<li class="boss-user" id="lineAppMsg_' + p +  '">',									"<a href=\"javascript:;\" onclick=\"showAppMessage('" + p +  "');\" >",									' <div class="boss-user-face"><img class=\"c-images-block\" src="images/dbsx.png"/></div>',											'<div class="boss-user-name"> <p class="new-c-nowrap c-f13 c-333">'+appName+'-待办工作'+ '</p>',									'<p class="c-nowrap c-f12 c-909090">'+titleApp+':'+ contentApp + '</p>',									'</div>',									'<div class="boss-user-time c-position-a">'+ YiHu.Util.dataTimeToStr(dateStrApp) + '</div>',																		'<div class="boss-user-number c-position-a" id="newAppMsg_' + p+ '">' + appMsgCount + '</div>',									'</a>',									'</li>' ];														$("#msgUl").prepend(str.join(''));							sumUnreadCount();							   							   							    						}  							if (sysMsgCount > 0) {								$("#newMsg_sysMessage").html(sysMsgCount).show();								$("#linewMsg_sysMessage >a > .boss-user-time.c-position-a").html(YiHu.Util.dataTimeToStr(dateStr));								$("#title_sysMessage").html(title);								$("#content_sysMessage").html(content);								newMsgBodyCount += limitBody;								limitBody = 0;							}						/*								if (appMsgCount > 0) {								$("#newMsg_appMessage").html(appMsgCount).show();								$("#linewMsg_appMessage >a > .boss-user-time.c-position-a").html(YiHu.Util.dataTimeToStr(dateStrApp));								$("#title_appMessage").html(titleApp);								$("#content_appMessage").html(contentApp);								newMsgBodyCount += limitAppBody;								limitAppBody = 0;							}*/														if(frist!=1){																if(gFlag==1){									loadGroups();								}								if(fFlag==1){									loadFriends();								}							}						}												sumUnreadCount();				//	}				} else if (msg.Code == -8000) {					//showHideMsg(data.Message, 3);					window.location.href = "jump.jsp";				} else {					//showHideMsg("加载未读推送消息失败", 1);				}			} else {				//showHideMsg("加载未读推送消息失败", 1);			}		},		error : function() {			//showHideMsg("加载未读推送消息失败", 1);		}	});}//加载好友邀请中列表信息function loadFriendInvite() {	$.ajax({		url : "UserFriendInvite/queryFriendInviteList",		dataType : "json",		type : 'POST',		success : function(msg) {			if (msg) {				if (msg.Code == 10000) {					var $newMsg = $("#newMsg_VMessage");					if ($newMsg.length > 0) {						var clickMsgCount = parseInt($(								"#newMsg_VMessage").html());						if (clickMsgCount > 0) {							$("#newMsg_VMessage").html('0').hide();							newMsgBodyCount -= 1;						}						sumUnreadCount();						if (newMsgBodyCount <= 0) {							newMsgBodyCount = 0;							$("#im_count").hide();							//$(".boss-user-number.c-position-a").remove();						}						$("#linewMsg_VMessage").detach();					}					if (msg.Result && msg.Result != '') {						var data = msg.Result;						var sysMsgCount = 0;						var VMessageCount = 0;						var str = '';						for ( var i = 0; i < data.length; i++) {							var photoUri = data[i].photoUri;							photoUri = (photoUri && photoUri != "") ? photoUri									: "images/face.png";							var dateStr = data[i].updateTime;							VMessageCount++;							if (VMessageCount > 99)								VMessageCount = 99;							str = [									'<li class="boss-user" id="linewMsg_VMessage">',									'<a href=\"javascript:;\" onclick=\"showVMessage();\">',									'<div class="boss-user-face"><img class=\"c-images-block\" src="'											+ photoUri + '"/></div>',									'<div class="boss-user-name c-nowrap c-f14 c-333"> <p class="c-nowrap c-f14 c-333">'											+ '您有一条验证消息' + '</p>',									'<p class="c-nowrap c-f12 c-909090">'											+ data[i].userName											+ '请求添加您为好友' + '</p>',									'</div>',									'<div class="boss-user-time c-position-a">'											+ YiHu.Util													.dataTimeToStr(dateStr)											+ '</div>',									'<div class="boss-user-number c-position-a" id="newMsg_VMessage">'											+ VMessageCount + '</div>',									'</a></li>' ];						}						if (str != '') {															newMsgBodyCount += 1;														$("#msgUl").prepend(str.join(''));						}												sumUnreadCount();					}				} else if (msg.Code == -8000) {					//showHideMsg(data.Message, 3);					window.location.href = "jump.jsp";				} else {					//showHideMsg("加载好友邀请中列表信息失败", 1);				}			} else {				//showHideMsg("加载好友邀请中列表信息失败", 1);			}		},		error : function() {			//showHideMsg("加载好友邀请中列表信息失败", 1);		}	});}function showVMessage() {	$('#iframe-userInfo').attr("src", "");	showIframe('verificationMessage.html');}function showSysMessage() {	var clickMsgCount = parseInt($("#newMsg_sysMessage").html());	if (clickMsgCount > 0) {		$("#newMsg_sysMessage").html('0').hide();		newMsgBodyCount -= 1;		limitBody = 1;	}	sumUnreadCount();	if (newMsgBodyCount <= 0) {		newMsgBodyCount = 0;		$("#im_count").hide();		//$(".boss-user-number.c-position-a").remove();	}	$('#iframe-userInfo').attr("src", "");	showIframe('sysMessage.html');}function showAppMessage(id) {	var clickMsgCount = parseInt($("#newAppMsg_"+id).html());	if (clickMsgCount > 0) {		$("#newAppMsg_"+id).html('0').hide();		newMsgBodyCount -= 1;		//limitAppBody = 1;	}	sumUnreadCount();	if (newMsgBodyCount <= 0) {		newMsgBodyCount = 0;		$("#im_count").hide();		//$(".boss-user-number.c-position-a").remove();	}	var src='appMessage.html?appId='+id;	$('#iframe-userInfo').attr("src", "");	showIframe(src);}function showFullImg(url){		$('#show-full-img > img').attr("src",url);  var contentImg=$('#show-full-img').get(0);   // var  contentImg='<img src="'+$(this).attr("src")+'">';  var d = art.dialog({  	title: '图片',        padding: '1px 1px',	    lock: true,    content: contentImg	});	$('.aui_content').niceScroll({cursorborder:"",cursorcolor:"#cccdd1"});		d.show();	}function ifConnecte() {	art.dialog({		lock : false,		artIcon : 'ask',		opacity : 0.4,		time: 5,			width : '15%',		height: '10%',			title : '提示',		content : '已经在其他地方登入,IM会话已断开(您如果还想继续进行IM聊天,请重新登入系统)',		left: '95%',				// X轴坐标		top: '100%', 				// Y轴坐标		init: function() {			$(".aui_close").hide();		}	});	}
 |