...
|
...
|
@@ -11,6 +11,7 @@ var $ = require('yoho-jquery'), |
|
|
uuid = require('uuid'),
|
|
|
emojiMap = require('./emoji-map'),
|
|
|
editArea = require('./edit-area'),
|
|
|
serviceApi = require('./service-api'),
|
|
|
broswer = require('./broswer'),
|
|
|
socketChat = require('./socket-chat'),
|
|
|
socketConf = require('./socket-config');
|
...
|
...
|
@@ -23,7 +24,6 @@ var allRTs, |
|
|
assetsPrefix,
|
|
|
cursorPosition,
|
|
|
configDomains,
|
|
|
hasMore = true,
|
|
|
titleInterval,
|
|
|
$html = $('html'),
|
|
|
$window = $(window),
|
...
|
...
|
@@ -51,20 +51,14 @@ var tipTpl = require('hbs/service/tip.hbs'), |
|
|
|
|
|
var processInfo = {
|
|
|
scrollLoad: false,
|
|
|
loadingHistory: false,
|
|
|
hasMore: true,
|
|
|
manual: false,
|
|
|
completeClose: false, // 评价完成后关闭
|
|
|
promoter: 1, // 评论发起者 1:客户自己 2:客服
|
|
|
savedEval: false // 是否保存过评论
|
|
|
};
|
|
|
|
|
|
var key,
|
|
|
urls = {
|
|
|
makeEval: '/evalute/saveEvalute',
|
|
|
leaveMsg: '/leavemessage/saveLeavemessage',
|
|
|
msgHistory: '/conversationMessage/pageList',
|
|
|
evalReason: '/evalute/queryReasonByConversationId'
|
|
|
};
|
|
|
|
|
|
require('bootstrap');
|
|
|
require('../common');
|
|
|
require('blueimp-file-upload/js/jquery.iframe-transport');
|
...
|
...
|
@@ -77,6 +71,7 @@ encryptedUid = $encryptedUid.val(); |
|
|
assetsPrefix = $assetsPrefix.val();
|
|
|
socketConfCM = socketConf.conversationMessage;
|
|
|
socketConfCM.encryptedUid = encryptedUid;
|
|
|
|
|
|
// 原始配置信息用于重新连线
|
|
|
originConf = JSON.parse(JSON.stringify(socketConf));
|
|
|
|
...
|
...
|
@@ -354,7 +349,7 @@ function pageInit() { |
|
|
|
|
|
/**
|
|
|
* 人工接入队列中
|
|
|
* @param message 内部消息对象
|
|
|
* @param message 内部消息对象
|
|
|
*/
|
|
|
function inQueue(message) {
|
|
|
systemTip(message.content);
|
...
|
...
|
@@ -508,14 +503,12 @@ function pageInit() { |
|
|
$evalModal.find('.discontent').empty().append(dom);
|
|
|
}
|
|
|
|
|
|
// todo
|
|
|
// 拉取评价原因
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: urls.evalReason,
|
|
|
data: {
|
|
|
conversationId: socketConfCM.conversationId
|
|
|
},
|
|
|
success: function success(res) {
|
|
|
serviceApi.reason({
|
|
|
conversationId: socketConfCM.conversationId
|
|
|
})
|
|
|
.done(function(res) {
|
|
|
var data = res.data,
|
|
|
len = data.length;
|
|
|
|
...
|
...
|
@@ -524,8 +517,7 @@ function pageInit() { |
|
|
len && discontentHtml(len, data);
|
|
|
}
|
|
|
$evalModal.modal('show');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -709,12 +701,12 @@ function pageInit() { |
|
|
len = msgList.length;
|
|
|
|
|
|
if (msgList[0] && endTime === msgList[0].sendTime) {
|
|
|
hasMore = false;
|
|
|
processInfo.hasMore = false;
|
|
|
}
|
|
|
|
|
|
endTime = msgList[0] && msgList[0].sendTime;
|
|
|
|
|
|
if (hasMore) {
|
|
|
if (processInfo.hasMore) {
|
|
|
for (i = 0; i < len; i++) {
|
|
|
item = msgList[i];
|
|
|
item.chatMessage.newContent = emojiPrefix(item.chatMessage.newContent);
|
...
|
...
|
@@ -770,6 +762,8 @@ function pageInit() { |
|
|
$msgList.prepend(dom);
|
|
|
heightAfter = $msgList.height();
|
|
|
$panelMainBody.scrollTop(heightAfter - heightBefore);
|
|
|
|
|
|
processInfo.loadingHistory = false;
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -782,24 +776,31 @@ function pageInit() { |
|
|
encryptedUid: encryptedUid
|
|
|
};
|
|
|
|
|
|
if (processInfo.loadingHistory) {
|
|
|
return;
|
|
|
}
|
|
|
processInfo.loadingHistory = true;
|
|
|
|
|
|
if (endTime) {
|
|
|
data.endTime = endTime;
|
|
|
}
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: urls.msgHistory,
|
|
|
data: data,
|
|
|
success: function(res) {
|
|
|
|
|
|
serviceApi.history(data)
|
|
|
.done(function(res) {
|
|
|
if (res && res.code === 200) {
|
|
|
if (hasMore) {
|
|
|
msgList = res.data && res.data.records || [];
|
|
|
if (processInfo.hasMore) {
|
|
|
msgList = res.data.records || [];
|
|
|
msgResolve(msgList);
|
|
|
}
|
|
|
$history.hide();
|
|
|
processInfo.scrollLoad = true;
|
|
|
} else {
|
|
|
processInfo.loadingHistory = false;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
})
|
|
|
.fail(function() {
|
|
|
processInfo.loadingHistory = false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 用户信息获取并初始化socket连接
|
...
|
...
|
@@ -852,23 +853,15 @@ function pageInit() { |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: urls.leaveMsg,
|
|
|
data: {
|
|
|
content: val,
|
|
|
encryptedUid: encryptedUid,
|
|
|
conversationId: socketConfCM.newConversationId || socketConfCM.conversationId
|
|
|
},
|
|
|
success: function(res) {
|
|
|
if (res && res.code === 200) {
|
|
|
lMsg.modal('hide');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
serviceApi.leaveMsg({
|
|
|
content: val,
|
|
|
encryptedUid: encryptedUid,
|
|
|
conversationId: socketConfCM.conversationId
|
|
|
})
|
|
|
.done(function() {})
|
|
|
.always(function() {
|
|
|
lMsg.modal('hide');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 提交评价
|
...
|
...
|
@@ -900,14 +893,9 @@ function pageInit() { |
|
|
data.reasonMsg = reason;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: urls.makeEval,
|
|
|
data: data,
|
|
|
success: function(res) {
|
|
|
// 提交评价过后,不管是否成功都应该关闭弹框
|
|
|
serviceApi.evaluate(data)
|
|
|
.done(function(res) {
|
|
|
processInfo.promoter = 1;
|
|
|
mEval.modal('hide');
|
|
|
$btnEval.hide();
|
|
|
processInfo.savedEval = true;
|
|
|
|
...
|
...
|
@@ -922,11 +910,10 @@ function pageInit() { |
|
|
window.close();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
})
|
|
|
.always(function() {
|
|
|
mEval.modal('hide');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 根节点高度设置
|
...
|
...
|
@@ -1181,9 +1168,13 @@ function pageInit() { |
|
|
|
|
|
// 滚动加载更多
|
|
|
$panelMainBody.scroll(function() {
|
|
|
var loading = $panelMainBody.scrollTop() === 0;
|
|
|
var isLoadingArea = $panelMainBody.scrollTop() < 100;
|
|
|
|
|
|
processInfo.scrollLoad && loading && hasMore && fetchHistoryMsg();
|
|
|
isLoadingArea &&
|
|
|
processInfo.scrollLoad &&
|
|
|
!processInfo.loadingHistory &&
|
|
|
processInfo.hasMore &&
|
|
|
fetchHistoryMsg();
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1195,13 +1186,6 @@ function pageInit() { |
|
|
success: function(domains) {
|
|
|
configDomains = domains;
|
|
|
|
|
|
// url前缀添加
|
|
|
for (key in urls) {
|
|
|
if (urls.hasOwnProperty(key)) {
|
|
|
urls[key] = configDomains.imCs + urls[key];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 检查支持性
|
|
|
(function() {
|
|
|
if (!window.WebSocket) {
|
...
|
...
|
|