...
|
...
|
@@ -153,8 +153,6 @@ let chat = { |
|
|
onMessage: function(event) {
|
|
|
let received = JSON.parse(event.data);
|
|
|
|
|
|
console.log('客户端接收到消息:', received);
|
|
|
|
|
|
// update 会话id
|
|
|
cmEntity.conversationId = received.newConversationId > 0 ?
|
|
|
received.newConversationId : received.conversationId;
|
...
|
...
|
@@ -315,7 +313,7 @@ let chat = { |
|
|
this.bootSocket();
|
|
|
this.canEvalute = true;
|
|
|
|
|
|
this.switchService('rebot');
|
|
|
this.switchService('robot');
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -643,29 +641,36 @@ let chat = { |
|
|
const sysInfo = self._sysInfo.bind(this);
|
|
|
const chatMessage = cmEntity.chatMessage;
|
|
|
|
|
|
function whetherLeaveMsg(cm) {
|
|
|
const canLeave = cm.isLeaveMessage === 2;
|
|
|
const append = canLeave ? '您可以选择<span class="blue" data-trigger="leave-msg">留言</span>' : '';
|
|
|
const reg = /[,|,]$/g;
|
|
|
|
|
|
chatMessage.content = canLeave ?
|
|
|
chatMessage.content :
|
|
|
(chatMessage.content = chatMessage.content.replace(reg, ''));
|
|
|
|
|
|
canLeave && (self.canLeaveMSG = true);
|
|
|
sysInfo(`${chatMessage.content || ''}${append}`);
|
|
|
}
|
|
|
|
|
|
|
|
|
function noService() {
|
|
|
$chatHeader.find('.js-service-txt').text('YOHO客服');
|
|
|
self.renderHeader('robot');
|
|
|
$chat.append(time(Date.now()).show());
|
|
|
}
|
|
|
|
|
|
// state: 0 没有人工客服
|
|
|
function noEmploye() {
|
|
|
$chatHeader.find('.js-service-txt').text('YOHO客服');
|
|
|
self.renderHeader('robot');
|
|
|
|
|
|
$chat.append(time(Date.now()).show());
|
|
|
sysInfo(`${chatMessage.content || ''}您可以选择<span class="blue" data-trigger="leave-msg">留言</span>`);
|
|
|
whetherLeaveMsg(cmEntity);
|
|
|
}
|
|
|
|
|
|
// state 1: 排队中
|
|
|
function inQueue() {
|
|
|
let info = `${chatMessage.content}您可以<span class="blue" data-trigger="leave-msg">留言</span>`;
|
|
|
|
|
|
// let info = '您可以选择<span class="blue" data-trigger="leave-msg">留言</span>,客服会以短信形式回复您';
|
|
|
|
|
|
self.canLeaveMSG = true;
|
|
|
|
|
|
sysInfo(info);
|
|
|
whetherLeaveMsg(cmEntity);
|
|
|
}
|
|
|
|
|
|
// state 2: 人工客服进入
|
...
|
...
|
@@ -707,7 +712,6 @@ let chat = { |
|
|
viewData.data.content = viewData.data.content.replace(/^http:/, '');
|
|
|
}
|
|
|
|
|
|
// console.log(viewData);
|
|
|
let $html = $(this.messageT(viewData));
|
|
|
|
|
|
|
...
|
...
|
@@ -826,11 +830,6 @@ let chat = { |
|
|
if (type === 'human') {
|
|
|
cmEntity.type = socketConf.recType.MANUAL_SERVICE;
|
|
|
socket.send(JSON.stringify(cmEntity));
|
|
|
|
|
|
// this._sysInfo();
|
|
|
} else {
|
|
|
|
|
|
// todo;
|
|
|
}
|
|
|
},
|
|
|
|
...
|
...
|
@@ -840,7 +839,7 @@ let chat = { |
|
|
*/
|
|
|
renderHeader: function(type) {
|
|
|
let header = {
|
|
|
rebot: {
|
|
|
robot: {
|
|
|
title: '智能小YO',
|
|
|
right: '<span data-action="change-human">人工客服</span>'
|
|
|
},
|
...
|
...
|
|