bhd-components 0.6.5 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/{8bda9e2e.esm.es5.production.js → 0acf50ef.esm.es5.production.js} +1 -1
  2. package/dist/{d4259367.esm.es5.development.js → 4fa3313f.esm.es5.development.js} +1402 -1140
  3. package/dist/index.esm.es5.development.css +864 -732
  4. package/dist/index.esm.es5.development.js +945 -780
  5. package/dist/index.esm.es5.production.css +1 -1
  6. package/dist/index.esm.es5.production.js +1 -1
  7. package/es2017/customerService/contactsList.d.ts +1 -1
  8. package/es2017/customerService/contactsList.js +11 -145
  9. package/es2017/customerService/function.js +20 -13
  10. package/es2017/customerService/historyFun.js +334 -154
  11. package/es2017/customerService/index.js +567 -437
  12. package/es2017/customerService/index.module.less +169 -65
  13. package/es2017/customerService/index2.module.less +170 -65
  14. package/es2017/icons/components/custom-expand.d.ts +4 -0
  15. package/es2017/icons/components/custom-expand.js +22 -0
  16. package/es2017/icons/components/index.d.ts +1 -0
  17. package/es2017/icons/components/index.js +1 -0
  18. package/esm/customerService/contactsList.d.ts +1 -1
  19. package/esm/customerService/contactsList.js +11 -158
  20. package/esm/customerService/function.js +20 -13
  21. package/esm/customerService/historyFun.js +338 -167
  22. package/esm/customerService/index.js +557 -445
  23. package/esm/customerService/index.module.less +169 -65
  24. package/esm/customerService/index2.module.less +170 -65
  25. package/esm/icons/components/custom-expand.d.ts +4 -0
  26. package/esm/icons/components/custom-expand.js +24 -0
  27. package/esm/icons/components/index.d.ts +1 -0
  28. package/esm/icons/components/index.js +1 -0
  29. package/package.json +1 -1
