1
|
-
|
|
|
2
|
/**
|
1
|
/**
|
3
|
* 在线客服客户页
|
2
|
* 在线客服客户页
|
4
|
*
|
3
|
*
|
|
@@ -10,6 +9,7 @@ var $ = require('yoho-jquery'), |
|
@@ -10,6 +9,7 @@ var $ = require('yoho-jquery'), |
10
|
uuid = require('uuid'),
|
9
|
uuid = require('uuid'),
|
11
|
emojiMap = require('./emoji-map'),
|
10
|
emojiMap = require('./emoji-map'),
|
12
|
countdown = require('./countdown'),
|
11
|
countdown = require('./countdown'),
|
|
|
12
|
+ tab = require('./tab-hidden'),
|
13
|
socketChat = require('./socket-chat'),
|
13
|
socketChat = require('./socket-chat'),
|
14
|
socketConf = require('./socket-config'),
|
14
|
socketConf = require('./socket-config'),
|
15
|
common = require('../../../config/common');
|
15
|
common = require('../../../config/common');
|
|
@@ -20,9 +20,13 @@ var cmEntity, |
|
@@ -20,9 +20,13 @@ var cmEntity, |
20
|
encryptedUid,
|
20
|
encryptedUid,
|
21
|
cursorPosition,
|
21
|
cursorPosition,
|
22
|
hasMore = true,
|
22
|
hasMore = true,
|
|
|
23
|
+ titleInterval,
|
|
|
24
|
+ docTitle = document.title,
|
|
|
25
|
+ $document = $(document),
|
23
|
$msgList = $('.msg-list'),
|
26
|
$msgList = $('.msg-list'),
|
24
|
$msgEdit = $('.msg-edit'),
|
27
|
$msgEdit = $('.msg-edit'),
|
25
|
$leaveMsg = $('#leaveMsg'),
|
28
|
$leaveMsg = $('#leaveMsg'),
|
|
|
29
|
+ $close = $('.header .close'),
|
26
|
$sendOrder = $('.send-order'),
|
30
|
$sendOrder = $('.send-order'),
|
27
|
$sendImgInput = $('#sendImg'),
|
31
|
$sendImgInput = $('#sendImg'),
|
28
|
$history = $('.about-his.has-his'),
|
32
|
$history = $('.about-his.has-his'),
|
|
@@ -33,7 +37,7 @@ var cmEntity, |
|
@@ -33,7 +37,7 @@ var cmEntity, |
33
|
$panelMainBody = $('.panel-main .main-body');
|
37
|
$panelMainBody = $('.panel-main .main-body');
|
34
|
|
38
|
|
35
|
var processInfo = {
|
39
|
var processInfo = {
|
36
|
- csId: 0, // 客服Id
|
40
|
+ manual: false,
|
37
|
promoter: 1, // 评论发起者 1:客户自己 2:客服
|
41
|
promoter: 1, // 评论发起者 1:客户自己 2:客服
|
38
|
savedEval: false // 是否保存过评论
|
42
|
savedEval: false // 是否保存过评论
|
39
|
};
|
43
|
};
|
|
@@ -67,24 +71,29 @@ for (key in urls) { |
|
@@ -67,24 +71,29 @@ for (key in urls) { |
67
|
}
|
71
|
}
|
68
|
}
|
72
|
}
|
69
|
|
73
|
|
70
|
-// (function() {
|
|
|
71
|
-// var param = {
|
|
|
72
|
-// return_type: 'jsonp',
|
|
|
73
|
-// method: 'open.passport.get'
|
|
|
74
|
-// };
|
74
|
+// TODO 开发环境拿不到那个jsonp 这段代码仅供开发用
|
|
|
75
|
+// socketChat.init(Object.assign(socketConf, {
|
|
|
76
|
+//
|
|
|
77
|
+// onOpen: function() {
|
|
|
78
|
+// console.log('websocket opened!');
|
|
|
79
|
+// },
|
|
|
80
|
+//
|
|
|
81
|
+// onMessage: function(e) {
|
|
|
82
|
+// var received = JSON.parse(e.data);
|
|
|
83
|
+//
|
|
|
84
|
+// cmEntity.conversationId = received.newConversationId !== 0 ?
|
|
|
85
|
+// received.newConversationId :
|
|
|
86
|
+// received.conversationId;
|
75
|
//
|
87
|
//
|
76
|
-// $.getJSON('//www.yohobuy.com/common/passport/?callback=?', param, function(jsonData) {
|
|
|
77
|
-// if (jsonData && jsonData.data && jsonData.data.result !== -1) {
|
|
|
78
|
-// if(jsonData.data.headIco) {
|
|
|
79
|
-// socketConf.conversationMessage.userHead = jsonData.data.headIco;
|
|
|
80
|
-// socketConf.conversationMessage.userName = window.getUser()[0];
|
|
|
81
|
-// }
|
88
|
+// // 保存过程中信息
|
|
|
89
|
+// getMessage(received);
|
|
|
90
|
+// },
|
82
|
//
|
91
|
//
|
83
|
-// // 原始配置信息用于重新连线
|
|
|
84
|
-// originConf = JSON.parse(JSON.stringify(socketConf));
|
|
|
85
|
-// }
|
|
|
86
|
-// });
|
|
|
87
|
-// }());
|
92
|
+// onClose: function() {
|
|
|
93
|
+// console.log('websocket closed!');
|
|
|
94
|
+// }
|
|
|
95
|
+//
|
|
|
96
|
+// }));
|
88
|
|
97
|
|
89
|
/**
|
98
|
/**
|
90
|
* 设置光标位置
|
99
|
* 设置光标位置
|
|
@@ -222,9 +231,8 @@ function toggleAnswer(e) { |
|
@@ -222,9 +231,8 @@ function toggleAnswer(e) { |
222
|
/**
|
231
|
/**
|
223
|
* 连线客服
|
232
|
* 连线客服
|
224
|
*/
|
233
|
*/
|
225
|
-function connectService() {
|
234
|
+function manualService() {
|
226
|
cmEntity.type = 2;
|
235
|
cmEntity.type = 2;
|
227
|
- console.log(cmEntity);
|
|
|
228
|
socketChat.send(JSON.stringify(cmEntity));
|
236
|
socketChat.send(JSON.stringify(cmEntity));
|
229
|
|
237
|
|
230
|
}
|
238
|
}
|
|
@@ -286,13 +294,16 @@ function enterSuccess(message) { |
|
@@ -286,13 +294,16 @@ function enterSuccess(message) { |
286
|
* @param message 内部消息对象
|
294
|
* @param message 内部消息对象
|
287
|
* @private
|
295
|
* @private
|
288
|
*/
|
296
|
*/
|
289
|
-function _linkSuccess(msgType, message) {
|
297
|
+function linkSuccess(msgType, message) {
|
290
|
|
298
|
|
291
|
var OUT_SERVICE = 0,
|
299
|
var OUT_SERVICE = 0,
|
292
|
LINE_UP = 1,
|
300
|
LINE_UP = 1,
|
293
|
- MANUAL_SERVICE = 2;
|
301
|
+ MANUAL_SERVICE = 2,
|
|
|
302
|
+ ADMIN_MANUAL_SERVICE = 3;
|
294
|
|
303
|
|
295
|
- var liHtml;
|
304
|
+ var liHtml,
|
|
|
305
|
+ $iconEval = $('.icon.evaluate'),
|
|
|
306
|
+ $iconMs = $('.icon.manual-service');
|
296
|
|
307
|
|
297
|
switch (msgType) {
|
308
|
switch (msgType) {
|
298
|
|
309
|
|
|
@@ -323,6 +334,29 @@ function _linkSuccess(msgType, message) { |
|
@@ -323,6 +334,29 @@ function _linkSuccess(msgType, message) { |
323
|
<span class="tip">${message.content}</span>
|
334
|
<span class="tip">${message.content}</span>
|
324
|
</p>
|
335
|
</p>
|
325
|
</div>`;
|
336
|
</div>`;
|
|
|
337
|
+
|
|
|
338
|
+ // 接入人工客服需要评价
|
|
|
339
|
+ processInfo.manual = true;
|
|
|
340
|
+
|
|
|
341
|
+ // 显示评价&隐藏人工
|
|
|
342
|
+ $iconEval.show();
|
|
|
343
|
+ $iconMs.hide();
|
|
|
344
|
+ break;
|
|
|
345
|
+
|
|
|
346
|
+ case ADMIN_MANUAL_SERVICE: // 3是管理员分配客服成功
|
|
|
347
|
+ liHtml =
|
|
|
348
|
+ `<div class="list-item">
|
|
|
349
|
+ <p class="push-tip">
|
|
|
350
|
+ <span class="tip">${message.content}</span>
|
|
|
351
|
+ </p>
|
|
|
352
|
+ </div>`;
|
|
|
353
|
+
|
|
|
354
|
+ // 接入人工客服需要评价
|
|
|
355
|
+ processInfo.manual = true;
|
|
|
356
|
+
|
|
|
357
|
+ // 显示评价&隐藏人工
|
|
|
358
|
+ $iconEval.show();
|
|
|
359
|
+ $iconMs.hide();
|
326
|
break;
|
360
|
break;
|
327
|
|
361
|
|
328
|
default:
|
362
|
default:
|
|
@@ -339,7 +373,7 @@ function _linkSuccess(msgType, message) { |
|
@@ -339,7 +373,7 @@ function _linkSuccess(msgType, message) { |
339
|
* @param text 文本
|
373
|
* @param text 文本
|
340
|
* @private
|
374
|
* @private
|
341
|
*/
|
375
|
*/
|
342
|
-function _emojiPrefix(text) {
|
376
|
+function emojiPrefix(text) {
|
343
|
if (typeof text === 'string') {
|
377
|
if (typeof text === 'string') {
|
344
|
return text.replace(/src="(\d{3}).gif"/g, 'src="/img/service/emoji/$1.gif"');
|
378
|
return text.replace(/src="(\d{3}).gif"/g, 'src="/img/service/emoji/$1.gif"');
|
345
|
}
|
379
|
}
|
|
@@ -351,10 +385,10 @@ function _emojiPrefix(text) { |
|
@@ -351,10 +385,10 @@ function _emojiPrefix(text) { |
351
|
* 处理客户消息
|
385
|
* 处理客户消息
|
352
|
* @private
|
386
|
* @private
|
353
|
*/
|
387
|
*/
|
354
|
-function _handleCusMsg(rec, msgType, message) {
|
388
|
+function handleCusMsg(rec, msgType, message) {
|
355
|
var liHtml;
|
389
|
var liHtml;
|
356
|
|
390
|
|
357
|
- message.newContent = _emojiPrefix(message.newContent);
|
391
|
+ message.newContent = emojiPrefix(message.newContent);
|
358
|
|
392
|
|
359
|
// 图片添加标签
|
393
|
// 图片添加标签
|
360
|
if (msgType === 2) {
|
394
|
if (msgType === 2) {
|
|
@@ -372,8 +406,6 @@ function _handleCusMsg(rec, msgType, message) { |
|
@@ -372,8 +406,6 @@ function _handleCusMsg(rec, msgType, message) { |
372
|
</div>
|
406
|
</div>
|
373
|
</div>`;
|
407
|
</div>`;
|
374
|
|
408
|
|
375
|
-
|
|
|
376
|
- // targetItem.replaceWith(liHtml);
|
|
|
377
|
$msgList.append(liHtml);
|
409
|
$msgList.append(liHtml);
|
378
|
$panelMainBody.scrollTop($panelMainBody[0].scrollHeight);
|
410
|
$panelMainBody.scrollTop($panelMainBody[0].scrollHeight);
|
379
|
|
411
|
|
|
@@ -383,7 +415,7 @@ function _handleCusMsg(rec, msgType, message) { |
|
@@ -383,7 +415,7 @@ function _handleCusMsg(rec, msgType, message) { |
383
|
* 链接终端倒计时
|
415
|
* 链接终端倒计时
|
384
|
* @private
|
416
|
* @private
|
385
|
*/
|
417
|
*/
|
386
|
-function _breakCountdown(message) {
|
418
|
+function breakCountdown(message) {
|
387
|
var liHtml;
|
419
|
var liHtml;
|
388
|
|
420
|
|
389
|
liHtml =
|
421
|
liHtml =
|
|
@@ -401,25 +433,21 @@ function _breakCountdown(message) { |
|
@@ -401,25 +433,21 @@ function _breakCountdown(message) { |
401
|
|
433
|
|
402
|
// 倒计时信息
|
434
|
// 倒计时信息
|
403
|
countdown(message.newContent, $('.tip .countdown'));
|
435
|
countdown(message.newContent, $('.tip .countdown'));
|
404
|
-
|
|
|
405
|
-
|
|
|
406
|
}
|
436
|
}
|
407
|
|
437
|
|
408
|
/**
|
438
|
/**
|
409
|
* 处理客服消息
|
439
|
* 处理客服消息
|
410
|
* @private
|
440
|
* @private
|
411
|
*/
|
441
|
*/
|
412
|
-function _handleCsMsg(rec, msgType, message) {
|
442
|
+function handleCsMsg(rec, msgType, message) {
|
413
|
|
443
|
|
414
|
var liHtml;
|
444
|
var liHtml;
|
415
|
|
445
|
|
416
|
- message.newContent = _emojiPrefix(message.newContent);
|
|
|
417
|
-
|
446
|
+ message.newContent = emojiPrefix(message.newContent);
|
418
|
if (msgType === 2) {
|
447
|
if (msgType === 2) {
|
419
|
message.newContent =
|
448
|
message.newContent =
|
420
|
`<img class="img-msg" src="${message.content}">`;
|
449
|
`<img class="img-msg" src="${message.content}">`;
|
421
|
}
|
450
|
}
|
422
|
-
|
|
|
423
|
liHtml = `<div class="list-item guest">
|
451
|
liHtml = `<div class="list-item guest">
|
424
|
<img src="${rec.csHead}" class="avatar">
|
452
|
<img src="${rec.csHead}" class="avatar">
|
425
|
<div class="item-detail">
|
453
|
<div class="item-detail">
|
|
@@ -440,8 +468,8 @@ function _handleCsMsg(rec, msgType, message) { |
|
@@ -440,8 +468,8 @@ function _handleCsMsg(rec, msgType, message) { |
440
|
function showEvalModal() {
|
468
|
function showEvalModal() {
|
441
|
var $evalModal = $('#makeEvaluation');
|
469
|
var $evalModal = $('#makeEvaluation');
|
442
|
|
470
|
|
443
|
- // 没有客服不可以评价
|
|
|
444
|
- if (!processInfo.csId) {
|
471
|
+ // 没有接入人工
|
|
|
472
|
+ if (!processInfo.manual) {
|
445
|
return;
|
473
|
return;
|
446
|
}
|
474
|
}
|
447
|
|
475
|
|
|
@@ -457,10 +485,10 @@ function showEvalModal() { |
|
@@ -457,10 +485,10 @@ function showEvalModal() { |
457
|
|
485
|
|
458
|
html +=
|
486
|
html +=
|
459
|
`<div class="dis-row">
|
487
|
`<div class="dis-row">
|
460
|
- <span class="type" data-id="${data[i].id}">
|
488
|
+ <span class="type" data-id="${data[i].id}" data-content="${data[i].content}">
|
461
|
${data[i].content}
|
489
|
${data[i].content}
|
462
|
</span>
|
490
|
</span>
|
463
|
- <span class="type" data-id="${data[i + 1].id}">
|
491
|
+ <span class="type" data-id="${data[i + 1].id}" data-content="${data[i].content}">
|
464
|
${data[i + 1].content}
|
492
|
${data[i + 1].content}
|
465
|
</span>
|
493
|
</span>
|
466
|
</div>`;
|
494
|
</div>`;
|
|
@@ -472,10 +500,10 @@ function showEvalModal() { |
|
@@ -472,10 +500,10 @@ function showEvalModal() { |
472
|
for (r = 1, i = 0; r <= ceilRows - 1; r++) {
|
500
|
for (r = 1, i = 0; r <= ceilRows - 1; r++) {
|
473
|
html +=
|
501
|
html +=
|
474
|
`<div class="dis-row">
|
502
|
`<div class="dis-row">
|
475
|
- <span class="type" data-id="${data[i].id}">
|
503
|
+ <span class="type" data-id="${data[i].id}" data-content="${data[i].content}">
|
476
|
${data[i].content}
|
504
|
${data[i].content}
|
477
|
</span>
|
505
|
</span>
|
478
|
- <span class="type" data-id="${data[i + 1].id}">
|
506
|
+ <span class="type" data-id="${data[i + 1].id}" data-content="${data[i].content}">
|
479
|
${data[i + 1].content}
|
507
|
${data[i + 1].content}
|
480
|
</span>
|
508
|
</span>
|
481
|
</div>`;
|
509
|
</div>`;
|
|
@@ -483,7 +511,7 @@ function showEvalModal() { |
|
@@ -483,7 +511,7 @@ function showEvalModal() { |
483
|
}
|
511
|
}
|
484
|
html +=
|
512
|
html +=
|
485
|
`<div class="dis-row">
|
513
|
`<div class="dis-row">
|
486
|
- <span class="type" data-id="${data[len - 1].id}">
|
514
|
+ <span class="type" data-id="${data[len - 1].id}" data-content="${data[i].content}">
|
487
|
${data[len - 1].content}
|
515
|
${data[len - 1].content}
|
488
|
</span>
|
516
|
</span>
|
489
|
</div>`;
|
517
|
</div>`;
|
|
@@ -516,15 +544,24 @@ function showEvalModal() { |
|
@@ -516,15 +544,24 @@ function showEvalModal() { |
516
|
* 处理收到消息
|
544
|
* 处理收到消息
|
517
|
*/
|
545
|
*/
|
518
|
function getMessage(rec) {
|
546
|
function getMessage(rec) {
|
519
|
-
|
|
|
520
|
var tipTpl,
|
547
|
var tipTpl,
|
521
|
recType = rec.type,
|
548
|
recType = rec.type,
|
522
|
message = rec.message,
|
549
|
message = rec.message,
|
523
|
msgType = message.type,
|
550
|
msgType = message.type,
|
|
|
551
|
+ isHidden = tab.tabIsHidden(),
|
524
|
allTypes = socketConf.recType;
|
552
|
allTypes = socketConf.recType;
|
525
|
|
553
|
|
526
|
console.log('客户收到消息!', rec);
|
554
|
console.log('客户收到消息!', rec);
|
527
|
|
555
|
|
|
|
556
|
+ if (isHidden) {
|
|
|
557
|
+ titleInterval = setInterval(function() {
|
|
|
558
|
+ document.title = '您有新消息!';
|
|
|
559
|
+ setTimeout(function() {
|
|
|
560
|
+ document.title = docTitle;
|
|
|
561
|
+ }, 300);
|
|
|
562
|
+ }, 600);
|
|
|
563
|
+ }
|
|
|
564
|
+
|
528
|
switch (recType) {
|
565
|
switch (recType) {
|
529
|
|
566
|
|
530
|
case allTypes.ENTER:
|
567
|
case allTypes.ENTER:
|
|
@@ -532,20 +569,20 @@ function getMessage(rec) { |
|
@@ -532,20 +569,20 @@ function getMessage(rec) { |
532
|
break;
|
569
|
break;
|
533
|
|
570
|
|
534
|
case allTypes.LINK_SUCCESS:
|
571
|
case allTypes.LINK_SUCCESS:
|
535
|
- _linkSuccess(msgType, message);
|
572
|
+ linkSuccess(msgType, message);
|
536
|
break;
|
573
|
break;
|
537
|
|
574
|
|
538
|
case allTypes.CU_SEND:
|
575
|
case allTypes.CU_SEND:
|
539
|
- _handleCusMsg(rec, msgType, message);
|
576
|
+ handleCusMsg(rec, msgType, message);
|
540
|
break;
|
577
|
break;
|
541
|
|
578
|
|
542
|
case allTypes.BREAK_TIME:
|
579
|
case allTypes.BREAK_TIME:
|
543
|
- _breakCountdown(message);
|
580
|
+ breakCountdown(message);
|
544
|
break;
|
581
|
break;
|
545
|
|
582
|
|
546
|
case allTypes.ROBOT_SEND:
|
583
|
case allTypes.ROBOT_SEND:
|
547
|
rec.csName = rec.csName || '客服机器人';
|
584
|
rec.csName = rec.csName || '客服机器人';
|
548
|
- message.newContent = message.newContent || '机器人暂时无法提供服务';
|
585
|
+ message.newContent = message.newContent || '非常抱歉,小YO不是很理解您的问题,您也可以联系<a>人工客服</a>';
|
549
|
tipTpl = `<div class="list-item guest">
|
586
|
tipTpl = `<div class="list-item guest">
|
550
|
<img src="/img/service/robot-avatar.png" class="avatar">
|
587
|
<img src="/img/service/robot-avatar.png" class="avatar">
|
551
|
<div class="item-detail">
|
588
|
<div class="item-detail">
|
|
@@ -559,20 +596,17 @@ function getMessage(rec) { |
|
@@ -559,20 +596,17 @@ function getMessage(rec) { |
559
|
break;
|
596
|
break;
|
560
|
|
597
|
|
561
|
case allTypes.CS_SEND:
|
598
|
case allTypes.CS_SEND:
|
562
|
-
|
|
|
563
|
// 处理客服消息
|
599
|
// 处理客服消息
|
564
|
- _handleCsMsg(rec, msgType, message);
|
600
|
+ handleCsMsg(rec, msgType, message);
|
565
|
break;
|
601
|
break;
|
566
|
|
602
|
|
567
|
case allTypes.EVAL_INVITE:
|
603
|
case allTypes.EVAL_INVITE:
|
568
|
-
|
|
|
569
|
// 客服发起
|
604
|
// 客服发起
|
570
|
processInfo.promoter = 2;
|
605
|
processInfo.promoter = 2;
|
571
|
showEvalModal();
|
606
|
showEvalModal();
|
572
|
break;
|
607
|
break;
|
573
|
|
608
|
|
574
|
case allTypes.CS_CHATTING:
|
609
|
case allTypes.CS_CHATTING:
|
575
|
-
|
|
|
576
|
// 正在人工会话
|
610
|
// 正在人工会话
|
577
|
csChatting(message);
|
611
|
csChatting(message);
|
578
|
break;
|
612
|
break;
|
|
@@ -618,10 +652,10 @@ function msgResolve(msgList) { |
|
@@ -618,10 +652,10 @@ function msgResolve(msgList) { |
618
|
|
652
|
|
619
|
if (hasMore) {
|
653
|
if (hasMore) {
|
620
|
for (item of msgList) {
|
654
|
for (item of msgList) {
|
621
|
- item.message.newContent = _emojiPrefix(item.message.newContent);
|
655
|
+ item.message.newContent = emojiPrefix(item.message.newContent);
|
622
|
if (item.message.type === 2) {
|
656
|
if (item.message.type === 2) {
|
623
|
item.message.newContent =
|
657
|
item.message.newContent =
|
624
|
- ['<img class="msg-img" src="', item.message.newContent, '">'].join('');
|
658
|
+ ['<img class="img-msg" src="', item.message.newContent, '">'].join('');
|
625
|
}
|
659
|
}
|
626
|
|
660
|
|
627
|
// 客户自己的消息
|
661
|
// 客户自己的消息
|
|
@@ -683,30 +717,11 @@ function fetchHistoryMsg() { |
|
@@ -683,30 +717,11 @@ function fetchHistoryMsg() { |
683
|
});
|
717
|
});
|
684
|
}
|
718
|
}
|
685
|
|
719
|
|
686
|
-// 初始化socket连接
|
|
|
687
|
-socketChat.init(Object.assign(socketConf, {
|
|
|
688
|
-
|
|
|
689
|
- onOpen: function() {
|
|
|
690
|
- console.log('websocket opened!');
|
|
|
691
|
- },
|
|
|
692
|
-
|
|
|
693
|
- onMessage: function(e) {
|
|
|
694
|
- var received = JSON.parse(e.data);
|
|
|
695
|
-
|
|
|
696
|
- cmEntity.conversationId = received.newConversationId !== 0 ?
|
|
|
697
|
- received.newConversationId :
|
|
|
698
|
- received.conversationId;
|
|
|
699
|
-
|
|
|
700
|
- // 保存过程中信息
|
|
|
701
|
- processInfo.csId = received.csId;
|
|
|
702
|
- getMessage(received);
|
|
|
703
|
- },
|
|
|
704
|
-
|
|
|
705
|
- onClose: function() {
|
|
|
706
|
- console.log('websocket closed!');
|
|
|
707
|
- }
|
|
|
708
|
-
|
|
|
709
|
-}));
|
720
|
+// tab页title重置
|
|
|
721
|
+tab.tabVisible(function() {
|
|
|
722
|
+ document.title = docTitle;
|
|
|
723
|
+ clearInterval(titleInterval);
|
|
|
724
|
+});
|
710
|
|
725
|
|
711
|
// 提交留言
|
726
|
// 提交留言
|
712
|
$leaveMsg.find('.submit').click(function() {
|
727
|
$leaveMsg.find('.submit').click(function() {
|
|
@@ -740,28 +755,35 @@ $makeEvalModal.find('.submit').click(function() { |
|
@@ -740,28 +755,35 @@ $makeEvalModal.find('.submit').click(function() { |
740
|
star = mEval.find('.star.positive').length,
|
755
|
star = mEval.find('.star.positive').length,
|
741
|
reasonTypes = mEval.find('.dis-row .type.chosen');
|
756
|
reasonTypes = mEval.find('.dis-row .type.chosen');
|
742
|
|
757
|
|
743
|
- var reasonIds,
|
|
|
744
|
- idArray = [];
|
|
|
745
|
-
|
|
|
746
|
- $.each(reasonTypes, function(index, item) {
|
|
|
747
|
- idArray.push($(item).data('id'));
|
|
|
748
|
- });
|
758
|
+ var data = {
|
|
|
759
|
+ conversationId: cmEntity.conversationId,
|
|
|
760
|
+ encryptedUid: encryptedUid,
|
|
|
761
|
+ promoter: processInfo.promoter,
|
|
|
762
|
+ stars: star
|
|
|
763
|
+ };
|
749
|
|
764
|
|
750
|
- reasonIds = idArray.join(':');
|
765
|
+ var contents,
|
|
|
766
|
+ reasonIds,
|
|
|
767
|
+ idArray = [],
|
|
|
768
|
+ contentArray = [];
|
|
|
769
|
+
|
|
|
770
|
+ if (star < 4) {
|
|
|
771
|
+ $.each(reasonTypes, function(index, item) {
|
|
|
772
|
+ idArray.push($(item).data('id'));
|
|
|
773
|
+ contentArray.push($(item).data('content'));
|
|
|
774
|
+ });
|
|
|
775
|
+
|
|
|
776
|
+ reasonIds = idArray.join(':');
|
|
|
777
|
+ contents = contentArray.join(':');
|
|
|
778
|
+ data.reasonIds = reasonIds;
|
|
|
779
|
+ data.reasonMsgs = contents;
|
|
|
780
|
+ data.reasonMsg = reason;
|
|
|
781
|
+ }
|
751
|
|
782
|
|
752
|
$.ajax({
|
783
|
$.ajax({
|
753
|
type: 'POST',
|
784
|
type: 'POST',
|
754
|
url: urls.makeEval,
|
785
|
url: urls.makeEval,
|
755
|
- data: {
|
|
|
756
|
- conversationId: cmEntity.conversationId,
|
|
|
757
|
- csId: processInfo.csId,
|
|
|
758
|
- pid: cmEntity.platId,
|
|
|
759
|
- promoter: processInfo.promoter,
|
|
|
760
|
- reasonIds: reasonIds || '',
|
|
|
761
|
- reasonMsgs: reason,
|
|
|
762
|
- stars: star,
|
|
|
763
|
- encryptedUid: encryptedUid
|
|
|
764
|
- },
|
786
|
+ data: data,
|
765
|
success: function(res) {
|
787
|
success: function(res) {
|
766
|
if (res && res.code === 200) {
|
788
|
if (res && res.code === 200) {
|
767
|
processInfo.promoter = 1;
|
789
|
processInfo.promoter = 1;
|
|
@@ -874,32 +896,35 @@ $sendImgInput.fileupload({ |
|
@@ -874,32 +896,35 @@ $sendImgInput.fileupload({ |
874
|
// 订单信息、常见问题
|
896
|
// 订单信息、常见问题
|
875
|
$rightHeadTab.on('click', function() {
|
897
|
$rightHeadTab.on('click', function() {
|
876
|
var $el = $(this),
|
898
|
var $el = $(this),
|
877
|
- orderTab = $el.hasClass('order');
|
|
|
878
|
-
|
|
|
879
|
- if ($el.hasClass('active')) {
|
899
|
+ $siblings = $el.siblings(),
|
|
|
900
|
+ $panRight = $('.panel-right'),
|
|
|
901
|
+ order = $el.hasClass('order'),
|
|
|
902
|
+ active = $el.hasClass('active'),
|
|
|
903
|
+ $qaUse = $panRight.find('.qa-use'),
|
|
|
904
|
+ $orderUse = $panRight.find('.order-use');
|
|
|
905
|
+
|
|
|
906
|
+ if (active) {
|
880
|
return;
|
907
|
return;
|
881
|
}
|
908
|
}
|
882
|
|
909
|
|
883
|
- if (orderTab) {
|
|
|
884
|
- $('.right-head .tab.order').toggleClass('active');
|
|
|
885
|
- $('.right-head .tab.qa').toggleClass('active');
|
|
|
886
|
- $('.right-body.order').show();
|
|
|
887
|
- $('.right-body.qa').hide();
|
|
|
888
|
- $('.right-footer.qa').hide();
|
910
|
+ $el.addClass('active');
|
|
|
911
|
+ $siblings.removeClass('active');
|
|
|
912
|
+
|
|
|
913
|
+ if (order) {
|
|
|
914
|
+ $qaUse.hide();
|
|
|
915
|
+ $orderUse.show();
|
889
|
} else {
|
916
|
} else {
|
890
|
- $('.right-head .tab.order').toggleClass('active');
|
|
|
891
|
- $('.right-head .tab.qa').toggleClass('active');
|
|
|
892
|
- $('.right-body.order').hide();
|
|
|
893
|
- $('.right-body.qa').show();
|
|
|
894
|
- $('.right-footer.qa').show();
|
917
|
+ $qaUse.show();
|
|
|
918
|
+ $orderUse.hide();
|
895
|
}
|
919
|
}
|
896
|
});
|
920
|
});
|
897
|
|
921
|
|
898
|
// 星评
|
922
|
// 星评
|
899
|
-$('.make-eval .stars .star').on('click', function() {
|
923
|
+$document.on('click', '.make-eval .star', function() {
|
900
|
var el, i, len,
|
924
|
var el, i, len,
|
901
|
tag = $(this),
|
925
|
tag = $(this),
|
902
|
index = tag.index(),
|
926
|
index = tag.index(),
|
|
|
927
|
+ $detailReason = $('.detail-reason'),
|
903
|
textEl = $('.make-eval .star-text'),
|
928
|
textEl = $('.make-eval .star-text'),
|
904
|
startList = $('.make-eval .stars .star');
|
929
|
startList = $('.make-eval .stars .star');
|
905
|
|
930
|
|
|
@@ -917,11 +942,13 @@ $('.make-eval .stars .star').on('click', function() { |
|
@@ -917,11 +942,13 @@ $('.make-eval .stars .star').on('click', function() { |
917
|
el.index() > index && el.removeClass('positive');
|
942
|
el.index() > index && el.removeClass('positive');
|
918
|
}
|
943
|
}
|
919
|
|
944
|
|
|
|
945
|
+ index < 3 && $detailReason.show();
|
|
|
946
|
+ index >= 3 && $detailReason.hide();
|
920
|
textEl.text(starText[index]);
|
947
|
textEl.text(starText[index]);
|
921
|
});
|
948
|
});
|
922
|
|
949
|
|
923
|
// 选择不满意类型
|
950
|
// 选择不满意类型
|
924
|
-$(document).on('click', '.dis-row .type', function(e) {
|
951
|
+$document.on('click', '.dis-row .type', function(e) {
|
925
|
$(e.target).toggleClass('chosen');
|
952
|
$(e.target).toggleClass('chosen');
|
926
|
});
|
953
|
});
|
927
|
|
954
|
|
|
@@ -958,7 +985,7 @@ $msgEdit.find('.util .icon').on('click', function(e) { |
|
@@ -958,7 +985,7 @@ $msgEdit.find('.util .icon').on('click', function(e) { |
958
|
},
|
985
|
},
|
959
|
|
986
|
|
960
|
3: function() {
|
987
|
3: function() {
|
961
|
- connectService();
|
988
|
+ manualService();
|
962
|
}
|
989
|
}
|
963
|
};
|
990
|
};
|
964
|
|
991
|
|
|
@@ -969,13 +996,11 @@ $msgEdit.find('.util .icon').on('click', function(e) { |
|
@@ -969,13 +996,11 @@ $msgEdit.find('.util .icon').on('click', function(e) { |
969
|
});
|
996
|
});
|
970
|
|
997
|
|
971
|
// 设置表情
|
998
|
// 设置表情
|
972
|
-$('.emoji-component .emoji').on('click', setEmoji);
|
999
|
+$document.on('click', '.emoji-component .emoji', setEmoji);
|
973
|
|
1000
|
|
974
|
// 重新连线
|
1001
|
// 重新连线
|
975
|
$msgList.on('click', '.reconnect', function() {
|
1002
|
$msgList.on('click', '.reconnect', function() {
|
976
|
-
|
|
|
977
|
socketChat.init(Object.assign(originConf, {
|
1003
|
socketChat.init(Object.assign(originConf, {
|
978
|
-
|
|
|
979
|
onOpen: function() {
|
1004
|
onOpen: function() {
|
980
|
console.log('websocket opened!');
|
1005
|
console.log('websocket opened!');
|
981
|
},
|
1006
|
},
|
|
@@ -985,8 +1010,8 @@ $msgList.on('click', '.reconnect', function() { |
|
@@ -985,8 +1010,8 @@ $msgList.on('click', '.reconnect', function() { |
985
|
var received = JSON.parse(jsonString);
|
1010
|
var received = JSON.parse(jsonString);
|
986
|
|
1011
|
|
987
|
cmEntity.conversationId = received.newConversationId !== 0 ?
|
1012
|
cmEntity.conversationId = received.newConversationId !== 0 ?
|
988
|
- received.newConversationId :
|
|
|
989
|
- received.conversationId;
|
1013
|
+ received.newConversationId :
|
|
|
1014
|
+ received.conversationId;
|
990
|
|
1015
|
|
991
|
getMessage(received);
|
1016
|
getMessage(received);
|
992
|
},
|
1017
|
},
|
|
@@ -1002,8 +1027,8 @@ $msgList.on('click', '.reconnect', function() { |
|
@@ -1002,8 +1027,8 @@ $msgList.on('click', '.reconnect', function() { |
1002
|
$msgEdit.find('.send').on('click', sendMessage);
|
1027
|
$msgEdit.find('.send').on('click', sendMessage);
|
1003
|
|
1028
|
|
1004
|
// 关闭聊天窗口
|
1029
|
// 关闭聊天窗口
|
1005
|
-$('.header .close').click(function() {
|
|
|
1006
|
- if (processInfo.csId && !processInfo.savedEval) { // 没有保存过评论
|
1030
|
+$close.click(function() {
|
|
|
1031
|
+ if (processInfo.manual && !processInfo.savedEval) { // 没有保存过评论
|
1007
|
showEvalModal();
|
1032
|
showEvalModal();
|
1008
|
} else {
|
1033
|
} else {
|
1009
|
window.close();
|
1034
|
window.close();
|
|
@@ -1023,8 +1048,8 @@ $msgList.on('click', '.msg-bubble .img-msg', function(e) { |
|
@@ -1023,8 +1048,8 @@ $msgList.on('click', '.msg-bubble .img-msg', function(e) { |
1023
|
msgZoomIn.fadeIn();
|
1048
|
msgZoomIn.fadeIn();
|
1024
|
});
|
1049
|
});
|
1025
|
|
1050
|
|
1026
|
-$('.img-zoom-in').on('click', function(e) {
|
|
|
1027
|
- $(e.currentTarget).fadeOut();
|
1051
|
+$document.on('click', '.img-zoom-in', function() {
|
|
|
1052
|
+ $(this).fadeOut();
|
1028
|
});
|
1053
|
});
|
1029
|
|
1054
|
|
1030
|
// 显示历史记录
|
1055
|
// 显示历史记录
|
|
@@ -1038,13 +1063,44 @@ $panelMainBody.scroll(function() { |
|
@@ -1038,13 +1063,44 @@ $panelMainBody.scroll(function() { |
1038
|
});
|
1063
|
});
|
1039
|
|
1064
|
|
1040
|
|
1065
|
|
|
|
1066
|
+// 用户信息获取并初始化socket连接
|
|
|
1067
|
+(function() {
|
|
|
1068
|
+ var param = {
|
|
|
1069
|
+ return_type: 'jsonp',
|
|
|
1070
|
+ method: 'open.passport.get'
|
|
|
1071
|
+ };
|
1041
|
|
1072
|
|
|
|
1073
|
+ $.getJSON('//www.yohobuy.com/common/passport/?callback=?', param, function(jsonData) {
|
|
|
1074
|
+ if (jsonData && jsonData.data && jsonData.data.result !== -1) {
|
1042
|
|
1075
|
|
|
|
1076
|
+ socketConf.conversationMessage.userHead = jsonData.data.headIco || socketConf.config.defaultUserHead;
|
|
|
1077
|
+ socketConf.conversationMessage.userName = window.getUser()[0];
|
1043
|
|
1078
|
|
|
|
1079
|
+ // 原始配置信息用于重新连线
|
|
|
1080
|
+ originConf = JSON.parse(JSON.stringify(socketConf));
|
1044
|
|
1081
|
|
|
|
1082
|
+ socketChat.init(Object.assign(socketConf, {
|
1045
|
|
1083
|
|
|
|
1084
|
+ onOpen: function() {
|
|
|
1085
|
+ console.log('websocket opened!');
|
|
|
1086
|
+ },
|
1046
|
|
1087
|
|
|
|
1088
|
+ onMessage: function(e) {
|
|
|
1089
|
+ var received = JSON.parse(e.data);
|
1047
|
|
1090
|
|
|
|
1091
|
+ cmEntity.conversationId = received.newConversationId !== 0 ?
|
|
|
1092
|
+ received.newConversationId :
|
|
|
1093
|
+ received.conversationId;
|
1048
|
|
1094
|
|
|
|
1095
|
+ // 保存过程中信息
|
|
|
1096
|
+ getMessage(received);
|
|
|
1097
|
+ },
|
1049
|
|
1098
|
|
|
|
1099
|
+ onClose: function() {
|
|
|
1100
|
+ console.log('websocket closed!');
|
|
|
1101
|
+ }
|
1050
|
|
1102
|
|
|
|
1103
|
+ }));
|
|
|
1104
|
+ }
|
|
|
1105
|
+ });
|
|
|
1106
|
+}()); |