...
|
...
|
@@ -8,14 +8,17 @@ |
|
|
'use strict';
|
|
|
|
|
|
var $ = require('yoho-jquery'),
|
|
|
uuid = require('uuid'),
|
|
|
emojiMap = require('./emoji-map'),
|
|
|
editArea = require('./edit-area'),
|
|
|
serviceApi = require('./service-api'),
|
|
|
view = require('./view'),
|
|
|
broswer = require('./broswer'),
|
|
|
utility = require('./utility'),
|
|
|
socketChat = require('./socket-chat'),
|
|
|
socketConf = require('./socket-config');
|
|
|
util = require('./utility'),
|
|
|
send = require('./socket/send'),
|
|
|
edit = require('./socket/edit'),
|
|
|
ClipPaste = require('./clip-paste'),
|
|
|
serviceApi = require('./service-api'),
|
|
|
receive = require('./socket/receive'),
|
|
|
socketChat = require('./socket/chat'),
|
|
|
socketConf = require('./socket/config'),
|
|
|
processInfo = require('./view').processInfo;
|
|
|
|
|
|
var allRTs,
|
|
|
endTime,
|
...
|
...
|
@@ -23,14 +26,10 @@ var allRTs, |
|
|
encryptedUid,
|
|
|
socketConfCM,
|
|
|
assetsPrefix,
|
|
|
cursorPosition,
|
|
|
configDomains,
|
|
|
titleInterval,
|
|
|
$html = $('html'),
|
|
|
$window = $(window),
|
|
|
$document = $(document),
|
|
|
$msgList = $('.msg-list'),
|
|
|
docTitle = document.title,
|
|
|
$msgEdit = $('.msg-edit'),
|
|
|
$leaveMsg = $('#leaveMsg'),
|
|
|
$close = $('.header .close'),
|
...
|
...
|
@@ -38,7 +37,6 @@ var allRTs, |
|
|
$sendImgInput = $('#sendImg'),
|
|
|
$history = $('.about-his.has-his'),
|
|
|
$msgArea = $('.msg-edit .msg-area'),
|
|
|
$makeEvalModal = $('#makeEvaluation'),
|
|
|
$rightHeadTab = $('.right-head .tab'),
|
|
|
$encryptedUid = $('input[name=encryptedUid]'),
|
|
|
$assetsPrefix = $('input[name=assetsPrefix]'),
|
...
|
...
|
@@ -47,18 +45,7 @@ var allRTs, |
|
|
var tipTpl = require('hbs/service/tip.hbs'),
|
|
|
csTpl = require('hbs/service/cs-msg.hbs'),
|
|
|
cusTpl = require('hbs/service/cus-msg.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 // 是否保存过评论
|
|
|
};
|
|
|
robotTpl = require('hbs/service/robot-msg.hbs');
|
|
|
|
|
|
require('bootstrap');
|
|
|
require('../common');
|
...
|
...
|
@@ -72,12 +59,17 @@ encryptedUid = $encryptedUid.val(); |
|
|
assetsPrefix = $assetsPrefix.val();
|
|
|
socketConfCM = socketConf.conversationMessage;
|
|
|
socketConfCM.encryptedUid = encryptedUid;
|
|
|
processInfo.encryptedUid = encryptedUid;
|
|
|
|
|
|
// 原始配置信息用于重新连线
|
|
|
originConf = JSON.parse(JSON.stringify(socketConf));
|
|
|
|
|
|
// 页面初始化
|
|
|
function pageInit() {
|
|
|
var _loadPage = function() {
|
|
|
|
|
|
// 客服评价
|
|
|
var evalView = new view.Evaluate();
|
|
|
|
|
|
/**
|
|
|
* 添加新的消息
|
|
|
*/
|
...
|
...
|
@@ -87,48 +79,6 @@ function pageInit() { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 表情设置
|
|
|
* @param e
|
|
|
*/
|
|
|
function setEmoji(e) {
|
|
|
var i,
|
|
|
pos,
|
|
|
start,
|
|
|
end,
|
|
|
newVal,
|
|
|
textDom,
|
|
|
emojiText,
|
|
|
tag = $(e.target),
|
|
|
area = $('.msg-area'),
|
|
|
val = area.val(),
|
|
|
len = emojiMap.length,
|
|
|
emojiId = tag.data('id'),
|
|
|
comp = $('.emoji-component');
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
if (emojiMap[i].file === emojiId.toString()) {
|
|
|
emojiText = emojiMap[i].text;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (cursorPosition) {
|
|
|
start = val.substring(0, cursorPosition);
|
|
|
end = val.substring(cursorPosition);
|
|
|
newVal = [start, emojiText, end].join('');
|
|
|
} else {
|
|
|
newVal = [val, emojiText].join('');
|
|
|
}
|
|
|
|
|
|
comp.hide();
|
|
|
area.val(newVal);
|
|
|
cursorPosition += emojiText.length;
|
|
|
|
|
|
textDom = area[0];
|
|
|
pos = cursorPosition ? cursorPosition : newVal.length;
|
|
|
broswer.setCursor(textDom, pos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 系统通知
|
|
|
* @param tip 具体消息
|
|
|
*/
|
...
|
...
|
@@ -168,42 +118,24 @@ function pageInit() { |
|
|
var $countdown = $('.countdown');
|
|
|
|
|
|
$countdown.parents('.list-item').remove();
|
|
|
if (titleInterval) {
|
|
|
clearInterval(titleInterval);
|
|
|
document.title = docTitle;
|
|
|
}
|
|
|
util.removeBlinkAlert();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理发送消息
|
|
|
* @param e
|
|
|
* @param msgType
|
|
|
* @param msgContent
|
|
|
*/
|
|
|
function sendMessage(e, msgType, msgContent) {
|
|
|
function sendMessage() {
|
|
|
var $area = $('.msg-area'),
|
|
|
msg = $area.val().trim();
|
|
|
|
|
|
// 发送前共通处理
|
|
|
beforeSendMsg();
|
|
|
|
|
|
if (!msgContent) {
|
|
|
if (!msg) {
|
|
|
return;
|
|
|
}
|
|
|
socketConfCM.type = allRTs.CU_SEND;
|
|
|
socketConfCM.uuid = uuid.v4();
|
|
|
socketConfCM.chatMessage.content = msg;
|
|
|
socketConfCM.chatMessage.type = msgType || 1;
|
|
|
socketChat.send(socketConfCM);
|
|
|
$area.val('');
|
|
|
} else {
|
|
|
socketConfCM.type = allRTs.CU_SEND;
|
|
|
socketConfCM.uuid = uuid.v4();
|
|
|
socketConfCM.chatMessage.type = msgType || 1;
|
|
|
socketConfCM.chatMessage.content = msgContent;
|
|
|
socketChat.send(socketConfCM);
|
|
|
if (!msg) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
send.text(msg);
|
|
|
$area.val('');
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -219,14 +151,6 @@ function pageInit() { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 人工客服
|
|
|
*/
|
|
|
function manualService() {
|
|
|
socketConfCM.type = allRTs.MANUAL_SERVICE;
|
|
|
socketChat.send(socketConfCM);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 正在进行人工会话
|
|
|
*/
|
|
|
function csChatting(message) {
|
...
|
...
|
@@ -258,53 +182,54 @@ function pageInit() { |
|
|
|
|
|
// 系统通知
|
|
|
systemTip(message.content);
|
|
|
processInfo.savedEval = false;
|
|
|
processInfo.manual = false;
|
|
|
|
|
|
// 显示人工客服
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
'manual-service': true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 人工链接
|
|
|
* @param msgType 内部消息类型
|
|
|
* @param message 内部消息对象
|
|
|
* @param rec 接收对象
|
|
|
* @private
|
|
|
*/
|
|
|
function linkSuccess(msgType, message) {
|
|
|
function linkSuccess(rec) {
|
|
|
|
|
|
var OUT_SERVICE = 0,
|
|
|
LINE_UP = 1,
|
|
|
MANUAL_SERVICE = 2,
|
|
|
ADMIN_MANUAL_SERVICE = 3;
|
|
|
var OUT_SERVICE = 0, // 0 没上班
|
|
|
LINE_UP = 1, // 1 需要排队
|
|
|
MANUAL_SERVICE = 2, // 2 接入人工
|
|
|
ADMIN_MANUAL_SERVICE = 3; // 3 管理员分配
|
|
|
|
|
|
var message = rec.chatMessage;
|
|
|
var msgType = message.type;
|
|
|
|
|
|
var dom,
|
|
|
tipText;
|
|
|
|
|
|
switch (msgType) {
|
|
|
|
|
|
case OUT_SERVICE: // 0是没上班
|
|
|
tipText = message.content +
|
|
|
'您也可以选择<a class="leave-msg">留言</a>';
|
|
|
case OUT_SERVICE:
|
|
|
tipText = receive.leaMsgTip(rec);
|
|
|
dom = tipTpl({
|
|
|
content: tipText
|
|
|
});
|
|
|
break;
|
|
|
|
|
|
case LINE_UP: // 1是需要排队
|
|
|
tipText = message.content +
|
|
|
'您也可以选择<a class="leave-msg">留言</a>';
|
|
|
case LINE_UP:
|
|
|
tipText = receive.leaMsgTip(rec);
|
|
|
dom = tipTpl({
|
|
|
content: tipText
|
|
|
});
|
|
|
|
|
|
// 隐藏人工
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
'manual-service': false
|
|
|
});
|
|
|
break;
|
|
|
|
|
|
case MANUAL_SERVICE: // 2是接入人工成功
|
|
|
case MANUAL_SERVICE:
|
|
|
tipText = message.content;
|
|
|
dom = tipTpl({
|
|
|
content: tipText
|
...
|
...
|
@@ -314,7 +239,7 @@ function pageInit() { |
|
|
processInfo.manual = true;
|
|
|
|
|
|
// 显示评价&隐藏人工
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: true,
|
|
|
image: true,
|
|
|
evaluate: true,
|
...
|
...
|
@@ -322,17 +247,16 @@ function pageInit() { |
|
|
});
|
|
|
break;
|
|
|
|
|
|
case ADMIN_MANUAL_SERVICE: // 3是管理员分配客服成功
|
|
|
case ADMIN_MANUAL_SERVICE:
|
|
|
tipText = message.content;
|
|
|
dom = tipTpl({
|
|
|
content: tipText
|
|
|
});
|
|
|
|
|
|
// 接入人工客服需要评价
|
|
|
processInfo.manual = true;
|
|
|
|
|
|
// 显示评价&隐藏人工
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: true,
|
|
|
image: true,
|
|
|
evaluate: true,
|
...
|
...
|
@@ -357,46 +281,15 @@ function pageInit() { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 返回表情路径处理
|
|
|
* @param text 文本
|
|
|
* @private
|
|
|
*/
|
|
|
function emojiPrefix(text) {
|
|
|
if (typeof text === 'string') {
|
|
|
return text.replace(/src="(\d{3}).gif"/g, 'src="' + assetsPrefix + '/img/service/emoji/$1.gif"');
|
|
|
}
|
|
|
|
|
|
return text;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理客户消息
|
|
|
* @private
|
|
|
*/
|
|
|
function handleCusMsg(rec, msgType, message) {
|
|
|
var dom,
|
|
|
image,
|
|
|
mode = 2,
|
|
|
width = 100,
|
|
|
height = 100;
|
|
|
|
|
|
message.newContent = emojiPrefix(message.newContent);
|
|
|
rec.userHead = utility.autoProtocol(rec.userHead);
|
|
|
|
|
|
// 用户头像处理
|
|
|
if (!rec.userHead) {
|
|
|
rec.userHead = assetsPrefix + socketConf.defaultUserHead;
|
|
|
} else {
|
|
|
rec.userHead = rec.userHead
|
|
|
.replace(/\{mode\}/, mode)
|
|
|
.replace(/\{width\}/, width)
|
|
|
.replace(/\{height\}/, height);
|
|
|
}
|
|
|
image;
|
|
|
|
|
|
// 图片添加标签
|
|
|
if (msgType === 2) {
|
|
|
message.content = utility.autoProtocol(message.content);
|
|
|
message.newContent = '<img class="img-msg" src="' + message.content + '">';
|
|
|
dom = cusTpl({
|
|
|
userHead: rec.userHead,
|
|
|
userName: rec.userName,
|
...
|
...
|
@@ -447,12 +340,7 @@ function pageInit() { |
|
|
var dom,
|
|
|
image;
|
|
|
|
|
|
rec.csHead = utility.autoProtocol(rec.csHead);
|
|
|
message.newContent = emojiPrefix(message.newContent);
|
|
|
if (msgType === 2) {
|
|
|
message.content = utility.autoProtocol(message.content);
|
|
|
message.newContent = '<img class="img-msg" src="' + message.content + '">';
|
|
|
|
|
|
dom = csTpl({
|
|
|
csHead: rec.csHead,
|
|
|
csName: rec.csName,
|
...
|
...
|
@@ -478,53 +366,6 @@ function pageInit() { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 显示评价弹框
|
|
|
*/
|
|
|
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) {
|
...
|
...
|
@@ -535,19 +376,11 @@ function pageInit() { |
|
|
isHidden = broswer.tabIsHidden(),
|
|
|
allTypes = socketConf.recType;
|
|
|
|
|
|
// 删除上个定时器
|
|
|
if (titleInterval) {
|
|
|
clearInterval(titleInterval);
|
|
|
}
|
|
|
// 提醒
|
|
|
isHidden && util.addBlinkAlert();
|
|
|
|
|
|
if (isHidden) {
|
|
|
titleInterval = setInterval(function() {
|
|
|
document.title = '您有新消息!';
|
|
|
setTimeout(function() {
|
|
|
document.title = docTitle;
|
|
|
}, 300);
|
|
|
}, 600);
|
|
|
}
|
|
|
// 预处理
|
|
|
receive.preProcess(rec);
|
|
|
|
|
|
switch (recType) {
|
|
|
case allTypes.ENTER:
|
...
|
...
|
@@ -555,7 +388,7 @@ function pageInit() { |
|
|
break;
|
|
|
|
|
|
case allTypes.LINK_SUCCESS:
|
|
|
linkSuccess(msgType, message);
|
|
|
linkSuccess(rec);
|
|
|
break;
|
|
|
|
|
|
case allTypes.IN_QUNEUE:
|
...
|
...
|
@@ -585,10 +418,9 @@ function pageInit() { |
|
|
break;
|
|
|
|
|
|
case allTypes.EVAL_INVITE:
|
|
|
// 客服发起
|
|
|
if (!processInfo.savedEval) {
|
|
|
processInfo.promoter = 2;
|
|
|
showEvalModal();
|
|
|
evalView.open();
|
|
|
}
|
|
|
break;
|
|
|
|
...
|
...
|
@@ -598,7 +430,7 @@ function pageInit() { |
|
|
|
|
|
case allTypes.OP_LEAVE:
|
|
|
socketChat.clear();
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: false,
|
|
|
image: false
|
|
|
});
|
...
|
...
|
@@ -607,7 +439,7 @@ function pageInit() { |
|
|
|
|
|
case allTypes.OFFLINE:
|
|
|
socketChat.clear();
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: false,
|
|
|
image: false
|
|
|
});
|
...
|
...
|
@@ -652,14 +484,14 @@ function pageInit() { |
|
|
},
|
|
|
|
|
|
onOpen: function() {
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
evaluate: false,
|
|
|
'manual-service': false
|
|
|
});
|
|
|
},
|
|
|
|
|
|
onClose: function() {
|
|
|
editArea.setIcons({
|
|
|
edit.setIcons({
|
|
|
emoji: false,
|
|
|
image: false,
|
|
|
evaluate: false,
|
...
|
...
|
@@ -697,14 +529,10 @@ function pageInit() { |
|
|
heightBefore,
|
|
|
heightAfter;
|
|
|
|
|
|
var mode = 2,
|
|
|
width = 100,
|
|
|
height = 100;
|
|
|
|
|
|
msgList = msgList.reverse();
|
|
|
len = msgList.length;
|
|
|
|
|
|
if (msgList[0] && endTime === msgList[0].sendTime) {
|
|
|
if (!len || msgList[0] && endTime === msgList[0].sendTime) {
|
|
|
processInfo.hasMore = false;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -713,25 +541,10 @@ function pageInit() { |
|
|
if (processInfo.hasMore) {
|
|
|
for (i = 0; i < len; i++) {
|
|
|
item = msgList[i];
|
|
|
item.chatMessage.newContent = emojiPrefix(item.chatMessage.newContent);
|
|
|
if (item.chatMessage.type === 2) {
|
|
|
item.chatMessage.newContent = utility.autoProtocol(item.chatMessage.newContent);
|
|
|
item.chatMessage.newContent =
|
|
|
['<img class="img-msg" src="', item.chatMessage.newContent, '">'].join('');
|
|
|
}
|
|
|
receive.preProcess(item);
|
|
|
|
|
|
switch (item.type) {
|
|
|
case allRTs.CU_SEND:
|
|
|
item.userHead = utility.autoProtocol(item.userHead);
|
|
|
|
|
|
if (!item.userHead) {
|
|
|
item.userHead = assetsPrefix + socketConf.defaultUserHead;
|
|
|
} else {
|
|
|
item.userHead = item.userHead
|
|
|
.replace(/\{mode\}/, mode)
|
|
|
.replace(/\{width\}/, width)
|
|
|
.replace(/\{height\}/, height);
|
|
|
}
|
|
|
dom += cusTpl({
|
|
|
userHead: item.userHead,
|
|
|
userName: item.userName,
|
...
|
...
|
@@ -752,7 +565,7 @@ function pageInit() { |
|
|
|
|
|
case allRTs.CS_SEND:
|
|
|
dom += csTpl({
|
|
|
csHead: utility.autoProtocol(item.csHead),
|
|
|
csHead: item.csHead,
|
|
|
csName: item.csName,
|
|
|
sendTimeShort: item.sendTimeLong,
|
|
|
newContent: item.chatMessage.newContent
|
...
|
...
|
@@ -818,6 +631,15 @@ function pageInit() { |
|
|
};
|
|
|
|
|
|
$.getJSON('//www.yohobuy.com/common/passport/?callback=?', param, function(jsonData) {
|
|
|
if (jsonData.code !== 200) {
|
|
|
return location.href = '//www.yohobuy.com/signin.html?refer=' + encodeURIComponent(location.href);
|
|
|
}
|
|
|
|
|
|
// 点击刷新提示
|
|
|
window.onbeforeunload = function() {
|
|
|
return '';
|
|
|
};
|
|
|
|
|
|
if (jsonData && jsonData.data && jsonData.data.result !== -1) {
|
|
|
|
|
|
socketConfCM.userHead = jsonData.data.headIco || '';
|
...
|
...
|
@@ -832,12 +654,14 @@ function pageInit() { |
|
|
});
|
|
|
}());
|
|
|
|
|
|
// tab页title重置
|
|
|
broswer.tabVisible(function() {
|
|
|
document.title = docTitle;
|
|
|
clearInterval(titleInterval);
|
|
|
// 剪切板粘贴发送图片
|
|
|
new ClipPaste('.msg-area', function(path) {
|
|
|
send.image(path);
|
|
|
});
|
|
|
|
|
|
// tab页title重置
|
|
|
broswer.tabVisible(util.removeBlinkAlert);
|
|
|
|
|
|
// 校验留言输入内容
|
|
|
$leaveMsg.find('textarea').bind('change', function() {
|
|
|
var $lm = $('#leaveMsg'),
|
...
|
...
|
@@ -871,58 +695,6 @@ function pageInit() { |
|
|
});
|
|
|
});
|
|
|
|
|
|
// 提交评价
|
|
|
$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({
|
|
|
height: '100%'
|
...
|
...
|
@@ -937,7 +709,7 @@ function pageInit() { |
|
|
$('.qa-list .q').on('click', toggleAnswer);
|
|
|
|
|
|
// 发送订单信息
|
|
|
$sendOrder.on('click', function(e) {
|
|
|
$sendOrder.on('click', function() {
|
|
|
var tag = $(this),
|
|
|
no = tag.data('no'),
|
|
|
nm = tag.data('nm'),
|
...
|
...
|
@@ -946,14 +718,15 @@ function pageInit() { |
|
|
|
|
|
var msgContent = ['单号:', no, '金额:', '¥' + nm, '下单时间:', time, '状态:', status];
|
|
|
|
|
|
sendMessage(e, 10, msgContent);
|
|
|
send.order(msgContent);
|
|
|
});
|
|
|
|
|
|
// 发送图片
|
|
|
$sendImgInput.fileupload({
|
|
|
dataType: 'json',
|
|
|
acceptFileTypes: /(\.|\/)(bmp|gif|jpe?g|png)$/i,
|
|
|
maxFileSize: 5000000, // 5M
|
|
|
url: configDomains.imCs + '/fileManage/uploadFile',
|
|
|
url: gDomains.imCs + '/fileManage/uploadFile', // eslint-disable-line
|
|
|
progressall: function(e, data) {
|
|
|
var progress = parseInt(data.loaded / data.total * 100, 10);
|
|
|
|
...
|
...
|
@@ -966,11 +739,7 @@ function pageInit() { |
|
|
beforeSendMsg();
|
|
|
|
|
|
// 上传成功后发送图片消息
|
|
|
socketConfCM.type = allRTs.CU_SEND;
|
|
|
socketConfCM.chatMessage.content = utility.autoProtocol(res.data.filePath);
|
|
|
socketConfCM.chatMessage.type = 2;
|
|
|
socketConfCM.uuid = uuid.v4();
|
|
|
socketChat.send(socketConfCM);
|
|
|
send.image(util.autoProtocol(res.data.filePath));
|
|
|
}
|
|
|
setTimeout(function() {
|
|
|
$('.progress-bar').fadeOut();
|
...
|
...
|
@@ -1031,41 +800,6 @@ function pageInit() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
// 星评
|
|
|
$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);
|
|
|
|
...
|
...
|
@@ -1095,11 +829,11 @@ function pageInit() { |
|
|
},
|
|
|
|
|
|
2: function() {
|
|
|
showEvalModal();
|
|
|
evalView.open();
|
|
|
},
|
|
|
|
|
|
3: function() {
|
|
|
manualService();
|
|
|
send.manual();
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -1110,7 +844,7 @@ function pageInit() { |
|
|
});
|
|
|
|
|
|
// 设置表情
|
|
|
$document.on('click', '.emoji-component .emoji', setEmoji);
|
|
|
$document.on('click', '.emoji-component .emoji', edit.setEmoji);
|
|
|
|
|
|
// 表情组件隐藏
|
|
|
$document.on('click', function(e) {
|
...
|
...
|
@@ -1137,8 +871,7 @@ function pageInit() { |
|
|
// 关闭聊天窗口
|
|
|
$close.click(function() {
|
|
|
if (processInfo.manual && !processInfo.savedEval) {
|
|
|
// 没有保存过评论
|
|
|
showEvalModal(true);
|
|
|
evalView.open(true);
|
|
|
} else {
|
|
|
window.close();
|
|
|
}
|
...
|
...
|
@@ -1146,7 +879,7 @@ function pageInit() { |
|
|
|
|
|
// 失去焦点更新鼠标位置
|
|
|
$msgArea.on('blur', function() {
|
|
|
cursorPosition = $(this).getCursorPosition();
|
|
|
$(this).recordCursor();
|
|
|
});
|
|
|
|
|
|
// 消息图片放大显示
|
...
|
...
|
@@ -1182,31 +915,13 @@ function pageInit() { |
|
|
processInfo.hasMore &&
|
|
|
fetchHistoryMsg();
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 拉取域名信息
|
|
|
(function() {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/service/domains',
|
|
|
success: function(domains) {
|
|
|
configDomains = domains;
|
|
|
|
|
|
// 检查支持性
|
|
|
(function() {
|
|
|
if (!window.WebSocket) {
|
|
|
$('.un-support').show();
|
|
|
return false;
|
|
|
} else {
|
|
|
socketConf.servers.push(configDomains.imSocket);
|
|
|
pageInit();
|
|
|
}
|
|
|
}());
|
|
|
}
|
|
|
});
|
|
|
}());
|
|
|
// 检查支持性
|
|
|
if (util.isSupport()) {
|
|
|
socketConf.servers.push(gDomains.imSocket); // eslint-disable-line
|
|
|
_loadPage();
|
|
|
} else {
|
|
|
$('.un-support').show();
|
|
|
}
|
|
|
|
|
|
// 点击刷新提示
|
|
|
window.onbeforeunload = function() {
|
|
|
return '';
|
|
|
}; |
...
|
...
|
|