Commit 31eb419b by 施宇

11

parent 9b8b1a50
Showing with 67 additions and 38 deletions
......@@ -510,20 +510,44 @@ $(function () {
self.singleChat();
},
onTextMessage: function (message) {
self.receiveData(1, {
name: self.judgeCustomer(message).name,
id: message.ext.id,
img: self.judgeCustomer(message).img,
message: message.data,
from: message.from,
touserid: message.ext.touserid
}, false);
if (self.customerNum == self.defaultName) {
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,
img: self.judgeCustomer(message).img,
message: message.data,
from: message.from,
touserid: message.ext.touserid
}, false);
if (self.customerNum == self.defaultName) {
var index = self.chatList.indexOf(message.from);
if (index == -1) {
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
......@@ -607,7 +631,7 @@ $(function () {
if (self.isRelogin) {
self.isRelogin = false;
// self.registerIm();
self.registerIm();
self.registerIm();
} else {
layer.open({
title: '提示',
......@@ -651,7 +675,7 @@ $(function () {
registerIm: function () {
var me = this;
IcController.getData(apis.authregistim, 'post', {
"token": Util.getCookie('token') || ''
"token": Util.getCookie('token') || ''
}, function (res) {
if (res.errcode == 0) {
me.getUserInfo();
......@@ -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