Commit 31eb419b by 施宇

11

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