...
|
...
|
@@ -9,17 +9,18 @@ |
|
|
|
|
|
var $ = require('yoho-jquery'),
|
|
|
uuid = require('uuid'),
|
|
|
editArea = require('./edit-area'),
|
|
|
serviceApi = require('./service-api'),
|
|
|
broswer = require('./broswer'),
|
|
|
cursor = require('./cursor'),
|
|
|
view = require('./view'),
|
|
|
send = require('./socket/send'),
|
|
|
edit = require('./socket/edit'),
|
|
|
receive = require('./socket/receive'),
|
|
|
util = require('./utility'),
|
|
|
clipPaste = require('./clip-paste'),
|
|
|
socketChat = require('./socket/chat'),
|
|
|
socketConf = require('./socket/config'),
|
|
|
clipPaste = require('./clip-paste');
|
|
|
processInfo = require('./view').processInfo;
|
|
|
|
|
|
var allRTs,
|
|
|
endTime,
|
...
|
...
|
@@ -52,16 +53,6 @@ var tipTpl = require('hbs/service/tip.hbs'), |
|
|
robotTpl = require('hbs/service/robot-msg.hbs'),
|
|
|
disTpl = require('hbs/service/discontent-row.hbs');
|
|
|
|
|
|
var processInfo = {
|
|
|
scrollLoad: false,
|
|
|
loadingHistory: false,
|
|
|
hasMore: true,
|
|
|
manual: false,
|
|
|
completeClose: false, // 评价完成后关闭
|
|
|
promoter: 1, // 评论发起者 1:客户自己 2:客服
|
|
|
savedEval: false // 是否保存过评论
|
|
|
};
|
|
|
|
|
|
require('bootstrap');
|
|
|
require('../common');
|
|
|
require('blueimp-file-upload/js/jquery.iframe-transport');
|
...
|
...
|
@@ -74,12 +65,17 @@ encryptedUid = $encryptedUid.val(); |
|
|
assetsPrefix = $assetsPrefix.val();
|
|
|
socketConfCM = socketConf.conversationMessage;
|
|
|
socketConfCM.encryptedUid = encryptedUid;
|
|
|
processInfo.encryptedUid = encryptedUid;
|
|
|
|
|
|
// 原始配置信息用于重新连线
|
|
|
originConf = JSON.parse(JSON.stringify(socketConf));
|
|
|
|
|
|
// 页面初始化
|
|
|
var _loadPage = function() {
|
|
|
|
|
|
// 客服评价
|
|
|
var evalView = new view.Evaluate();
|
|
|
|
|
|
/**
|
|
|
* 添加新的消息
|
|
|
*/
|
...
|
...
|
@@ -144,7 +140,6 @@ var _loadPage = function() { |
|
|
var $area = $('.msg-area'),
|
|
|
msg = $area.val().trim();
|
|
|
|
|
|
// 发送前共通处理
|
|
|
beforeSendMsg();
|
|
|
|
|
|
if (!msgContent) {
|
...
|
...
|
@@ -220,7 +215,7 @@ var _loadPage = function() { |
|
|
systemTip(message.content);
|
|
|
|
|
|
// 显示人工客服
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
'manual-service': true
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -258,7 +253,7 @@ var _loadPage = function() { |
|
|
});
|
|
|
|
|
|
// 隐藏人工
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
'manual-service': false
|
|
|
});
|
|
|
break;
|
...
|
...
|
@@ -273,7 +268,7 @@ var _loadPage = function() { |
|
|
processInfo.manual = true;
|
|
|
|
|
|
// 显示评价&隐藏人工
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: true,
|
|
|
image: true,
|
|
|
evaluate: true,
|
...
|
...
|
@@ -287,11 +282,10 @@ var _loadPage = function() { |
|
|
content: tipText
|
|
|
});
|
|
|
|
|
|
// 接入人工客服需要评价
|
|
|
processInfo.manual = true;
|
|
|
|
|
|
// 显示评价&隐藏人工
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: true,
|
|
|
image: true,
|
|
|
evaluate: true,
|
...
|
...
|
@@ -401,53 +395,6 @@ var _loadPage = function() { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 显示评价弹框
|
|
|
*/
|
|
|
function showEvalModal(cptClose) {
|
|
|
var $evalModal = $('#makeEvaluation');
|
|
|
|
|
|
// 评价完成后关闭
|
|
|
processInfo.completeClose = cptClose;
|
|
|
|
|
|
// 没有接入人工
|
|
|
if (!processInfo.manual) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 评价原因
|
|
|
function discontentHtml(len, data) {
|
|
|
var i,
|
|
|
dom = '';
|
|
|
|
|
|
for (i = 0; i < len; i = i + 2) {
|
|
|
dom += disTpl({
|
|
|
id1: data[i].id,
|
|
|
id1Content: data[i].content,
|
|
|
id2: data[i + 1] && data[i + 1].id,
|
|
|
id2Content: data[i + 1] && data[i + 1].content
|
|
|
});
|
|
|
}
|
|
|
|
|
|
$evalModal.find('.discontent').empty().append(dom);
|
|
|
}
|
|
|
|
|
|
// 拉取评价原因
|
|
|
serviceApi.reason({
|
|
|
conversationId: socketConfCM.conversationId
|
|
|
})
|
|
|
.done(function(res) {
|
|
|
var data = res.data,
|
|
|
len = data.length;
|
|
|
|
|
|
if (res && res.code === 200) {
|
|
|
// 评价原因
|
|
|
len && discontentHtml(len, data);
|
|
|
}
|
|
|
$evalModal.modal('show');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理收到消息
|
|
|
*/
|
|
|
function getMessage(rec) {
|
...
|
...
|
@@ -465,7 +412,7 @@ var _loadPage = function() { |
|
|
|
|
|
if (isHidden) {
|
|
|
titleInterval = setInterval(function() {
|
|
|
document.title = '您有新消息!';
|
|
|
document.title = '您有新消息';
|
|
|
setTimeout(function() {
|
|
|
document.title = docTitle;
|
|
|
}, 300);
|
...
|
...
|
@@ -511,10 +458,9 @@ var _loadPage = function() { |
|
|
break;
|
|
|
|
|
|
case allTypes.EVAL_INVITE:
|
|
|
// 客服发起
|
|
|
if (!processInfo.savedEval) {
|
|
|
processInfo.promoter = 2;
|
|
|
showEvalModal();
|
|
|
evalView.open();
|
|
|
}
|
|
|
break;
|
|
|
|
...
|
...
|
@@ -524,7 +470,7 @@ var _loadPage = function() { |
|
|
|
|
|
case allTypes.OP_LEAVE:
|
|
|
socketChat.clear();
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: false,
|
|
|
image: false
|
|
|
});
|
...
|
...
|
@@ -533,7 +479,7 @@ var _loadPage = function() { |
|
|
|
|
|
case allTypes.OFFLINE:
|
|
|
socketChat.clear();
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: false,
|
|
|
image: false
|
|
|
});
|
...
|
...
|
@@ -578,14 +524,14 @@ var _loadPage = function() { |
|
|
},
|
|
|
|
|
|
onOpen: function() {
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
evaluate: false,
|
|
|
'manual-service': false
|
|
|
});
|
|
|
},
|
|
|
|
|
|
onClose: function() {
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: false,
|
|
|
image: false,
|
|
|
evaluate: false,
|
...
|
...
|
@@ -783,57 +729,57 @@ var _loadPage = function() { |
|
|
});
|
|
|
});
|
|
|
|
|
|
// 提交评价
|
|
|
$makeEvalModal.find('.submit').click(function() {
|
|
|
|
|
|
var $btnEval = $('.icon.evaluate'),
|
|
|
mEval = $('#makeEvaluation'),
|
|
|
reason = mEval.find('textarea').val().trim(),
|
|
|
star = mEval.find('.star.positive').length,
|
|
|
reasonTypes = mEval.find('.dis-row .type.chosen');
|
|
|
|
|
|
var data = {
|
|
|
conversationId: socketConfCM.conversationId,
|
|
|
encryptedUid: encryptedUid,
|
|
|
promoter: processInfo.promoter,
|
|
|
stars: star
|
|
|
};
|
|
|
|
|
|
var reasonIds,
|
|
|
idArray = [];
|
|
|
|
|
|
if (star < 4) {
|
|
|
$.each(reasonTypes, function(index, item) {
|
|
|
idArray.push($(item).data('id'));
|
|
|
});
|
|
|
|
|
|
reasonIds = idArray.join(':');
|
|
|
data.reasonIds = reasonIds;
|
|
|
data.reasonMsg = reason;
|
|
|
}
|
|
|
|
|
|
serviceApi.evaluate(data)
|
|
|
.done(function(res) {
|
|
|
processInfo.promoter = 1;
|
|
|
$btnEval.hide();
|
|
|
processInfo.savedEval = true;
|
|
|
|
|
|
if (res && res.code === 200) {
|
|
|
// 评价后通知客服
|
|
|
socketConfCM.type = allRTs.EVAL_NOTICE;
|
|
|
socketConfCM.uuid = uuid.v4();
|
|
|
socketChat.send(socketConfCM);
|
|
|
|
|
|
// 完成后关闭
|
|
|
if (processInfo.completeClose) {
|
|
|
window.close();
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
.always(function() {
|
|
|
mEval.modal('hide');
|
|
|
});
|
|
|
});
|
|
|
// // 提交评价
|
|
|
// $makeEvalModal.find('.submit').click(function() {
|
|
|
|
|
|
// var $btnEval = $('.icon.evaluate'),
|
|
|
// mEval = $('#makeEvaluation'),
|
|
|
// reason = mEval.find('textarea').val().trim(),
|
|
|
// star = mEval.find('.star.positive').length,
|
|
|
// reasonTypes = mEval.find('.dis-row .type.chosen');
|
|
|
|
|
|
// var data = {
|
|
|
// conversationId: socketConfCM.conversationId,
|
|
|
// encryptedUid: encryptedUid,
|
|
|
// promoter: processInfo.promoter,
|
|
|
// stars: star
|
|
|
// };
|
|
|
|
|
|
// var reasonIds,
|
|
|
// idArray = [];
|
|
|
|
|
|
// if (star < 4) {
|
|
|
// $.each(reasonTypes, function(index, item) {
|
|
|
// idArray.push($(item).data('id'));
|
|
|
// });
|
|
|
|
|
|
// reasonIds = idArray.join(':');
|
|
|
// data.reasonIds = reasonIds;
|
|
|
// data.reasonMsg = reason;
|
|
|
// }
|
|
|
|
|
|
// serviceApi.evaluate(data)
|
|
|
// .done(function(res) {
|
|
|
// processInfo.promoter = 1;
|
|
|
// $btnEval.hide();
|
|
|
// processInfo.savedEval = true;
|
|
|
|
|
|
// if (res && res.code === 200) {
|
|
|
// // 评价后通知客服
|
|
|
// socketConfCM.type = allRTs.EVAL_NOTICE;
|
|
|
// socketConfCM.uuid = uuid.v4();
|
|
|
// socketChat.send(socketConfCM);
|
|
|
|
|
|
// // 完成后关闭
|
|
|
// if (processInfo.completeClose) {
|
|
|
// window.close();
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
// .always(function() {
|
|
|
// mEval.modal('hide');
|
|
|
// });
|
|
|
// });
|
|
|
|
|
|
// 根节点高度设置
|
|
|
$html.css({
|
...
|
...
|
@@ -944,41 +890,6 @@ var _loadPage = function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
// 星评
|
|
|
$document.on('click', '.make-eval .star', function() {
|
|
|
var el,
|
|
|
i,
|
|
|
len,
|
|
|
tag = $(this),
|
|
|
index = tag.index(),
|
|
|
$detailReason = $('.detail-reason'),
|
|
|
textEl = $('.make-eval .star-text'),
|
|
|
startList = $('.make-eval .stars .star');
|
|
|
|
|
|
var starText = {
|
|
|
0: '非常不满意',
|
|
|
1: '不满意',
|
|
|
2: '一般',
|
|
|
3: '满意',
|
|
|
4: '非常满意'
|
|
|
};
|
|
|
|
|
|
for (i = 0, len = startList.length; i < len; i++) {
|
|
|
el = $(startList[i]);
|
|
|
el.index() <= index && el.addClass('positive');
|
|
|
el.index() > index && el.removeClass('positive');
|
|
|
}
|
|
|
|
|
|
index < 3 && $detailReason.show();
|
|
|
index >= 3 && $detailReason.hide();
|
|
|
textEl.text(starText[index]);
|
|
|
});
|
|
|
|
|
|
// 选择不满意类型
|
|
|
$document.on('click', '.dis-row .type', function(e) {
|
|
|
$(e.target).toggleClass('chosen');
|
|
|
});
|
|
|
|
|
|
// 留言
|
|
|
$msgList.on('click', '.leave-msg', leaveMsg);
|
|
|
|
...
|
...
|
@@ -1008,7 +919,7 @@ var _loadPage = function() { |
|
|
},
|
|
|
|
|
|
2: function() {
|
|
|
showEvalModal();
|
|
|
evalView.open();
|
|
|
},
|
|
|
|
|
|
3: function() {
|
...
|
...
|
@@ -1051,7 +962,7 @@ var _loadPage = function() { |
|
|
$close.click(function() {
|
|
|
if (processInfo.manual && !processInfo.savedEval) {
|
|
|
// 没有保存过评论
|
|
|
showEvalModal(true);
|
|
|
evalView.open(true);
|
|
|
} else {
|
|
|
window.close();
|
|
|
}
|
...
|
...
|
|