...
|
...
|
@@ -36,6 +36,7 @@ const msgTypeMap = { |
|
|
10: 'order'
|
|
|
};
|
|
|
|
|
|
const imServerURL= $('#js-im').val();
|
|
|
let lastServiceType = 'robot';
|
|
|
let lastMSGTime = null;
|
|
|
|
...
|
...
|
@@ -87,7 +88,9 @@ var chat = { |
|
|
let actions = {
|
|
|
onMessage: function(event) {
|
|
|
let received = JSON.parse(event.data);
|
|
|
console.log(received);
|
|
|
|
|
|
console.log('onMessage:');
|
|
|
console.table(received);
|
|
|
|
|
|
// update 会话id
|
|
|
cmEntity.conversationId = received.newConversationId > 0 ?
|
...
|
...
|
@@ -166,8 +169,11 @@ var chat = { |
|
|
|
|
|
window.addEventListener('offline', function() {
|
|
|
self._networkSick(true);
|
|
|
self.$chat.toggleClass('online', false);
|
|
|
});
|
|
|
|
|
|
// window.addEventListener('beforeunload', function() {});
|
|
|
|
|
|
// TODO
|
|
|
},
|
|
|
|
...
|
...
|
@@ -194,6 +200,8 @@ var chat = { |
|
|
|
|
|
msg.uid = uuid;
|
|
|
cmEntity.uuid = uuid;
|
|
|
cmEntity.type = socketConf.recType.CU_SEND;
|
|
|
|
|
|
switch (msg.type) {
|
|
|
case 'order':
|
|
|
arr = [
|
...
|
...
|
@@ -297,6 +305,15 @@ var chat = { |
|
|
var uuid = rec.uuid;
|
|
|
var viewData;
|
|
|
|
|
|
// 服务状态: 离线
|
|
|
if (
|
|
|
recType === allTypes.OFFLINE ||
|
|
|
recType === allTypes.OP_LEAVE ||
|
|
|
(recType === allTypes.MANUAL_SERVICE && msgType === 0)
|
|
|
) {
|
|
|
this.$chat.toggleClass('online', false);
|
|
|
}
|
|
|
|
|
|
switch (recType) {
|
|
|
|
|
|
// 客服消息
|
...
|
...
|
@@ -310,16 +327,20 @@ var chat = { |
|
|
// ------------------------------------------
|
|
|
// 1. 客服进入
|
|
|
case allTypes.CS_ENTER:
|
|
|
this.$chat.toggleClass('online', true);
|
|
|
this._sysInfo('客服小YO正在为您服务');
|
|
|
break;
|
|
|
case allTypes.OFFLINE:
|
|
|
this._sysInfo('TODO');
|
|
|
break;
|
|
|
case allTypes.TRANSFER:
|
|
|
this._sysInfo('TODO');
|
|
|
break;
|
|
|
case allTypes.MANUAL_SERVICE:
|
|
|
this._sysInfo('TODO');
|
|
|
if (message.type === 0) { // 没有在线客服
|
|
|
this.$header.find('.js-service-txt').text('YOHO客服');
|
|
|
this.$chatWin.append(time(Date.now()).show());
|
|
|
this._sysInfo();
|
|
|
}
|
|
|
break;
|
|
|
case allTypes.CS_CHANGE_STATE:
|
|
|
this._sysInfo('TODO');
|
...
|
...
|
@@ -341,7 +362,7 @@ var chat = { |
|
|
viewData = [viewData];
|
|
|
}
|
|
|
|
|
|
console.log(viewData);
|
|
|
// console.log(viewData);
|
|
|
let $html = $(this.messageT(viewData));
|
|
|
|
|
|
this.checkTime();
|
...
|
...
|
@@ -438,12 +459,8 @@ var chat = { |
|
|
right: '<span data-action="change-human">人工客服</span>'
|
|
|
},
|
|
|
human: {
|
|
|
title: '<i class="chat-status"></i><span>YOHO!客服</span>',
|
|
|
title: '<i class="chat-status"></i><span class="js-service-txt">正在连接...</span>',
|
|
|
right: '<span data-trigger="rating">评价</span>'
|
|
|
},
|
|
|
link: {
|
|
|
title: '正在连接...',
|
|
|
right: ''
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -474,6 +491,39 @@ $('.menu-trigger').on('click', function() { |
|
|
resizeFooter();
|
|
|
});
|
|
|
|
|
|
let $upload = $('.upload-img');
|
|
|
|
|
|
$upload.on('change', function() {
|
|
|
var input = event.target;
|
|
|
var files = input.files;
|
|
|
var formData = new FormData();
|
|
|
|
|
|
formData.append('files', [files[0]]);
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: `${imServerURL}/imServerURL`,
|
|
|
data: formData,
|
|
|
processData: false, // 告诉jQuery不要去处理发送的数据
|
|
|
contentType: false
|
|
|
}).done(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
console.log(res)
|
|
|
|
|
|
// chat.sendMSG({
|
|
|
// type: 'picture',
|
|
|
// data: {
|
|
|
// content: Todo
|
|
|
// }
|
|
|
// });
|
|
|
}
|
|
|
})
|
|
|
.fail(function(res) {
|
|
|
chat._sysInfo('图片太大了')
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
// 图片放大
|
|
|
$('#chat-window').on('click', '.chat-image', function() {
|
...
|
...
|
|