Commit 31eb419b by 施宇

11

parent 9b8b1a50
Showing with 56 additions and 27 deletions
...@@ -510,6 +510,28 @@ $(function () { ...@@ -510,6 +510,28 @@ $(function () {
self.singleChat(); self.singleChat();
}, },
onTextMessage: function (message) { onTextMessage: function (message) {
if (message.ext.isTemplate) { //模板消息
self.receiveData(1, {
name: self.judgeCustomer(message).name,
id: message.ext.id,
img: self.judgeCustomer(message).img,
from: message.from,
type: message.ext.type,
price: message.ext.price,
goodImage: message.ext.goodImage,
brand: message.ext.brand,
hq: message.ext.hq,
num: message.ext.num,
hq: message.ext.hq,
time: message.ext.time,
touserid: message.ext.touserid
}, true);
var index = self.chatList.indexOf(message.from);
if (index == -1) {
self.addChatMember(message.ext.id)
}
} else { //普通消息
self.receiveData(1, { self.receiveData(1, {
name: self.judgeCustomer(message).name, name: self.judgeCustomer(message).name,
id: message.ext.id, id: message.ext.id,
...@@ -524,6 +546,8 @@ $(function () { ...@@ -524,6 +546,8 @@ $(function () {
self.addChatMember(message.ext.id) self.addChatMember(message.ext.id)
} }
} }
}
}, //收到文本消息; }, //收到文本消息;
onEmojiMessage: function (message) { onEmojiMessage: function (message) {
self.receiveData(3, { self.receiveData(3, {
...@@ -542,24 +566,24 @@ $(function () { ...@@ -542,24 +566,24 @@ $(function () {
} }
}, //收到表情消息; }, //收到表情消息;
onCmdMessage: function (message) { // onCmdMessage: function (message) {
self.receiveData(1, { // self.receiveData(1, {
name: self.judgeCustomer(message).name, // name: self.judgeCustomer(message).name,
id: message.ext.id, // id: message.ext.id,
img: self.judgeCustomer(message).img, // img: self.judgeCustomer(message).img,
from: message.from, // from: message.from,
type: message.ext.type, // type: message.ext.type,
price: message.ext.price, // price: message.ext.price,
goodImage: message.ext.goodImage, // goodImage: message.ext.goodImage,
brand: message.ext.brand, // brand: message.ext.brand,
hq: message.ext.hq, // hq: message.ext.hq,
num: message.ext.num, // num: message.ext.num,
hq: message.ext.hq, // hq: message.ext.hq,
time: message.ext.time, // time: message.ext.time,
touserid: message.ext.touserid // touserid: message.ext.touserid
}, true); // }, true);
self.addChatMember(message.ext.id) // self.addChatMember(message.ext.id)
}, //收到命令消息; // }, //收到命令消息;
onPictureMessage: function (message) { onPictureMessage: function (message) {
var options = { var options = {
url: message.url url: message.url
...@@ -728,7 +752,7 @@ $(function () { ...@@ -728,7 +752,7 @@ $(function () {
// console.log(msg.body) // console.log(msg.body)
this.conn.send(msg.body); this.conn.send(msg.body);
}, },
sendCmd: function (templateObj) { sendCmd: function (templateObj) {//发送模板
var self = this; var self = this;
var userId = $('.notice_left ').find('.active').attr('userid'); var userId = $('.notice_left ').find('.active').attr('userid');
var touserid = $('.notice_left ').find('.active').attr('touserid'); var touserid = $('.notice_left ').find('.active').attr('touserid');
...@@ -736,7 +760,7 @@ $(function () { ...@@ -736,7 +760,7 @@ $(function () {
var img = $('.notice_left ').find('.active').attr('img'); var img = $('.notice_left ').find('.active').attr('img');
var status = $('.notice_left ').find('.active').attr('status'); //0表示客服,1表示正常 ,2不是拉黑 var status = $('.notice_left ').find('.active').attr('status'); //0表示客服,1表示正常 ,2不是拉黑
var id = this.conn.getUniqueId(); var id = this.conn.getUniqueId();
var msg = new WebIM.default.message('cmd', id); var msg = new WebIM.default.message('txt', id);
var params = $.extend({}, templateObj, { var params = $.extend({}, templateObj, {
timer: self.curentTime(), timer: self.curentTime(),
name: self.name, name: self.name,
...@@ -744,17 +768,21 @@ $(function () { ...@@ -744,17 +768,21 @@ $(function () {
img: self.img, img: self.img,
touserid: touserid, touserid: touserid,
name1: name, name1: name,
img1: img img1: img,
isTemplate:'1'
}); });
delete params.targetId;
delete params.userImg;
delete params.userName;
console.log(params)
if (status == 2) { if (status == 2) {
layer.msg('该用户已被拉黑'); layer.msg('该用户已被拉黑');
self.scrollToTop(userId) self.scrollToTop(userId)
return; return;
} }
msg.set({ msg.set({
msg: 'template', msg: '',
to: userId, to: userId,
action: "template",
ext: params, ext: params,
success: function () { success: function () {
var index = self.chatList.indexOf(userId); var index = self.chatList.indexOf(userId);
...@@ -769,7 +797,7 @@ $(function () { ...@@ -769,7 +797,7 @@ $(function () {
}, },
fail: function () { fail: function () {
console.log("Send Cmd failed"); console.log("Send Cmd failed");
layer.msg('消息发送失败'); layer.msg('模板消息发送失败');
} }
}); });
this.conn.send(msg.body); this.conn.send(msg.body);
...@@ -966,6 +994,7 @@ $(function () { ...@@ -966,6 +994,7 @@ $(function () {
}) })
}, },
rendHistoryMessage: function (id, data, isTemplate) { rendHistoryMessage: function (id, data, isTemplate) {
console.log(data)
var position = $(".notice_classify[userid=" + id + "]").attr('position'); var position = $(".notice_classify[userid=" + id + "]").attr('position');
if (position) { if (position) {
$(".notice_classify[userid=" + id + "]").removeAttr('position') $(".notice_classify[userid=" + id + "]").removeAttr('position')
...@@ -978,7 +1007,9 @@ $(function () { ...@@ -978,7 +1007,9 @@ $(function () {
if (fromId == id) { //接收的 左边 if (fromId == id) { //接收的 左边
rightOrLeft = 2; rightOrLeft = 2;
} }
if (data[i].data) { //消息或者表情 if (data[i].ext.isTemplate) { //模板
chatCon += this.messageHtml(rightOrLeft, data[i].ext, true, true, data[i].ext.timer);
} else if (data[i].data) { //消息或者表情
if (typeof (data[i].data) == 'string') { if (typeof (data[i].data) == 'string') {
chatCon += this.messageHtml(rightOrLeft, { chatCon += this.messageHtml(rightOrLeft, {
message: data[i].data, message: data[i].data,
...@@ -1009,8 +1040,6 @@ $(function () { ...@@ -1009,8 +1040,6 @@ $(function () {
img: this.judgeCustomer(data[i]).img, img: this.judgeCustomer(data[i]).img,
id: data[i].ext.id id: data[i].ext.id
}, false, true, data[i].ext.timer); }, false, true, data[i].ext.timer);
} else if (data[i].action == 'template') { //模板
chatCon += this.messageHtml(rightOrLeft, data[i].ext, true, true, data[i].ext.timer);
} }
} }
......
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