Authored by ccbikai(👎🏻🍜)

Merge branch 'master' into release/5.6

... ... @@ -164,9 +164,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);
})
... ...
... ... @@ -120,12 +120,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);
};
... ...
... ... @@ -5,7 +5,7 @@
<div class="title">留言</div>
</header>
<div class="main">
<textarea name="leave-text" maxlength="120" class="leave-text" placeholder="请输入留言文字,Yoho!Buy有货客服会以短信形式回复您,谢谢您对Yoho!Buy有货的支持!"></textarea>
<textarea name="leave-text" maxlength="120" class="leave-text" placeholder="请输入文字留言。"></textarea>
<button class="leave-submit">提交</button>
</div>
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -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>'
},
... ...
... ... @@ -59,7 +59,6 @@ function sendMsg(msg) {
return;
}
if (socket.readyState === WebSocket.OPEN) {
console.log('websocket send: ', JSON.parse(msg));
socket.send(msg);
} else {
sendFailCallback();
... ...
... ... @@ -49,6 +49,7 @@ let config = {
userName: '', // 用户账号
csId: 0, // 客服 ID
type: 1, // type => [0:没人在线,1:排队,2:接通,3:管理员分配]
isLeaveMessage: 0, // 是否开启留言 1:关闭 2:开启
version: '',
serviceSortId: 0,
serviceSortCode: '',
... ...
... ... @@ -65,7 +65,7 @@ LeaveMSGView.prototype = $.extend({}, EventEmitter.prototype, {
api.leaveMsg(content)
.done(function() {
self.trigger('save.LeaveMSGView', '留言成功,');
self.trigger('save.LeaveMSGView', '留言成功');
self.$input.val('');
})
.fail(function() {
... ... @@ -123,9 +123,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();
... ... @@ -137,8 +135,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();
... ... @@ -147,7 +146,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
// 评价原因渲染
api.queryReasons({
conversationId: cvId
type: YOHO_CS
})
.done(res => {
if (res && res.code === 200) {
... ... @@ -195,6 +194,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
},
post(data) {
var params;
if (this.isSending) {
tip.show('正在发送..');
return;
... ... @@ -203,7 +204,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
const self = this,
elem = this.elem;
let params = {
params = {
stars: ++this.rank,
promoter: 1,
reasonIds: '',
... ...