Authored by 李奇

留言和评价原因优化修改

... ... @@ -195,9 +195,9 @@ exports.queryGlobalOrder = (req, res) => {
* cvId 会话id
*/
exports.queryReasons = (req, res) => {
const cvId = req.body.conversationId;
const type = req.body.type;
imApi.queryReasons(cvId)
imApi.queryReasons(type)
.then(result=> {
res.json(result);
})
... ...
... ... @@ -124,12 +124,12 @@ exports.queryGlobalOrder = encryptedUid => {
/**
* 获取评价原因
* @param cvId 会话ID
* @param type 客服设置类型
*/
exports.queryReasons = cvId => {
exports.queryReasons = type => {
let params = {
conversationId: cvId
type
};
return ImService.post('/api/evalute/queryReasonByConversationId', params);
return ImService.post('/api/evalute/queryReasonBySettingType', params);
};
... ...
... ... @@ -153,8 +153,6 @@ var chat = {
onMessage: function(event) {
let received = JSON.parse(event.data);
console.log('客户端接收到消息:', received);
// update 会话id
cmEntity.conversationId = received.newConversationId > 0 ?
received.newConversationId : received.conversationId;
... ... @@ -643,6 +641,19 @@ var 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客服');
... ... @@ -654,18 +665,12 @@ var chat = {
$chatHeader.find('.js-service-txt').text('YOHO客服');
$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 @@ var chat = {
viewData.data.content = viewData.data.content.replace(/^http:/, '');
}
// console.log(viewData);
let $html = $(this.messageT(viewData));
... ...
... ... @@ -58,8 +58,7 @@ function sendMsg(msg) {
if (!window.WebSocket) {
return;
}
if (socket.readyState === WebSocket.OPEN) {
console.log('websocket send: ', JSON.parse(msg));
if (socket && socket.readyState === WebSocket.OPEN) {
socket.send(msg);
} else {
sendFailCallback();
... ...
... ... @@ -49,6 +49,7 @@ var config = {
userName: '', // 用户账号
csId: 0, // 客服 ID
type: 1, // type => [0:没人在线,1:排队,2:接通,3:管理员分配]
isLeaveMessage: 0, // 是否开启留言 1:关闭 2:开启
version: '',
serviceSortId: 0,
serviceSortCode: '',
... ...
... ... @@ -125,9 +125,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
$this.find('.cause span').removeClass('select');
if (starVal < 3) {
let cvId = self.cmEntity.conversationId;
return self.renderReasons(cvId);
return self.renderReasons();
}
$this.hide();
... ... @@ -139,8 +137,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
});
},
renderReasons(cvId) {
let self = this;
renderReasons() {
const self = this;
const YOHO_CS = 2; // 1:企业端 2:YOHO在线客服 3:BLK在线客服 4:MARS在线客服 5:机器人
if (self.reasonsRendered) {
self.$more.show();
... ... @@ -149,7 +148,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
// 评价原因渲染
api.queryReasons({
conversationId: cvId
type: YOHO_CS
})
.done(res => {
if (res && res.code === 200) {
... ...