Authored by ccbikai(👎🏻🍜)

Merge branch 'master' into release/5.6

@@ -164,9 +164,9 @@ exports.queryGlobalOrder = (req, res) => { @@ -164,9 +164,9 @@ exports.queryGlobalOrder = (req, res) => {
164 * cvId 会话id 164 * cvId 会话id
165 */ 165 */
166 exports.queryReasons = (req, res) => { 166 exports.queryReasons = (req, res) => {
167 - const cvId = req.body.conversationId; 167 + const type = req.body.type;
168 168
169 - imApi.queryReasons(cvId) 169 + imApi.queryReasons(type)
170 .then(result=> { 170 .then(result=> {
171 res.json(result); 171 res.json(result);
172 }) 172 })
@@ -120,12 +120,12 @@ exports.queryGlobalOrder = encryptedUid => { @@ -120,12 +120,12 @@ exports.queryGlobalOrder = encryptedUid => {
120 120
121 /** 121 /**
122 * 获取评价原因 122 * 获取评价原因
123 - * @param cvId 会话ID 123 + * @param type 客服设置类型
124 */ 124 */
125 -exports.queryReasons = cvId => { 125 +exports.queryReasons = type => {
126 let params = { 126 let params = {
127 - conversationId: cvId 127 + type
128 }; 128 };
129 129
130 - return ImService.post('/api/evalute/queryReasonByConversationId', params); 130 + return ImService.post('/api/evalute/queryReasonBySettingType', params);
131 }; 131 };
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <div class="title">留言</div> 5 <div class="title">留言</div>
6 </header> 6 </header>
7 <div class="main"> 7 <div class="main">
8 - <textarea name="leave-text" maxlength="120" class="leave-text" placeholder="请输入留言文字,Yoho!Buy有货客服会以短信形式回复您,谢谢您对Yoho!Buy有货的支持!"></textarea> 8 + <textarea name="leave-text" maxlength="120" class="leave-text" placeholder="请输入文字留言。"></textarea>
9 <button class="leave-submit">提交</button> 9 <button class="leave-submit">提交</button>
10 </div> 10 </div>
11 -</div>  
  11 +</div>
@@ -153,8 +153,6 @@ let chat = { @@ -153,8 +153,6 @@ let 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;
@@ -315,7 +313,7 @@ let chat = { @@ -315,7 +313,7 @@ let chat = {
315 this.bootSocket(); 313 this.bootSocket();
316 this.canEvalute = true; 314 this.canEvalute = true;
317 315
318 - this.switchService('rebot'); 316 + this.switchService('robot');
319 }, 317 },
320 318
321 /** 319 /**
@@ -643,29 +641,36 @@ let chat = { @@ -643,29 +641,36 @@ let 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 + self.renderHeader('robot');
649 $chat.append(time(Date.now()).show()); 660 $chat.append(time(Date.now()).show());
650 } 661 }
651 662
652 // state: 0 没有人工客服 663 // state: 0 没有人工客服
653 function noEmploye() { 664 function noEmploye() {
654 - $chatHeader.find('.js-service-txt').text('YOHO客服'); 665 + self.renderHeader('robot');
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 @@ let chat = { @@ -707,7 +712,6 @@ let 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
@@ -826,11 +830,6 @@ let chat = { @@ -826,11 +830,6 @@ let chat = {
826 if (type === 'human') { 830 if (type === 'human') {
827 cmEntity.type = socketConf.recType.MANUAL_SERVICE; 831 cmEntity.type = socketConf.recType.MANUAL_SERVICE;
828 socket.send(JSON.stringify(cmEntity)); 832 socket.send(JSON.stringify(cmEntity));
829 -  
830 - // this._sysInfo();  
831 - } else {  
832 -  
833 - // todo;  
834 } 833 }
835 }, 834 },
836 835
@@ -840,7 +839,7 @@ let chat = { @@ -840,7 +839,7 @@ let chat = {
840 */ 839 */
841 renderHeader: function(type) { 840 renderHeader: function(type) {
842 let header = { 841 let header = {
843 - rebot: { 842 + robot: {
844 title: '智能小YO', 843 title: '智能小YO',
845 right: '<span data-action="change-human">人工客服</span>' 844 right: '<span data-action="change-human">人工客服</span>'
846 }, 845 },
@@ -59,7 +59,6 @@ function sendMsg(msg) { @@ -59,7 +59,6 @@ function sendMsg(msg) {
59 return; 59 return;
60 } 60 }
61 if (socket.readyState === WebSocket.OPEN) { 61 if (socket.readyState === WebSocket.OPEN) {
62 - console.log('websocket send: ', JSON.parse(msg));  
63 socket.send(msg); 62 socket.send(msg);
64 } else { 63 } else {
65 sendFailCallback(); 64 sendFailCallback();
@@ -49,6 +49,7 @@ let config = { @@ -49,6 +49,7 @@ let 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: '',
@@ -65,7 +65,7 @@ LeaveMSGView.prototype = $.extend({}, EventEmitter.prototype, { @@ -65,7 +65,7 @@ LeaveMSGView.prototype = $.extend({}, EventEmitter.prototype, {
65 65
66 api.leaveMsg(content) 66 api.leaveMsg(content)
67 .done(function() { 67 .done(function() {
68 - self.trigger('save.LeaveMSGView', '留言成功,'); 68 + self.trigger('save.LeaveMSGView', '留言成功');
69 self.$input.val(''); 69 self.$input.val('');
70 }) 70 })
71 .fail(function() { 71 .fail(function() {
@@ -123,9 +123,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { @@ -123,9 +123,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
123 $this.find('.cause span').removeClass('select'); 123 $this.find('.cause span').removeClass('select');
124 124
125 if (starVal < 3) { 125 if (starVal < 3) {
126 - let cvId = self.cmEntity.conversationId;  
127 -  
128 - return self.renderReasons(cvId); 126 + return self.renderReasons();
129 } 127 }
130 128
131 $this.hide(); 129 $this.hide();
@@ -137,8 +135,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { @@ -137,8 +135,9 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
137 }); 135 });
138 }, 136 },
139 137
140 - renderReasons(cvId) {  
141 - let self = this; 138 + renderReasons() {
  139 + const self = this;
  140 + const YOHO_CS = 2; // 1:企业端 2:YOHO在线客服 3:BLK在线客服 4:MARS在线客服 5:机器人
142 141
143 if (self.reasonsRendered) { 142 if (self.reasonsRendered) {
144 self.$more.show(); 143 self.$more.show();
@@ -147,7 +146,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { @@ -147,7 +146,7 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
147 146
148 // 评价原因渲染 147 // 评价原因渲染
149 api.queryReasons({ 148 api.queryReasons({
150 - conversationId: cvId 149 + type: YOHO_CS
151 }) 150 })
152 .done(res => { 151 .done(res => {
153 if (res && res.code === 200) { 152 if (res && res.code === 200) {
@@ -195,6 +194,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { @@ -195,6 +194,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
195 }, 194 },
196 195
197 post(data) { 196 post(data) {
  197 + var params;
  198 +
198 if (this.isSending) { 199 if (this.isSending) {
199 tip.show('正在发送..'); 200 tip.show('正在发送..');
200 return; 201 return;
@@ -203,7 +204,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { @@ -203,7 +204,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
203 204
204 const self = this, 205 const self = this,
205 elem = this.elem; 206 elem = this.elem;
206 - let params = { 207 +
  208 + params = {
207 stars: ++this.rank, 209 stars: ++this.rank,
208 promoter: 1, 210 promoter: 1,
209 reasonIds: '', 211 reasonIds: '',