Showing
6 changed files
with
28 additions
and
25 deletions
@@ -195,9 +195,9 @@ exports.queryGlobalOrder = (req, res) => { | @@ -195,9 +195,9 @@ exports.queryGlobalOrder = (req, res) => { | ||
195 | * cvId 会话id | 195 | * cvId 会话id |
196 | */ | 196 | */ |
197 | exports.queryReasons = (req, res) => { | 197 | exports.queryReasons = (req, res) => { |
198 | - const cvId = req.body.conversationId; | 198 | + const type = req.body.type; |
199 | 199 | ||
200 | - imApi.queryReasons(cvId) | 200 | + imApi.queryReasons(type) |
201 | .then(result=> { | 201 | .then(result=> { |
202 | res.json(result); | 202 | res.json(result); |
203 | }) | 203 | }) |
@@ -124,12 +124,12 @@ exports.queryGlobalOrder = encryptedUid => { | @@ -124,12 +124,12 @@ exports.queryGlobalOrder = encryptedUid => { | ||
124 | 124 | ||
125 | /** | 125 | /** |
126 | * 获取评价原因 | 126 | * 获取评价原因 |
127 | - * @param cvId 会话ID | 127 | + * @param type 客服设置类型 |
128 | */ | 128 | */ |
129 | -exports.queryReasons = cvId => { | 129 | +exports.queryReasons = type => { |
130 | let params = { | 130 | let params = { |
131 | - conversationId: cvId | 131 | + type |
132 | }; | 132 | }; |
133 | 133 | ||
134 | - return ImService.post('/api/evalute/queryReasonByConversationId', params); | 134 | + return ImService.post('/api/evalute/queryReasonBySettingType', params); |
135 | }; | 135 | }; |
@@ -153,8 +153,6 @@ var chat = { | @@ -153,8 +153,6 @@ var chat = { | ||
153 | onMessage: function(event) { | 153 | onMessage: function(event) { |
154 | let received = JSON.parse(event.data); | 154 | let received = JSON.parse(event.data); |
155 | 155 | ||
156 | - console.log('客户端接收到消息:', received); | ||
157 | - | ||
158 | // update 会话id | 156 | // update 会话id |
159 | cmEntity.conversationId = received.newConversationId > 0 ? | 157 | cmEntity.conversationId = received.newConversationId > 0 ? |
160 | received.newConversationId : received.conversationId; | 158 | received.newConversationId : received.conversationId; |
@@ -643,6 +641,19 @@ var chat = { | @@ -643,6 +641,19 @@ var chat = { | ||
643 | const sysInfo = self._sysInfo.bind(this); | 641 | const sysInfo = self._sysInfo.bind(this); |
644 | const chatMessage = cmEntity.chatMessage; | 642 | const chatMessage = cmEntity.chatMessage; |
645 | 643 | ||
644 | + function whetherLeaveMsg(cm) { | ||
645 | + const canLeave = cm.isLeaveMessage === 2; | ||
646 | + const append = canLeave ? '您可以选择<span class="blue" data-trigger="leave-msg">留言</span>' : ''; | ||
647 | + const reg = /[,|,]$/g; | ||
648 | + | ||
649 | + chatMessage.content = canLeave ? | ||
650 | + chatMessage.content : | ||
651 | + (chatMessage.content = chatMessage.content.replace(reg, "")); | ||
652 | + | ||
653 | + canLeave && (self.canLeaveMSG = true); | ||
654 | + sysInfo(`${chatMessage.content || ''}${append}`); | ||
655 | + } | ||
656 | + | ||
646 | 657 | ||
647 | function noService() { | 658 | function noService() { |
648 | $chatHeader.find('.js-service-txt').text('YOHO客服'); | 659 | $chatHeader.find('.js-service-txt').text('YOHO客服'); |
@@ -654,18 +665,12 @@ var chat = { | @@ -654,18 +665,12 @@ var chat = { | ||
654 | $chatHeader.find('.js-service-txt').text('YOHO客服'); | 665 | $chatHeader.find('.js-service-txt').text('YOHO客服'); |
655 | 666 | ||
656 | $chat.append(time(Date.now()).show()); | 667 | $chat.append(time(Date.now()).show()); |
657 | - sysInfo(`${chatMessage.content || ''}您可以选择<span class="blue" data-trigger="leave-msg">留言</span>`); | 668 | + whetherLeaveMsg(cmEntity); |
658 | } | 669 | } |
659 | 670 | ||
660 | // state 1: 排队中 | 671 | // state 1: 排队中 |
661 | function inQueue() { | 672 | function inQueue() { |
662 | - let info = `${chatMessage.content}您可以<span class="blue" data-trigger="leave-msg">留言</span>`; | ||
663 | - | ||
664 | - // let info = '您可以选择<span class="blue" data-trigger="leave-msg">留言</span>,客服会以短信形式回复您'; | ||
665 | - | ||
666 | - self.canLeaveMSG = true; | ||
667 | - | ||
668 | - sysInfo(info); | 673 | + whetherLeaveMsg(cmEntity); |
669 | } | 674 | } |
670 | 675 | ||
671 | // state 2: 人工客服进入 | 676 | // state 2: 人工客服进入 |
@@ -707,7 +712,6 @@ var chat = { | @@ -707,7 +712,6 @@ var chat = { | ||
707 | viewData.data.content = viewData.data.content.replace(/^http:/, ''); | 712 | viewData.data.content = viewData.data.content.replace(/^http:/, ''); |
708 | } | 713 | } |
709 | 714 | ||
710 | - // console.log(viewData); | ||
711 | let $html = $(this.messageT(viewData)); | 715 | let $html = $(this.messageT(viewData)); |
712 | 716 | ||
713 | 717 |
@@ -58,8 +58,7 @@ function sendMsg(msg) { | @@ -58,8 +58,7 @@ function sendMsg(msg) { | ||
58 | if (!window.WebSocket) { | 58 | if (!window.WebSocket) { |
59 | return; | 59 | return; |
60 | } | 60 | } |
61 | - if (socket.readyState === WebSocket.OPEN) { | ||
62 | - console.log('websocket send: ', JSON.parse(msg)); | 61 | + if (socket && socket.readyState === WebSocket.OPEN) { |
63 | socket.send(msg); | 62 | socket.send(msg); |
64 | } else { | 63 | } else { |
65 | sendFailCallback(); | 64 | sendFailCallback(); |
@@ -49,6 +49,7 @@ var config = { | @@ -49,6 +49,7 @@ var config = { | ||
49 | userName: '', // 用户账号 | 49 | userName: '', // 用户账号 |
50 | csId: 0, // 客服 ID | 50 | csId: 0, // 客服 ID |
51 | type: 1, // type => [0:没人在线,1:排队,2:接通,3:管理员分配] | 51 | type: 1, // type => [0:没人在线,1:排队,2:接通,3:管理员分配] |
52 | + isLeaveMessage: 0, // 是否开启留言 1:关闭 2:开启 | ||
52 | version: '', | 53 | version: '', |
53 | serviceSortId: 0, | 54 | serviceSortId: 0, |
54 | serviceSortCode: '', | 55 | serviceSortCode: '', |
@@ -125,9 +125,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -125,9 +125,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
125 | $this.find('.cause span').removeClass('select'); | 125 | $this.find('.cause span').removeClass('select'); |
126 | 126 | ||
127 | if (starVal < 3) { | 127 | if (starVal < 3) { |
128 | - let cvId = self.cmEntity.conversationId; | ||
129 | - | ||
130 | - return self.renderReasons(cvId); | 128 | + return self.renderReasons(); |
131 | } | 129 | } |
132 | 130 | ||
133 | $this.hide(); | 131 | $this.hide(); |
@@ -139,8 +137,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -139,8 +137,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
139 | }); | 137 | }); |
140 | }, | 138 | }, |
141 | 139 | ||
142 | - renderReasons(cvId) { | ||
143 | - let self = this; | 140 | + renderReasons() { |
141 | + const self = this; | ||
142 | + const YOHO_CS = 2; // 1:企业端 2:YOHO在线客服 3:BLK在线客服 4:MARS在线客服 5:机器人 | ||
144 | 143 | ||
145 | if (self.reasonsRendered) { | 144 | if (self.reasonsRendered) { |
146 | self.$more.show(); | 145 | self.$more.show(); |
@@ -149,7 +148,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | @@ -149,7 +148,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { | ||
149 | 148 | ||
150 | // 评价原因渲染 | 149 | // 评价原因渲染 |
151 | api.queryReasons({ | 150 | api.queryReasons({ |
152 | - conversationId: cvId | 151 | + type: YOHO_CS |
153 | }) | 152 | }) |
154 | .done(res => { | 153 | .done(res => { |
155 | if (res && res.code === 200) { | 154 | if (res && res.code === 200) { |
-
Please register or login to post a comment