@@ -47,21 +47,22 @@ var CustomerService = function(props) {
47
47
  var _useState17 = _sliced_to_array(useState(false), 2), firstLoad = _useState17[0], setFirstLoad = _useState17[1]; //第一次切换全屏时滚动到页面底部
48
48
  var _useState18 = _sliced_to_array(useState(45), 2), buttomHei = _useState18[0], setButtomHei = _useState18[1]; //底部输入框的高度
49
49
  var _useState19 = _sliced_to_array(useState(false), 2), showHistory = _useState19[0], setShowHistory = _useState19[1]; //是否显示历史记录
50
- var _useState20 = _sliced_to_array(useState(false), 2), showContacts = _useState20[0], setShowContacts = _useState20[1]; //是否显示关联老师
50
+ var _useState20 = _sliced_to_array(useState(false), 2), showContacts = _useState20[0], setShowContacts = _useState20[1]; //是否显示老师列表
51
51
  var _useState21 = _sliced_to_array(useState(-1), 2), showType = _useState21[0], setShowType = _useState21[1]; //显示聊天框类型 1、侧边栏 2 modal 3 相应的div中 newlabo中使用
52
52
  var _useState22 = _sliced_to_array(useState(-1), 2), answerMode = _useState22[0], setAnswerMode = _useState22[1]; //设置回答模式。1,召唤老师回答
53
53
  var _useState23 = _sliced_to_array(useState([]), 2), teacherList = _useState23[0], setTeacherList = _useState23[1]; //老师列表
54
54
  var _useState24 = _sliced_to_array(useState({}), 2), problem = _useState24[0], setProblem = _useState24[1]; //召唤老师回答的问题
55
- var _useState25 = _sliced_to_array(useState([]), 2), roomList = _useState25[0], setRoomList = _useState25[1]; //聊天列表
55
+ // const [roomList,setRoomList] = useState([]);//聊天列表
56
+ var _useState25 = _sliced_to_array(useState([]), 2), contactsList = _useState25[0], setContactsList = _useState25[1]; //老师列表
56
57
  var _useState26 = _sliced_to_array(useState([]), 2), chatObj = _useState26[0], setChatObj = _useState26[1]; //聊天记录id保存,用来在实验报告中记录
57
58
  var timer = useRef(null); //文本框输入时
58
59
  var receiveMessageTimer = useRef(null); //接收ai发回的消息
59
60
  var voiceCountdownTimer = useRef(null); //语音录制倒计时
60
61
  var listTimer = useRef(null); // 请求列表倒计时
61
62
  var roomMessage = useRef(null); //循环当前页面的新消息
63
+ var chatRoomList = useRef(null); //获取聊天室列表
62
64
  var ctrl = useRef(); //停止生成ai回答时使用
63
65
  var childRef = useRef(null); //获取子组件方法
64
- // const [mid, setmid] = useState(props.userData.mid); //当前用户id
65
66
  var mid = props.userData.mid;
66
67
  var remarkable = new Remarkable({
67
68
  highlight: function highlight(str, lang) {
@@ -83,32 +84,34 @@ var CustomerService = function(props) {
83
84
  clearTimeout(listTimer.current);
84
85
  clearTimeout(timer.current);
85
86
  clearTimeout(roomMessage.current);
87
+ clearTimeout(chatRoomList.current);
86
88
  };
87
89
  }, []);
88
90
  useEffect(function() {
89
91
  var handleScroll = function handleScroll() {
90
92
  var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
91
93
  var scrollTop = container.scrollTop;
92
- // const scrollBottom = container.scroll;
93
94
  var clientHeight = container.clientHeight;
94
95
  var scrollHeight = container.scrollHeight;
95
96
  // console.log(scrollTop,clientHeight,scrollHeight,'333dfkvmdfv')
96
- if (clientHeight + scrollTop + 0.5 >= scrollHeight) {
97
+ if (clientHeight + scrollTop + 0.5 >= scrollHeight && pageNumHistory > 1) {
97
98
  console.log("到底部了22222");
98
- // console.log(11111111,pageNumHistory)
99
- if (pageNumHistory > 1) {
100
- // console.log(pageNumHistory,'pageNumpageNumpageNum')
101
- var number = pageNumHistory - 1;
102
- setPageNumHistory(number);
103
- clearTimeout(listTimer.current);
104
- setBottomLoading(true);
105
- listTimer.current = setTimeout(function() {
106
- // console.log("加载下一页", number);
99
+ // if (pageNumHistory > 1) {
100
+ // console.log(pageNumHistory,'pageNumpageNumpageNum')
101
+ var number = pageNumHistory - 1;
102
+ setPageNumHistory(number);
103
+ clearTimeout(listTimer.current);
104
+ listTimer.current = setTimeout(function() {
105
+ if (number > 0) {
106
+ setBottomLoading(true);
107
107
  getHistoryMessage(number, 4);
108
- }, 1000);
109
- } else {
110
- setLastId("");
111
- }
108
+ } else {
109
+ setPageNumHistory(0);
110
+ }
111
+ }, 100);
112
+ // } else {
113
+ // setLastId("");
114
+ // }
112
115
  }
113
116
  if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
114
117
  console.log("到顶了", pageNum);
@@ -167,13 +170,11 @@ var CustomerService = function(props) {
167
170
  // console.log(props,'lsdkcmsdlcksd')
168
171
  getQuestiionsList("", 1);
169
172
  scrollToBottom();
170
- // less.modifyVars({ "@color-border-Tr": "#f4523b" });
171
173
  setShowType(initShowType);
172
174
  }, [
173
175
  initShowType
174
176
  ]);
175
177
  useEffect(function() {
176
- // console.log(roomId,1111111)
177
178
  if (roomId != "") {
178
179
  if (lastId == "") {
179
180
  getHistoryMessage(pageNum, 2);
@@ -185,30 +186,28 @@ var CustomerService = function(props) {
185
186
  }, [
186
187
  roomId
187
188
  ]);
189
+ //创建聊天室并获取聊天室列表
188
190
  useEffect(function() {
189
- if (roomList.length == 0) {
190
- createRooms("AI").then(function(res) {
191
- setRoomId(res.data.id);
192
- setRoomList([
193
- {
194
- roomId: res.data.id,
195
- unreadCount: 0,
196
- uid: mid,
197
- sender: "AI"
198
- }
199
- ]);
200
- });
201
- } else {
202
- setRoomList(roomList);
203
- }
204
- // recordRef.current.roomList=JSON.parse(JSON.stringify(roomList))
205
- }, [
206
- roomList
207
- ]);
191
+ createRooms("AI").then(function(res) {
192
+ setRoomId(res.data.id);
193
+ });
194
+ roomsListTimer();
195
+ return function() {
196
+ clearTimeout(chatRoomList.current);
197
+ };
198
+ }, []);
208
199
  //进入页面,发送打招呼信息
209
200
  useEffect(function() {
210
- // console.log(historyMessageList, "dkjvndfkjvd33333f");
211
201
  //老师的聊天窗口不发送打招呼信息
202
+ var roomList = contactsList;
203
+ // console.log(roomList,'dkfvdfkjvndfkjvdfv')
204
+ var count = 0;
205
+ roomList.map(function(item) {
206
+ count += item.unreadCount;
207
+ });
208
+ if (count > 0) {
209
+ setShowContacts(true);
210
+ }
212
211
  if (!(roomList.length > 0 && roomList[0].roomId != roomId)) {
213
212
  //是否发送打招呼信息
214
213
  if (greetingMessage && historyMessageList.length == 0) {
@@ -243,7 +242,7 @@ var CustomerService = function(props) {
243
242
  }, [
244
243
  bese64String
245
244
  ]);
246
- //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
245
+ //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
247
246
  var sendGreetingMessage = function(type) {
248
247
  var questionsList = [];
249
248
  var obj = {};
@@ -348,26 +347,21 @@ var CustomerService = function(props) {
348
347
  setKeyWord("");
349
348
  setQuestionsList([]);
350
349
  setCitationContent({});
351
- http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj, {
352
- headers: {
353
- "x-module-id": userData.modules.find(function(ele) {
354
- return ele.short == "IntelligentCustomerService";
355
- }).id,
356
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
357
- }
358
- }).then(function(res) {
350
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
359
351
  if (res.data.id) {
360
- setHistoryMessageList(function(historyMessageList) {
361
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
362
- id: res.data.id,
363
- upvoted: false,
364
- downvoted: false,
365
- quotedMessage: "",
366
- createdAt: getDataTime(-1),
367
- extraInfo: JSON.stringify(obj.extraInfos)
368
- }));
369
- return newHistoryMessageList;
370
- });
352
+ if (pageNumHistory <= 1) {
353
+ setHistoryMessageList(function(historyMessageList) {
354
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
355
+ id: res.data.id,
356
+ upvoted: false,
357
+ downvoted: false,
358
+ quotedMessage: "",
359
+ createdAt: getDataTime(-1),
360
+ extraInfo: JSON.stringify(obj.extraInfos)
361
+ }));
362
+ return newHistoryMessageList;
363
+ });
364
+ }
371
365
  scrollToBottom();
372
366
  if (type == 4) {
373
367
  sendGreetingMessage(6);
@@ -390,7 +384,7 @@ var CustomerService = function(props) {
390
384
  };
391
385
  setProblem({});
392
386
  } else if (type == 2) {
393
- var list = roomList.filter(function(item) {
387
+ var list = contactsList.filter(function(item) {
394
388
  return item.roomId == roomId;
395
389
  });
396
390
  var recevier = "";
@@ -405,16 +399,9 @@ var CustomerService = function(props) {
405
399
  quotedMessage: citationContent.content || ""
406
400
  };
407
401
  }
408
- http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj, {
409
- headers: {
410
- "x-module-id": userData.modules.find(function(ele) {
411
- return ele.short == "TeacherAnswer";
412
- }).id,
413
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
414
- }
415
- }).then(function(res) {
402
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj).then(function(res) {
416
403
  if (res.data.id) {
417
- console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
404
+ // console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
418
405
  if (pageNum == 1 || pageNumHistory == 1 || pageNumHistory == 0) {
419
406
  setHistoryMessageList(function(historyMessageList) {
420
407
  var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
@@ -435,8 +422,8 @@ var CustomerService = function(props) {
435
422
  if (type == 1) {
436
423
  var roomList = [
437
424
  {
438
- "roomId": roomId,
439
- "id": res.data.id
425
+ roomId: roomId,
426
+ id: res.data.id
440
427
  }
441
428
  ];
442
429
  setChatObj(function(list) {
@@ -487,21 +474,23 @@ var CustomerService = function(props) {
487
474
  } else if (userData.modules.some(function(item) {
488
475
  return item.short == "AIservice";
489
476
  })) {
490
- setHistoryMessageList(function(historyMessageList) {
491
- var newHistoryMessageList = historyMessageList.concat({
492
- roomId: roomId,
493
- sender: mid,
494
- recevier: "AI",
495
- message: keyWord,
496
- quotedMessage: citationContent.content,
497
- id: "654321",
498
- upvoted: false,
499
- downvoted: false,
500
- createdAt: getDataTime(-1),
501
- extraInfo: JSON.stringify([])
477
+ if (pageNumHistory <= 1) {
478
+ setHistoryMessageList(function(historyMessageList) {
479
+ var newHistoryMessageList = historyMessageList.concat({
480
+ roomId: roomId,
481
+ sender: mid,
482
+ recevier: "AI",
483
+ message: keyWord,
484
+ quotedMessage: citationContent.content,
485
+ id: "654321",
486
+ upvoted: false,
487
+ downvoted: false,
488
+ createdAt: getDataTime(-1),
489
+ extraInfo: JSON.stringify([])
490
+ });
491
+ return newHistoryMessageList;
502
492
  });
503
- return newHistoryMessageList;
504
- });
493
+ }
505
494
  setFinished(false);
506
495
  aiSendQuestions(3, {
507
496
  //相关数据
@@ -519,39 +508,36 @@ var CustomerService = function(props) {
519
508
  };
520
509
  //向知识库发送问题 或答案 type:1 发送问题 2 接受答案
521
510
  var sendingExistingIssues = function(type, obj, questions) {
522
- setHistoryMessageList(function(historyMessageList) {
523
- var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
524
- id: null,
525
- upvoted: false,
526
- downvoted: false,
527
- createdAt: getDataTime(-1),
528
- extraInfo: JSON.stringify(obj.extraInfos)
529
- }));
530
- return newHistoryMessageList;
531
- });
532
- scrollToBottom();
533
- http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj, {
534
- headers: {
535
- "x-module-id": userData.modules.find(function(ele) {
536
- return ele.short == "IntelligentCustomerService";
537
- }).id,
538
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
539
- }
540
- }).then(function(res) {
511
+ if (pageNumHistory <= 1) {
512
+ setHistoryMessageList(function(historyMessageList) {
513
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
514
+ id: null,
515
+ upvoted: false,
516
+ downvoted: false,
517
+ createdAt: getDataTime(-1),
518
+ extraInfo: JSON.stringify(obj.extraInfos)
519
+ }));
520
+ return newHistoryMessageList;
521
+ });
522
+ scrollToBottom();
523
+ }
524
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
541
525
  if (res.data.id) {
542
- //更新聊天记录id
543
- setHistoryMessageList(function(historyMessageList) {
544
- var newHistoryMessageList = historyMessageList.map(function(item) {
545
- if (item.id == null) {
546
- return _object_spread_props(_object_spread({}, item), {
547
- id: res.data.id
548
- });
549
- } else {
550
- return item;
551
- }
526
+ if (pageNumHistory <= 1) {
527
+ //更新聊天记录id
528
+ setHistoryMessageList(function(historyMessageList) {
529
+ var newHistoryMessageList = historyMessageList.map(function(item) {
530
+ if (item.id == null) {
531
+ return _object_spread_props(_object_spread({}, item), {
532
+ id: res.data.id
533
+ });
534
+ } else {
535
+ return item;
536
+ }
537
+ });
538
+ return newHistoryMessageList;
552
539
  });
553
- return newHistoryMessageList;
554
- });
540
+ }
555
541
  }
556
542
  if (type == 1) {
557
543
  //发送答案,调用自动回答
@@ -570,31 +556,15 @@ var CustomerService = function(props) {
570
556
  sendingExistingIssues(2, dataObj, "");
571
557
  testLabQuestion(obj.message, questions.answer, "");
572
558
  }
573
- }).then(function(res) {
574
- console.log(res);
575
559
  });
576
560
  };
577
561
  //向AI发送问题 type == 1 发送点赞或踩消息,type == 2 发送重新生成消息,type == 3 正常发送消息
578
562
  var content = ""; //用于实验报告的问题记录
579
563
  var aiSendQuestions = function(type, obj, id) {
580
564
  content = "";
581
- // if (type == 3) {
582
- // try {
583
- // if (ctrl && ctrl.current) {
584
- // ctrl.current.abort();
585
- // }
586
- // } catch (error) {}
587
- // clearTimeout(receiveMessageTimer.current);
588
- // setHistoryMessageList((historyMessageList) => {
589
- // return historyMessageList.filter((item) => item.id != "123456");
590
- // });
591
- // setFinished(true);
592
- // return;
593
- // }
594
565
  ctrl.current = new AbortController();
595
566
  clearTimeout(receiveMessageTimer.current);
596
567
  receiveMessageTimer.current = setTimeout(function() {
597
- // console.log('超时终止1111')
598
568
  setHistoryMessageList(function(historyMessageList) {
599
569
  return historyMessageList.filter(function(item) {
600
570
  return item.id != "123456" && item.id != "654321";
@@ -632,39 +602,42 @@ var CustomerService = function(props) {
632
602
  setTimeout(function() {
633
603
  setQuestionsList([]);
634
604
  }, 2000);
605
+ // console.log(pageNumHistory,44444444444444);
635
606
  //占位信息
636
- setHistoryMessageList(function(historyMessageList) {
637
- if (type == 2) {
638
- return historyMessageList.map(function(item) {
639
- if (item.id == id) {
640
- return {
641
- roomId: roomId,
642
- sender: "AI",
643
- recevier: mid,
644
- message: "正在输入...",
645
- id: "123456",
646
- createdAt: getDataTime(-1),
647
- extraInfo: null
648
- };
649
- } else {
650
- return item;
651
- }
652
- });
653
- } else {
654
- return historyMessageList.concat({
655
- roomId: roomId,
656
- sender: "AI",
657
- recevier: mid,
658
- message: "正在输入...",
659
- id: "123456",
660
- createdAt: getDataTime(-1),
661
- extraInfo: null
662
- });
663
- }
664
- });
665
- setTimeout(function() {
666
- scrollToBottom();
667
- }, 10);
607
+ if (pageNumHistory <= 1) {
608
+ setHistoryMessageList(function(historyMessageList) {
609
+ if (type == 2) {
610
+ return historyMessageList.map(function(item) {
611
+ if (item.id == id) {
612
+ return {
613
+ roomId: roomId,
614
+ sender: "AI",
615
+ recevier: mid,
616
+ message: "正在输入...",
617
+ id: "123456",
618
+ createdAt: getDataTime(-1),
619
+ extraInfo: null
620
+ };
621
+ } else {
622
+ return item;
623
+ }
624
+ });
625
+ } else {
626
+ return historyMessageList.concat({
627
+ roomId: roomId,
628
+ sender: "AI",
629
+ recevier: mid,
630
+ message: "正在输入...",
631
+ id: "123456",
632
+ createdAt: getDataTime(-1),
633
+ extraInfo: null
634
+ });
635
+ }
636
+ });
637
+ setTimeout(function() {
638
+ scrollToBottom();
639
+ }, 10);
640
+ }
668
641
  //使用fetchEventSource接收数据
669
642
  var eventSource = fetchEventSource("".concat(urllocation, "/chat-service/public/v1.0/chat-with-ai/messages"), {
670
643
  method: "POST",
@@ -674,7 +647,7 @@ var CustomerService = function(props) {
674
647
  "X-Auth-Jwt": window.localStorage.getItem("usertoken") || "",
675
648
  "Auth-Token": userData.token,
676
649
  "X-Module-Id": userData.modules.find(function(ele) {
677
- return ele.short == "AIservice";
650
+ return ele.short == "IntelligentCustomerService";
678
651
  }).id
679
652
  },
680
653
  body: data,
@@ -785,7 +758,9 @@ var CustomerService = function(props) {
785
758
  };
786
759
  //渲染AI回答
787
760
  var renderAiAnswer = function(msg, message_id, type) {
761
+ // console.log(pageNumHistory,5555555);
788
762
  // console.log(aiSendQuestions().abort(),'slkdsdsdsd')
763
+ if (pageNumHistory > 1) return;
789
764
  var obj = msg;
790
765
  var id = msg.messageId;
791
766
  setHistoryMessageList(function(historyMessageList) {
@@ -837,9 +812,9 @@ var CustomerService = function(props) {
837
812
  return newHistoryMessageList2;
838
813
  }
839
814
  });
840
- setTimeout(function() {
841
- scrollToBottom();
842
- }, 10);
815
+ // setTimeout(() => {
816
+ scrollToBottom();
817
+ // }, 10);
843
818
  };
844
819
  //问题记录到实验报告中
845
820
  var testLabQuestion = function(title, content, teachId) {
@@ -851,13 +826,6 @@ var CustomerService = function(props) {
851
826
  teachId: teachId != undefined ? teachId : chatWith.uid | mid,
852
827
  stepId: stepId,
853
828
  stepIds: stepIds
854
- }, {
855
- headers: {
856
- "x-module-id": userData.modules.find(function(ele) {
857
- return ele.short == "IntelligentCustomerService";
858
- }).id,
859
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
860
- }
861
829
  }).then(function() {
862
830
  console.log(roomId, chatObj, "roomIdroomIdroomIdroomId");
863
831
  setChatObj(function(list1) {
@@ -873,13 +841,6 @@ var CustomerService = function(props) {
873
841
  var speechToText = function() {
874
842
  http.post("".concat(urllocation, "/chat-service/public/v1.0/speech:recognize"), {
875
843
  audio: bese64String
876
- }, {
877
- headers: {
878
- "x-module-id": userData.modules.find(function(ele) {
879
- return ele.short == "AIservice";
880
- }).id,
881
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
882
- }
883
844
  }).then(function(res) {
884
845
  setVoiceRecordingStatus(3);
885
846
  if (res.data) {
@@ -895,20 +856,13 @@ var CustomerService = function(props) {
895
856
  var createRooms = function(uid) {
896
857
  return http.post("".concat(urllocation, "/chat-service/public/v1.0/rooms"), {
897
858
  chatWith: uid
898
- }, {
899
- headers: {
900
- "x-module-id": userData.modules.find(function(ele) {
901
- return ele.short == "IntelligentCustomerService";
902
- }).id,
903
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
904
- }
905
859
  });
906
860
  };
907
861
  //获取历史消息 flag:1,历史记录点击定位,2,代表是上拉加载,3,存在新的消息-->老师回答等,4,下拉加载,滚动到底部时,主要用于查看历史记录
908
862
  var getHistoryMessage = function(pageNum, flag) {
909
- var id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "1";
863
+ var id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "1", raw_data = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [];
910
864
  clearTimeout(roomMessage.current);
911
- console.log(pageNum, flag, "dkfjvndfjvndfkvdf");
865
+ // console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
912
866
  // flag == 1 时已经设置好了位置标记
913
867
  var last_id = "";
914
868
  if (flag == 2 && historyMessageList.length > 0) {
@@ -923,31 +877,29 @@ var CustomerService = function(props) {
923
877
  }
924
878
  var rid = flag == 3 ? id : roomId;
925
879
  if (rid == "") return;
880
+ var page = pageNum ? pageNum : 1;
926
881
  return http.get("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), {
927
882
  params: {
928
883
  roomId: rid,
929
- page: pageNum ? pageNum : 1,
884
+ page: page,
930
885
  maxPageSize: 30,
931
886
  direction: "desc"
932
- },
933
- headers: {
934
- "x-module-id": userData.modules.find(function(ele) {
935
- return ele.short == "IntelligentCustomerService";
936
- }).id,
937
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
938
887
  }
939
888
  }).then(function(res) {
940
889
  var totalNumber = 0;
941
- var roomList = [];
942
- setRoomList(function(list) {
943
- roomList = list;
944
- return list;
945
- });
890
+ var roomList = contactsList;
946
891
  if (res.data.messages.length > 0) {
947
892
  clearTimeout(listTimer.current);
948
893
  var total = res.data.total;
949
894
  var maxPageSize = 30;
950
895
  var dataList = res.data.messages.reverse();
896
+ //历史记录点击进来的,多加载一页,防止定位不准
897
+ if (flag == 1 && page > 1) {
898
+ var markPage = page - 1;
899
+ setPageNumHistory(markPage);
900
+ getHistoryMessage(page - 1, 5, "1", dataList);
901
+ return;
902
+ }
951
903
  setPageCount(Math.ceil(total / maxPageSize));
952
904
  var newHistoryMessageList = [];
953
905
  setHistoryMessageList(function(historyMessageList) {
@@ -956,6 +908,9 @@ var CustomerService = function(props) {
956
908
  if (flag == 1) {
957
909
  newHistoryMessageList = dataList;
958
910
  }
911
+ if (flag == 5) {
912
+ newHistoryMessageList = raw_data.concat(dataList);
913
+ }
959
914
  if (flag == 4) {
960
915
  newHistoryMessageList = historyMessageList.concat(dataList); //下拉加载,向后追加内容
961
916
  }
@@ -977,6 +932,7 @@ var CustomerService = function(props) {
977
932
  totalNumber = newHistoryMessageList.length;
978
933
  return newHistoryMessageList;
979
934
  });
935
+ // console.log(lastId,'lastIdlastId-------')
980
936
  //如果在跟老师的聊天窗口,用于找到与老师的最新的聊天,并不在与老师对话的窗口中,并聊天窗口相同
981
937
  try {
982
938
  if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4)) {
@@ -1015,6 +971,7 @@ var CustomerService = function(props) {
1015
971
  });
1016
972
  var isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
1017
973
  if (!isAiChatWindow && roomList.length > 0 && (pageNum == 1 || pageNumHistory == 0)) {
974
+ //&& pageNum == 1
1018
975
  getRoomidHistoryMessage(totalNumber, rid);
1019
976
  }
1020
977
  }).catch(function(res) {
@@ -1033,14 +990,8 @@ var CustomerService = function(props) {
1033
990
  params: {
1034
991
  roomId: rid,
1035
992
  page: 1,
1036
- maxPageSize: totalNumber,
993
+ maxPageSize: totalNumber == 0 ? 30 : totalNumber,
1037
994
  direction: "desc"
1038
- },
1039
- headers: {
1040
- "x-module-id": userData.modules.find(function(ele) {
1041
- return ele.short == "IntelligentCustomerService";
1042
- }).id,
1043
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1044
995
  }
1045
996
  }).then(function(res) {
1046
997
  var newHistoryMessageList = [];
@@ -1059,7 +1010,7 @@ var CustomerService = function(props) {
1059
1010
  newList = newHistoryMessageList.length;
1060
1011
  return newHistoryMessageList;
1061
1012
  });
1062
- console.log(dataList.length, originList, lastId, "dfkvdnfkvdfj44444");
1013
+ // console.log(dataList.length , originList,lastId,'dfkvdnfkvdfj44444');
1063
1014
  if (!lastId && originList != newList) {
1064
1015
  setTimeout(function() {
1065
1016
  scrollToBottom();
@@ -1107,8 +1058,7 @@ var CustomerService = function(props) {
1107
1058
  console.log(newMessage, "newMessagenewMessage");
1108
1059
  var result = [];
1109
1060
  newMessage.forEach(function(item, index) {
1110
- var isQuestion = item.receiver !== mid //是否为问题
1111
- ;
1061
+ var isQuestion = item.receiver !== mid; //是否为问题
1112
1062
  if (isQuestion) {
1113
1063
  //问题
1114
1064
  if (newMessage[index + 1] && newMessage[index + 1].receiver === mid) {
@@ -1140,13 +1090,6 @@ var CustomerService = function(props) {
1140
1090
  }
1141
1091
  http.post(url, {
1142
1092
  messageId: id
1143
- }, {
1144
- headers: {
1145
- "x-module-id": userData.modules.find(function(ele) {
1146
- return ele.short == "IntelligentCustomerService";
1147
- }).id,
1148
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1149
- }
1150
1093
  }).then(function(res) {
1151
1094
  setHistoryMessageList(function(historyMessageList) {
1152
1095
  var list = historyMessageList;
@@ -1171,13 +1114,6 @@ var CustomerService = function(props) {
1171
1114
  }
1172
1115
  http.post(url, {
1173
1116
  messageId: id
1174
- }, {
1175
- headers: {
1176
- "x-module-id": userData.modules.find(function(ele) {
1177
- return ele.short == "IntelligentCustomerService";
1178
- }).id,
1179
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1180
- }
1181
1117
  }).then(function(res) {
1182
1118
  setHistoryMessageList(function(historyMessageList) {
1183
1119
  var list = historyMessageList;
@@ -1207,13 +1143,7 @@ var CustomerService = function(props) {
1207
1143
  };
1208
1144
  }
1209
1145
  http.get("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions"), {
1210
- params: data,
1211
- headers: {
1212
- "x-module-id": userData.modules.find(function(ele) {
1213
- return ele.short == "IntelligentCustomerService";
1214
- }).id,
1215
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1216
- }
1146
+ params: data
1217
1147
  }).then(function(res) {
1218
1148
  if (res.data.questions) {
1219
1149
  if (flag == 1) {
@@ -1229,12 +1159,6 @@ var CustomerService = function(props) {
1229
1159
  http.get("".concat(urllocation, "/chat-service/public/v1.0/teachers"), {
1230
1160
  params: {
1231
1161
  name: keyWord
1232
- },
1233
- headers: {
1234
- "x-module-id": userData.modules.find(function(ele) {
1235
- return ele.short == "TeacherAnswer";
1236
- }).id,
1237
- "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1238
1162
  }
1239
1163
  }).then(function(res) {
1240
1164
  console.log(res);
@@ -1243,6 +1167,90 @@ var CustomerService = function(props) {
1243
1167
  }
1244
1168
  });
1245
1169
  };
1170
+ //获取聊天室列表
1171
+ var roomsListTimer = function() {
1172
+ if (chatRoomList != null) clearTimeout(chatRoomList.current);
1173
+ chatRoomList.current = setTimeout(function() {
1174
+ return roomsListTimer();
1175
+ }, 60000);
1176
+ http.get("".concat(urllocation, "/chat-service/public/v1.0/rooms"), {
1177
+ params: {
1178
+ page: 1,
1179
+ maxPageSize: 100002
1180
+ }
1181
+ }).then(function(res) {
1182
+ if (res.data) {
1183
+ var list = res.data.contacts;
1184
+ setContactsList(function(list1) {
1185
+ list = list.map(function(item, index) {
1186
+ var c_list = list1.filter(function(e) {
1187
+ return e.sender == item.sender;
1188
+ });
1189
+ var obj = {};
1190
+ if (c_list.length > 0) {
1191
+ obj = c_list[0];
1192
+ }
1193
+ return _object_spread({}, obj, item);
1194
+ });
1195
+ return list;
1196
+ });
1197
+ getUserInfo(list);
1198
+ }
1199
+ });
1200
+ };
1201
+ //获取老师的信息等
1202
+ var getUserInfo = function(list) {
1203
+ var getUserid = [];
1204
+ //查找需要用户名和头像的
1205
+ list.map(function(item, i) {
1206
+ if (!item.name && !item.headImg && item.sender != "AI") {
1207
+ getUserid.push(item.sender);
1208
+ }
1209
+ });
1210
+ if (getUserid.length > 0) {
1211
+ getUserName(getUserid.join(",")).then(function(res) {
1212
+ if (res.data) {
1213
+ var nameList = res.data;
1214
+ // console.log(nameList,contactsList,'kdsjnvjdkvdfj')
1215
+ setContactsList(function(contactsList) {
1216
+ list = list.map(function(item, index) {
1217
+ var name = nameList.filter(function(v) {
1218
+ return v.uid == item.sender;
1219
+ });
1220
+ if (name.length > 0) {
1221
+ return _object_spread({}, item, name[0]);
1222
+ } else {
1223
+ return item;
1224
+ }
1225
+ });
1226
+ return list;
1227
+ });
1228
+ }
1229
+ });
1230
+ } else {
1231
+ setContactsList(function(contactsList) {
1232
+ list = list.map(function(item, index) {
1233
+ var c_list = contactsList.filter(function(e) {
1234
+ return e.sender == item.sender;
1235
+ });
1236
+ var obj = {};
1237
+ if (c_list.length > 0) {
1238
+ obj = c_list[0];
1239
+ }
1240
+ return _object_spread({}, obj, item);
1241
+ });
1242
+ return list;
1243
+ });
1244
+ }
1245
+ };
1246
+ //获取老师用户名
1247
+ var getUserName = function(uid) {
1248
+ return http.get("".concat(urllocation, "/chat-service/public/v1.0/userinfo"), {
1249
+ params: {
1250
+ uid: uid
1251
+ }
1252
+ });
1253
+ };
1246
1254
  //设置滚动条滚动到底部
1247
1255
  var scrollToBottom = function() {
1248
1256
  var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
@@ -1258,10 +1266,16 @@ var CustomerService = function(props) {
1258
1266
  try {
1259
1267
  setTimeout(function() {
1260
1268
  var top = showType == 1 || showType == 3 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
1269
+ // let top =
1270
+ // showType == 1 || showType == 3
1271
+ // ? $("#li_flag").offset().top
1272
+ // : $("#chat_content_modal #li_flag").offset().top -
1273
+ // $("#chat_content_modal").offset().top;
1274
+ // console.log(top2,top,444444444444)
1261
1275
  $("#".concat(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal")).animate({
1262
1276
  scrollTop: top
1263
1277
  }, 0);
1264
- }, 10);
1278
+ }, 100);
1265
1279
  } catch (error) {}
1266
1280
  setLoading(false);
1267
1281
  }
@@ -1281,19 +1295,34 @@ var CustomerService = function(props) {
1281
1295
  });
1282
1296
  });
1283
1297
  };
1284
- //渲染头部
1285
- var renderHeader = function() {
1286
- var list = roomList.filter(function(e) {
1298
+ //显示未读消息
1299
+ var showUnreadMessage = function() {
1300
+ var count = 0;
1301
+ contactsList.map(function(item) {
1302
+ count = count + item.unreadCount;
1303
+ });
1304
+ if (count > 0) {
1305
+ return /*#__PURE__*/ _jsx("span", {
1306
+ className: styles.count,
1307
+ children: count > 99 ? "99+" : count
1308
+ });
1309
+ } else {
1310
+ return "";
1311
+ }
1312
+ };
1313
+ //显示聊天室名字
1314
+ var showChatRoomName = function() {
1315
+ var title = "AI助手";
1316
+ var list = contactsList.filter(function(e) {
1287
1317
  return e.roomId == roomId;
1288
1318
  });
1289
- var title = "智能问答";
1290
1319
  if (list.length > 0 && list[0].name) {
1291
1320
  title = list[0].name;
1292
1321
  }
1293
- var count = 0;
1294
- roomList.map(function(item) {
1295
- count = count + item.unreadCount;
1296
- });
1322
+ return title;
1323
+ };
1324
+ //渲染头部
1325
+ var renderHeader = function() {
1297
1326
  if (showType == 4) {
1298
1327
  return /*#__PURE__*/ _jsxs("div", {
1299
1328
  className: styles.top,
@@ -1301,7 +1330,7 @@ var CustomerService = function(props) {
1301
1330
  /*#__PURE__*/ _jsx("div", {
1302
1331
  className: styles.user,
1303
1332
  children: /*#__PURE__*/ _jsx("p", {
1304
- children: title
1333
+ children: showChatRoomName()
1305
1334
  })
1306
1335
  }),
1307
1336
  /*#__PURE__*/ _jsxs("div", {
@@ -1352,13 +1381,10 @@ var CustomerService = function(props) {
1352
1381
  },
1353
1382
  children: [
1354
1383
  /*#__PURE__*/ _jsx(CustomContacts, {}),
1355
- count > 0 ? /*#__PURE__*/ _jsx("span", {
1356
- className: styles.count,
1357
- children: count > 99 ? "99+" : count
1358
- }) : ""
1384
+ showUnreadMessage()
1359
1385
  ]
1360
1386
  }),
1361
- title
1387
+ showChatRoomName()
1362
1388
  ]
1363
1389
  })
1364
1390
  }),
@@ -1381,7 +1407,13 @@ var CustomerService = function(props) {
1381
1407
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
1382
1408
  // switchDialogBox(3, true);
1383
1409
  setShowType(2);
1384
- childRef.current.roomsListTimer();
1410
+ setTimeout(function() {
1411
+ setKeyWord(" ");
1412
+ }, 100);
1413
+ setTimeout(function() {
1414
+ setKeyWord("");
1415
+ }, 300);
1416
+ // childRef.current.roomsListTimer();
1385
1417
  },
1386
1418
  children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
1387
1419
  }) : /*#__PURE__*/ _jsx("i", {
@@ -1406,7 +1438,7 @@ var CustomerService = function(props) {
1406
1438
  var resettingBottomHei = function() {
1407
1439
  setTimeout(function() {
1408
1440
  if (showType == 1 || showType == 3) {
1409
- if (document.getElementById("Drawer_buttom_modal")) {
1441
+ if (document.getElementById("Drawer_buttom")) {
1410
1442
  var hei = document.getElementById("Drawer_buttom").offsetHeight;
1411
1443
  setButtomHei(hei);
1412
1444
  }
@@ -1420,28 +1452,50 @@ var CustomerService = function(props) {
1420
1452
  };
1421
1453
  //切换聊天室 type == renew ,存在新消息
1422
1454
  var switchChatRoom = function(id, type) {
1423
- setLastId("");
1424
- setPageNum(1);
1425
- setPageCount(0);
1426
- setRoomId(id);
1427
- //
1428
- // if (type == "renew") {
1429
- // getHistoryMessage(1, 3,id);
1430
- // }else{
1431
- // setRoomId(id);
1432
- // }
1433
- readMessage(id, urllocation, userData, http);
1434
- };
1435
- var saveContactsList = function(list) {
1436
- if (list != undefined) {
1437
- setRoomList(list);
1455
+ if (type != "1") {
1456
+ readMessage(id, urllocation, userData, http);
1457
+ setLastId("");
1458
+ setPageNum(1);
1459
+ setPageCount(0);
1460
+ setRoomId(id);
1461
+ try {
1462
+ if (ctrl && ctrl.current) {
1463
+ ctrl.current.abort();
1464
+ }
1465
+ setFinished(true);
1466
+ } catch (error) {}
1467
+ setTimeout(function() {
1468
+ roomsListTimer();
1469
+ }, 500);
1438
1470
  }
1471
+ //删除聊天室
1472
+ if (type == "1") {
1473
+ if (id == roomId) {
1474
+ // console.log(contactsList,888888);
1475
+ switchChatRoom(contactsList[0].roomId, "");
1476
+ }
1477
+ setContactsList(function(list) {
1478
+ var newList = list;
1479
+ newList = newList.filter(function(v) {
1480
+ return v.roomId != id;
1481
+ });
1482
+ return newList;
1483
+ });
1484
+ }
1485
+ // if (type == "renew") {
1486
+ // getHistoryMessage(1, 3,id);
1487
+ // }else{
1488
+ // setRoomId(id);
1489
+ // }
1439
1490
  };
1491
+ // const saveContactsList = (list: any)=>{
1492
+ // console.log(list,44444444)
1493
+ // // if(list != undefined){
1494
+ // // setRoomList(list);
1495
+ // // }
1496
+ // }
1440
1497
  //渲染问答
1441
1498
  var renderQuestion = function() {
1442
- // 2023-12-01T14:34:07
1443
- // console.log(lastId,'lastIdlastIdlastId')
1444
- // console.log(mid, historyMessageList, "ddkfdscksdcs");
1445
1499
  if (historyMessageList.length > 0) {
1446
1500
  return /*#__PURE__*/ _jsx("ul", {
1447
1501
  className: styles.message_con,
@@ -1492,62 +1546,67 @@ var CustomerService = function(props) {
1492
1546
  children: /*#__PURE__*/ _jsxs("div", {
1493
1547
  className: styles.main_content,
1494
1548
  children: [
1495
- /*#__PURE__*/ _jsx("div", {
1496
- className: styles.operate_modal,
1497
- children: /*#__PURE__*/ _jsxs("p", {
1498
- className: styles.operate,
1499
- children: [
1500
- /*#__PURE__*/ _jsx("i", {
1501
- className: "yinyong_quote1",
1502
- onClick: function() {
1503
- setCitationContent({
1504
- content: item.message,
1505
- id: item.id
1506
- });
1507
- resettingBottomHei();
1508
- onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1509
- },
1510
- children: /*#__PURE__*/ _jsx(CustomQuote, {})
1511
- }),
1512
- copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
1513
- return list == item.id;
1514
- }) ? /*#__PURE__*/ _jsx("i", {
1515
- className: "tongyong-xuanzhongdui",
1516
- children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1517
- }) : /*#__PURE__*/ _jsx("i", {
1518
- className: "fuzhi21",
1519
- onClick: function() {
1520
- var bol = copyText(item.message);
1521
- if (bol) {
1522
- var obj = copyTextOBJ;
1523
- obj = obj.filter(function(list) {
1524
- return list != item.id;
1525
- });
1526
- obj.push(item.id);
1527
- setCopyTextObj(obj);
1528
- }
1529
- setTimeout(function() {
1530
- var obj = copyTextOBJ;
1531
- obj = obj.filter(function(list) {
1532
- return list != item.id;
1533
- });
1534
- setCopyTextObj(obj);
1535
- }, 3000);
1536
- onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1549
+ /*#__PURE__*/ _jsxs("div", {
1550
+ className: styles.main_content_flag,
1551
+ children: [
1552
+ /*#__PURE__*/ _jsx("div", {
1553
+ className: styles.operate_modal,
1554
+ children: /*#__PURE__*/ _jsxs("p", {
1555
+ className: styles.operate,
1556
+ children: [
1557
+ /*#__PURE__*/ _jsx("i", {
1558
+ className: "yinyong_quote1",
1559
+ onClick: function() {
1560
+ setCitationContent({
1561
+ content: item.message,
1562
+ id: item.id
1563
+ });
1564
+ resettingBottomHei();
1565
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1566
+ },
1567
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1568
+ }),
1569
+ copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
1570
+ return list == item.id;
1571
+ }) ? /*#__PURE__*/ _jsx("i", {
1572
+ className: "tongyong-xuanzhongdui",
1573
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1574
+ }) : /*#__PURE__*/ _jsx("i", {
1575
+ className: "fuzhi21",
1576
+ onClick: function() {
1577
+ var bol = copyText(item.message);
1578
+ if (bol) {
1579
+ var obj = copyTextOBJ;
1580
+ obj = obj.filter(function(list) {
1581
+ return list != item.id;
1582
+ });
1583
+ obj.push(item.id);
1584
+ setCopyTextObj(obj);
1585
+ }
1586
+ setTimeout(function() {
1587
+ var obj = copyTextOBJ;
1588
+ obj = obj.filter(function(list) {
1589
+ return list != item.id;
1590
+ });
1591
+ setCopyTextObj(obj);
1592
+ }, 3000);
1593
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1594
+ },
1595
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1596
+ })
1597
+ ]
1598
+ })
1599
+ }),
1600
+ /*#__PURE__*/ _jsx("div", {
1601
+ className: styles.content,
1602
+ children: /*#__PURE__*/ _jsx("p", {
1603
+ dangerouslySetInnerHTML: {
1604
+ __html: remarkable.render(message)
1537
1605
  },
1538
- children: /*#__PURE__*/ _jsx(CustomCopy, {})
1606
+ className: styles.content_child
1539
1607
  })
1540
- ]
1541
- })
1542
- }),
1543
- /*#__PURE__*/ _jsx("div", {
1544
- className: styles.content,
1545
- children: /*#__PURE__*/ _jsx("p", {
1546
- dangerouslySetInnerHTML: {
1547
- __html: remarkable.render(message)
1548
- },
1549
- className: styles.content_child
1550
- })
1608
+ })
1609
+ ]
1551
1610
  }),
1552
1611
  //引用消息
1553
1612
  item.quotedMessage && /*#__PURE__*/ _jsx("div", {
@@ -1586,14 +1645,17 @@ var CustomerService = function(props) {
1586
1645
  } else {
1587
1646
  //获取用户头像
1588
1647
  var headImg = "";
1589
- var chatWindow = roomList.filter(function(item) {
1648
+ var chatWindow = [];
1649
+ var isAiChatWindow;
1650
+ chatWindow = contactsList.filter(function(item) {
1590
1651
  return item.roomId == roomId;
1591
1652
  });
1592
1653
  if (chatWindow.length > 0 && chatWindow[0].headImg != "") {
1593
1654
  headImg = chatWindow[0].headImg;
1594
1655
  }
1656
+ // console.log(chatWindow,'chatWindowchatWindow')
1595
1657
  //是否在智能客服窗口
1596
- var isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
1658
+ isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
1597
1659
  var header = 2; //代表是ai头像
1598
1660
  if (isAiChatWindow && item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "isVoteMessage") {
1599
1661
  //使用AI头像
@@ -1625,34 +1687,39 @@ var CustomerService = function(props) {
1625
1687
  children: /*#__PURE__*/ _jsxs("div", {
1626
1688
  className: styles.main_content,
1627
1689
  children: [
1628
- /*#__PURE__*/ _jsx("div", {
1629
- className: styles.operate_modal,
1630
- children: // 不是最后一行,
1631
- historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
1632
- }),
1633
1690
  /*#__PURE__*/ _jsxs("div", {
1634
- className: styles.content,
1691
+ className: styles.main_content_flag,
1635
1692
  children: [
1636
- /*#__PURE__*/ _jsx("p", {
1637
- dangerouslySetInnerHTML: {
1638
- __html: remarkable.render(message)
1639
- },
1640
- className: styles.content_child
1693
+ /*#__PURE__*/ _jsx("div", {
1694
+ className: styles.operate_modal,
1695
+ children: // 不是最后一行,
1696
+ historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
1641
1697
  }),
1642
- item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsx("ul", {
1643
- className: styles.association_problem,
1644
- children: JSON.parse(item.extraInfo).map(function(list, index) {
1645
- return /*#__PURE__*/ _jsxs("li", {
1646
- onClick: function() {
1647
- sendMessage(list, 1);
1698
+ /*#__PURE__*/ _jsxs("div", {
1699
+ className: styles.content,
1700
+ children: [
1701
+ /*#__PURE__*/ _jsx("p", {
1702
+ dangerouslySetInnerHTML: {
1703
+ __html: remarkable.render(message)
1648
1704
  },
1649
- children: [
1650
- index + 1,
1651
- ".",
1652
- list.question
1653
- ]
1654
- }, i + "_" + index + "_" + list.value);
1655
- })
1705
+ className: styles.content_child
1706
+ }),
1707
+ item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "messageSource" && JSON.parse(item.extraInfo)[0].value != "knowledgebase" && /*#__PURE__*/ _jsx("ul", {
1708
+ className: styles.association_problem,
1709
+ children: JSON.parse(item.extraInfo).map(function(list, index) {
1710
+ return /*#__PURE__*/ _jsxs("li", {
1711
+ onClick: function() {
1712
+ sendMessage(list, 1);
1713
+ },
1714
+ children: [
1715
+ index + 1,
1716
+ ".",
1717
+ list.question
1718
+ ]
1719
+ }, i + "_" + index + "_" + list.value);
1720
+ })
1721
+ })
1722
+ ]
1656
1723
  })
1657
1724
  ]
1658
1725
  }),
@@ -1680,7 +1747,7 @@ var CustomerService = function(props) {
1680
1747
  isAiChatWindow && item.findTeacher && userData.modules.some(function(item) {
1681
1748
  return item.short == "TeacherAnswer";
1682
1749
  }) ? /*#__PURE__*/ _jsx("div", {
1683
- className: "".concat(styles.operate_modal_bottom),
1750
+ className: "".concat(styles.operate_modal_bottom, " "),
1684
1751
  children: /*#__PURE__*/ _jsx("p", {
1685
1752
  className: styles.stop_findTeacher,
1686
1753
  children: /*#__PURE__*/ _jsx("span", {
@@ -1855,7 +1922,8 @@ var CustomerService = function(props) {
1855
1922
  };
1856
1923
  //渲染最后一条的操作按钮
1857
1924
  var renderLastOperateBtn = function(item, isAiChatWindow, i) {
1858
- {}
1925
+ {
1926
+ /* 停止生成按钮 最后一次生成答案的支持点击 */ }
1859
1927
  //问候语及点赞下面不需要展示相关按钮
1860
1928
  var extraInfo = item.extraInfo;
1861
1929
  //JSON.parse(extraInfo)[0].key == 'questionId' 是联想问题
@@ -1879,6 +1947,9 @@ var CustomerService = function(props) {
1879
1947
  }
1880
1948
  return /*#__PURE__*/ _jsxs("div", {
1881
1949
  className: "".concat(styles.operate_modal_bottom),
1950
+ style: {
1951
+ position: showStopBtn ? "sticky" : "relative"
1952
+ },
1882
1953
  children: [
1883
1954
  /*#__PURE__*/ _jsxs("p", {
1884
1955
  className: styles.stop_generate,
@@ -1935,8 +2006,6 @@ var CustomerService = function(props) {
1935
2006
  question: historyMessageList[i - 1].message,
1936
2007
  user: problem.user
1937
2008
  });
1938
- console.log(item, "88888999999");
1939
- // if(item.extraInfo == null){
1940
2009
  setHistoryMessageList(function(historyMessageList) {
1941
2010
  var newHistoryMessageList = historyMessageList.concat({
1942
2011
  id: -1,
@@ -1955,30 +2024,6 @@ var CustomerService = function(props) {
1955
2024
  });
1956
2025
  return newHistoryMessageList;
1957
2026
  });
1958
- // }else{
1959
- // setHistoryMessageList(
1960
- // (historyMessageList) => {
1961
- // let newHistoryMessageList =
1962
- // historyMessageList.concat({
1963
- // id: -1,
1964
- // roomId: roomId,
1965
- // sender: "AI",
1966
- // recevier: mid,
1967
- // message:
1968
- // "请告诉我您要召唤的老师名字",
1969
- // createdAt: getDataTime(-1),
1970
- // findTeacher:true,
1971
- // extraInfo: JSON.stringify([
1972
- // {
1973
- // key: "questionId",
1974
- // value: "questionId",
1975
- // },
1976
- // ])
1977
- // });
1978
- // return newHistoryMessageList;
1979
- // }
1980
- // );
1981
- // }
1982
2027
  setTimeout(function() {
1983
2028
  scrollToBottom();
1984
2029
  }, 200);
@@ -2149,6 +2194,7 @@ var CustomerService = function(props) {
2149
2194
  if (answerMode == 1) {
2150
2195
  getTeacherList(String(e.target.value));
2151
2196
  } else {
2197
+ var roomList = contactsList;
2152
2198
  if (roomList.length > 0 && roomList[0].roomId != roomId) return;
2153
2199
  getQuestiionsList(String(e.target.value), 2);
2154
2200
  }
@@ -2164,10 +2210,32 @@ var CustomerService = function(props) {
2164
2210
  clearTimeout(timer.current);
2165
2211
  setKeyWord("");
2166
2212
  setCitationContent({});
2213
+ //查找是否是召唤老师回答并有相应的老师名称
2214
+ if (answerMode == 1 && teacherList.length > 0) {
2215
+ var list = teacherList.filter(function(v) {
2216
+ return v.name == keyWord.trim();
2217
+ });
2218
+ if (list.length > 0) {
2219
+ //直接进入召唤老师回答模式
2220
+ enterTeacherChat(list[0]);
2221
+ setButtomHei(45);
2222
+ return;
2223
+ }
2224
+ }
2167
2225
  //跟老师对话
2226
+ var roomList = contactsList;
2168
2227
  if (roomList.length > 0 && roomList[0].roomId != roomId) {
2169
2228
  sendToTeacher(2);
2170
2229
  } else {
2230
+ clearTimeout(timer.current);
2231
+ setQuestionsList([]);
2232
+ setAnswerMode(-1);
2233
+ setTeacherList([]);
2234
+ setHistoryMessageList(function(historyMessageList) {
2235
+ return historyMessageList.filter(function(item) {
2236
+ return item.id != "-1";
2237
+ });
2238
+ });
2171
2239
  sendMessage("", 0);
2172
2240
  }
2173
2241
  setButtomHei(45);
@@ -2250,11 +2318,33 @@ var CustomerService = function(props) {
2250
2318
  setCitationContent({});
2251
2319
  setButtomHei(45);
2252
2320
  if (keyWord.trim() != "") {
2321
+ //查找是否是召唤老师回答并有相应的老师名称
2322
+ if (answerMode == 1 && teacherList.length > 0) {
2323
+ var list = teacherList.filter(function(v) {
2324
+ return v.name == keyWord.trim();
2325
+ });
2326
+ if (list.length > 0) {
2327
+ //直接进入召唤老师回答模式
2328
+ enterTeacherChat(list[0]);
2329
+ setButtomHei(45);
2330
+ return;
2331
+ }
2332
+ }
2253
2333
  setKeyWord("");
2254
2334
  //跟老师对话
2335
+ var roomList = contactsList;
2255
2336
  if (roomList.length > 0 && roomList[0].roomId != roomId) {
2256
2337
  sendToTeacher(2);
2257
2338
  } else {
2339
+ clearTimeout(timer.current);
2340
+ setQuestionsList([]);
2341
+ setAnswerMode(-1);
2342
+ setTeacherList([]);
2343
+ setHistoryMessageList(function(historyMessageList) {
2344
+ return historyMessageList.filter(function(item) {
2345
+ return item.id != "-1";
2346
+ });
2347
+ });
2258
2348
  sendMessage("", 0);
2259
2349
  }
2260
2350
  onEvent(serverName + serverUrl(), "click_智能问答_ Enter", "提交");
@@ -2266,6 +2356,34 @@ var CustomerService = function(props) {
2266
2356
  ]
2267
2357
  });
2268
2358
  };
2359
+ //进入与老师的聊天
2360
+ var enterTeacherChat = function(item) {
2361
+ setTeacherList([]);
2362
+ //提问的问题
2363
+ setProblem({
2364
+ question: problem.question,
2365
+ user: item.uid
2366
+ });
2367
+ setKeyWord("");
2368
+ //setUpdateRecords(true);
2369
+ setAnswerMode(-1);
2370
+ setChatWith(item);
2371
+ var roomList = contactsList;
2372
+ var list = roomList.filter(function(e) {
2373
+ return e.sender == item.uid;
2374
+ });
2375
+ setShowContacts(true);
2376
+ if (list.length > 0) {
2377
+ setRoomId(list[0].roomId); //已有聊天室
2378
+ } else {
2379
+ createRooms(item.uid).then(function(res) {
2380
+ // childRef.current.roomsListTimer();
2381
+ roomsListTimer();
2382
+ var id = res.data.id;
2383
+ setRoomId(id); //新的聊天室id
2384
+ });
2385
+ }
2386
+ };
2269
2387
  //渲染联想问题及联想的老师名称
2270
2388
  var renderAssociationProblem = function() {
2271
2389
  if (answerMode == 1) {
@@ -2275,35 +2393,24 @@ var CustomerService = function(props) {
2275
2393
  bottom: "".concat(buttomHei + 14, "px")
2276
2394
  },
2277
2395
  children: teacherList.map(function(item) {
2278
- var span = item.name.replaceAll(keyWord, function() {
2279
- return "<span class=".concat(styles.sign, ">").concat(keyWord, "</span>");
2280
- });
2396
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2397
+ var span = "";
2398
+ //搜索内容是否有特殊字符
2399
+ if (reg.test(keyWord)) {
2400
+ span = item.name.replaceAll(keyWord, function(e) {
2401
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
2402
+ });
2403
+ } else {
2404
+ span = item.name.replaceAll(new RegExp(keyWord, "ig"), function(i) {
2405
+ // console.log(i,'skdcnsdjk')
2406
+ return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
2407
+ });
2408
+ }
2281
2409
  return /*#__PURE__*/ _jsx("p", {
2282
2410
  className: styles.item,
2283
2411
  children: /*#__PURE__*/ _jsx("span", {
2284
2412
  onClick: function() {
2285
- setTeacherList([]);
2286
- //提问的问题
2287
- setProblem({
2288
- question: problem.question,
2289
- user: item.uid
2290
- });
2291
- setKeyWord("");
2292
- //setUpdateRecords(true);
2293
- setAnswerMode(-1);
2294
- setChatWith(item);
2295
- var list = roomList.filter(function(e) {
2296
- return e.sender == item.uid;
2297
- });
2298
- if (list.length > 0) {
2299
- setRoomId(list[0].roomId); //已有聊天室
2300
- } else {
2301
- createRooms(item.uid).then(function(res) {
2302
- childRef.current.roomsListTimer();
2303
- var id = res.data.id;
2304
- setRoomId(id); //新的聊天室id
2305
- });
2306
- }
2413
+ enterTeacherChat(item);
2307
2414
  },
2308
2415
  dangerouslySetInnerHTML: {
2309
2416
  __html: span
@@ -2319,9 +2426,19 @@ var CustomerService = function(props) {
2319
2426
  bottom: "".concat(buttomHei + 6, "px")
2320
2427
  },
2321
2428
  children: questionsList.map(function(item) {
2322
- var span = item.question.replaceAll(keyWord, function() {
2323
- return "<span class=".concat(styles.sign, ">").concat(keyWord, "</span>");
2324
- });
2429
+ var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
2430
+ var span = "";
2431
+ //搜索内容是否有特殊字符
2432
+ if (reg.test(keyWord)) {
2433
+ span = item.question.replaceAll(keyWord, function(e) {
2434
+ return "<span class=".concat(styles.sign, ">").concat(e, "</span>");
2435
+ });
2436
+ } else {
2437
+ span = item.question.replaceAll(new RegExp(keyWord, "ig"), function(i) {
2438
+ // console.log(i,'skdcnsdjk')
2439
+ return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
2440
+ });
2441
+ }
2325
2442
  return /*#__PURE__*/ _jsx("p", {
2326
2443
  className: styles.item,
2327
2444
  children: /*#__PURE__*/ _jsx("span", {
@@ -2341,30 +2458,33 @@ var CustomerService = function(props) {
2341
2458
  };
2342
2459
  //加载指定数据,点击历史记录
2343
2460
  var loadSpecifiedData = function(renewRoomId, page, id, receiver) {
2461
+ // let renewRoomId = '4a615d7126b343f78d10dcb06dbc29b0';
2462
+ // let page = 1;
2463
+ // let id = '0e459f0a3a62438698f170b42b94d150';
2464
+ // let receiver = mid;
2344
2465
  if (page != 1) {
2345
2466
  setPageNumHistory(page);
2346
2467
  }
2347
- setPageNum(page);
2348
2468
  setLastId(id); //用于定位
2469
+ setPageNum(page);
2349
2470
  //如果是当前聊天室
2350
2471
  if (renewRoomId == roomId) {
2351
2472
  getHistoryMessage(page, 1);
2352
2473
  } else {
2353
2474
  setRoomId(renewRoomId);
2354
- if (childRef.current) {
2355
- if (receiver != mid) {
2356
- createRooms(receiver);
2357
- }
2358
- setTimeout(function() {
2359
- childRef.current.roomsListTimer();
2360
- }, 500);
2475
+ if (receiver != mid) {
2476
+ createRooms(receiver);
2361
2477
  }
2478
+ setTimeout(function() {
2479
+ roomsListTimer();
2480
+ }, 500);
2362
2481
  }
2482
+ setShowContacts(true);
2363
2483
  };
2364
2484
  return /*#__PURE__*/ _jsxs(_Fragment, {
2365
2485
  children: [
2366
2486
  /*#__PURE__*/ _jsxs(Drawer, {
2367
- title: "智能问答",
2487
+ title: "AI助手",
2368
2488
  width: 560,
2369
2489
  onClose: function() {
2370
2490
  onCancel();
@@ -2389,9 +2509,9 @@ var CustomerService = function(props) {
2389
2509
  onClose: function() {
2390
2510
  setShowContacts(false);
2391
2511
  },
2392
- // roomIdAi={roomIdAi}
2393
2512
  switchChatRoom: switchChatRoom,
2394
- saveContactsList: saveContactsList,
2513
+ // saveContactsList={saveContactsList}
2514
+ contactsList: contactsList,
2395
2515
  ref: childRef
2396
2516
  })
2397
2517
  }),
@@ -2448,7 +2568,7 @@ var CustomerService = function(props) {
2448
2568
  ]
2449
2569
  }),
2450
2570
  /*#__PURE__*/ _jsxs(Modal, {
2451
- title: "智能问答",
2571
+ title: "AI助手",
2452
2572
  open: showType == 2 ? true : false,
2453
2573
  onCancel: function() {
2454
2574
  onCancel();
@@ -2487,7 +2607,8 @@ var CustomerService = function(props) {
2487
2607
  setShowContacts(false);
2488
2608
  },
2489
2609
  switchChatRoom: switchChatRoom,
2490
- saveContactsList: saveContactsList,
2610
+ contactsList: contactsList,
2611
+ // saveContactsList={saveContactsList}
2491
2612
  ref: childRef
2492
2613
  }),
2493
2614
  /*#__PURE__*/ _jsxs("div", {
@@ -2543,13 +2664,7 @@ var CustomerService = function(props) {
2543
2664
  /*#__PURE__*/ _jsx("div", {
2544
2665
  className: styles.user,
2545
2666
  children: /*#__PURE__*/ _jsx("p", {
2546
- children: roomList.filter(function(e) {
2547
- return e.roomId == roomId;
2548
- }).length > 0 && roomList.filter(function(e) {
2549
- return e.roomId == roomId;
2550
- })[0].name != undefined ? roomList.filter(function(e) {
2551
- return e.roomId == roomId;
2552
- })[0].name : "智能问答"
2667
+ children: showChatRoomName()
2553
2668
  })
2554
2669
  }),
2555
2670
  /*#__PURE__*/ _jsxs("div", {
@@ -2570,7 +2685,7 @@ var CustomerService = function(props) {
2570
2685
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2571
2686
  setFirstLoad(false);
2572
2687
  setShowType(4);
2573
- childRef.current.roomsListTimer();
2688
+ // childRef.current.roomsListTimer();
2574
2689
  },
2575
2690
  children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
2576
2691
  }),
@@ -2638,8 +2753,9 @@ var CustomerService = function(props) {
2638
2753
  onClose: function() {
2639
2754
  setShowContacts(false);
2640
2755
  },
2756
+ contactsList: contactsList,
2641
2757
  switchChatRoom: switchChatRoom,
2642
- saveContactsList: saveContactsList,
2758
+ // saveContactsList={saveContactsList}
2643
2759
  ref: childRef
2644
2760
  })
2645
2761
  })
@@ -2648,7 +2764,7 @@ var CustomerService = function(props) {
2648
2764
  showType == 4 && /*#__PURE__*/ _jsxs(_Fragment, {
2649
2765
  children: [
2650
2766
  /*#__PURE__*/ _jsxs(Modal, {
2651
- title: "智能问答",
2767
+ title: "AI助手",
2652
2768
  open: true,
2653
2769
  onCancel: function() {
2654
2770
  onCancel();
@@ -2686,8 +2802,9 @@ var CustomerService = function(props) {
2686
2802
  onClose: function() {
2687
2803
  setShowContacts(false);
2688
2804
  },
2805
+ contactsList: contactsList,
2689
2806
  switchChatRoom: switchChatRoom,
2690
- saveContactsList: saveContactsList,
2807
+ // saveContactsList={saveContactsList}
2691
2808
  ref: childRef
2692
2809
  }),
2693
2810
  /*#__PURE__*/ _jsxs("div", {
@@ -2743,13 +2860,7 @@ var CustomerService = function(props) {
2743
2860
  /*#__PURE__*/ _jsx("div", {
2744
2861
  className: styles.user,
2745
2862
  children: /*#__PURE__*/ _jsx("p", {
2746
- children: roomList.filter(function(e) {
2747
- return e.roomId == roomId;
2748
- }).length > 0 && !roomList.filter(function(e) {
2749
- return e.roomId == roomId;
2750
- })[0].name ? roomList.filter(function(e) {
2751
- return e.roomId == roomId;
2752
- })[0].name : "智能问答"
2863
+ children: showChatRoomName()
2753
2864
  })
2754
2865
  }),
2755
2866
  /*#__PURE__*/ _jsxs("div", {
@@ -2768,7 +2879,7 @@ var CustomerService = function(props) {
2768
2879
  onClick: function() {
2769
2880
  onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2770
2881
  setShowType(4);
2771
- childRef.current.roomsListTimer();
2882
+ // childRef.current.roomsListTimer();
2772
2883
  },
2773
2884
  children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
2774
2885
  }),
@@ -2825,8 +2936,9 @@ var CustomerService = function(props) {
2825
2936
  onClose: function() {
2826
2937
  setShowContacts(false);
2827
2938
  },
2939
+ contactsList: contactsList,
2828
2940
  switchChatRoom: switchChatRoom,
2829
- saveContactsList: saveContactsList,
2941
+ // saveContactsList={saveContactsList}
2830
2942
  ref: childRef
2831
2943
  })
2832
2944
  })