Commit ed85262c by 施宇

1111

parent 7ab8c457
Showing with 20 additions and 3 deletions
...@@ -8,16 +8,17 @@ $(function () { ...@@ -8,16 +8,17 @@ $(function () {
templateObj: JSON.parse(Util.getCookie('template') || "{}"), templateObj: JSON.parse(Util.getCookie('template') || "{}"),
customerText: Util.getCookie('customer') || "", customerText: Util.getCookie('customer') || "",
isLoginSuccess: false, isLoginSuccess: false,
chatList: [],
img: "", img: "",
name: "", name: "",
id: "", id: "",
init: function () { init: function () {
if(this.ieFun()){ if (this.ieFun()) {
this.getUserInfo(); this.getUserInfo();
this.connection(); this.connection();
this.connListen(); this.connListen();
this.bindFunction(); this.bindFunction();
}else{ } else {
layer.open({ layer.open({
title: '提示', title: '提示',
content: '浏览器不兼容聊天系统,建议使用其他浏览器!' content: '浏览器不兼容聊天系统,建议使用其他浏览器!'
...@@ -57,6 +58,9 @@ $(function () { ...@@ -57,6 +58,9 @@ $(function () {
if (res.errcode === 0) { if (res.errcode === 0) {
self.rendChatSection(res.data); self.rendChatSection(res.data);
self.login(name, password); self.login(name, password);
for (var i = 0; i < res.data.length; i++) {
self.chatList.push(res.data[i].im_username)
}
} else { } else {
layer.msg('获取历史纪录失败'); layer.msg('获取历史纪录失败');
self.deleteCookie() self.deleteCookie()
...@@ -229,7 +233,8 @@ $(function () { ...@@ -229,7 +233,8 @@ $(function () {
}, },
ieFun: function () { ieFun: function () {
if (navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE8.0" || navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE9.0")) { if (navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE8.0" || navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE9.0")) {
return false}else{ return false
} else {
return true return true
} }
}, },
...@@ -505,8 +510,11 @@ $(function () { ...@@ -505,8 +510,11 @@ $(function () {
touserid: message.ext.touserid touserid: message.ext.touserid
}, false); }, false);
if (self.customerNum == self.defaultName) { if (self.customerNum == self.defaultName) {
var index = self.chatList.indexOf(message.from);
if (index == -1) {
self.addChatMember(message.ext.id) self.addChatMember(message.ext.id)
} }
}
}, //收到文本消息; }, //收到文本消息;
onEmojiMessage: function (message) { onEmojiMessage: function (message) {
self.receiveData(3, { self.receiveData(3, {
...@@ -518,8 +526,11 @@ $(function () { ...@@ -518,8 +526,11 @@ $(function () {
touserid: message.ext.touserid touserid: message.ext.touserid
}, false); }, false);
if (self.customerNum == self.defaultName) { if (self.customerNum == self.defaultName) {
var index = self.chatList.indexOf(message.from);
if (index == -1) {
self.addChatMember(message.ext.id) self.addChatMember(message.ext.id)
} }
}
}, //收到表情消息; }, //收到表情消息;
onCmdMessage: function (message) { onCmdMessage: function (message) {
...@@ -555,8 +566,11 @@ $(function () { ...@@ -555,8 +566,11 @@ $(function () {
touserid: message.ext.touserid touserid: message.ext.touserid
}, false); }, false);
if (self.customerNum == self.defaultName) { if (self.customerNum == self.defaultName) {
var index = self.chatList.indexOf(message.from);
if (index == -1) {
self.addChatMember(message.ext.id) self.addChatMember(message.ext.id)
} }
}
}; };
options.onFileDownloadError = function () { options.onFileDownloadError = function () {
// 图片下载失败 // 图片下载失败
...@@ -704,7 +718,10 @@ $(function () { ...@@ -704,7 +718,10 @@ $(function () {
action: "template", action: "template",
ext: params, ext: params,
success: function () { success: function () {
var index = self.chatList.indexOf(userId);
if (index == -1) {
self.addChatMember(templateObj.targetId); self.addChatMember(templateObj.targetId);
}
$('#' + userId).find('.notice_item_content').append(self.messageHtml(1, $('#' + userId).find('.notice_item_content').append(self.messageHtml(1,
params, true)); params, true));
var imgLen = $('#' + userId).find('img').length; var imgLen = $('#' + userId).find('img').length;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment