bhd-components 0.5.5 → 0.5.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 (117) hide show
  1. package/dist/1bddec89.esm.es5.production.js +72 -0
  2. package/dist/535fc6c5.esm.es5.development.js +95493 -0
  3. package/dist/CustomerService.esm.es5.development.css +2827 -0
  4. package/dist/CustomerService.esm.es5.development.js +3823 -0
  5. package/dist/CustomerService.esm.es5.production.css +1 -0
  6. package/dist/CustomerService.esm.es5.production.js +1 -0
  7. package/dist/vendor.esm.es5.development.esm.es5.development.css +117 -0
  8. package/dist/vendor.esm.es5.production.esm.es5.production.css +9 -0
  9. package/es2017/customerService/contactsList/index.d.ts +13 -0
  10. package/es2017/customerService/contactsList/index.js +313 -0
  11. package/es2017/customerService/contactsList/index.module.less +187 -0
  12. package/es2017/customerService/function.d.ts +17 -0
  13. package/es2017/customerService/function.js +67 -0
  14. package/es2017/customerService/historyFun/index.d.ts +13 -0
  15. package/es2017/customerService/historyFun/index.js +241 -0
  16. package/es2017/customerService/historyFun/index.module.less +189 -0
  17. package/es2017/customerService/images/knowledge_icon.png +0 -0
  18. package/es2017/customerService/images/voice_btn.gif +0 -0
  19. package/es2017/customerService/index.d.ts +16 -0
  20. package/es2017/customerService/index.js +2493 -0
  21. package/es2017/customerService/index.module.less +727 -0
  22. package/es2017/customerService/useMediaRecorder.d.ts +9 -0
  23. package/es2017/customerService/useMediaRecorder.js +78 -0
  24. package/es2017/customerService/voice_btn.gif +0 -0
  25. package/es2017/icons/components/custom-ai_icon.d.ts +4 -0
  26. package/es2017/icons/components/custom-ai_icon.js +58 -0
  27. package/es2017/icons/components/custom-contacts.d.ts +4 -0
  28. package/es2017/icons/components/custom-contacts.js +29 -0
  29. package/es2017/icons/components/custom-copy.d.ts +4 -0
  30. package/es2017/icons/components/custom-copy.js +36 -0
  31. package/es2017/icons/components/custom-dislike.d.ts +4 -0
  32. package/es2017/icons/components/custom-dislike.js +22 -0
  33. package/es2017/icons/components/custom-duihao.d.ts +4 -0
  34. package/es2017/icons/components/custom-duihao.js +22 -0
  35. package/es2017/icons/components/custom-exit_full_screen.d.ts +4 -0
  36. package/es2017/icons/components/custom-exit_full_screen.js +26 -0
  37. package/es2017/icons/components/custom-full_screen.d.ts +4 -0
  38. package/es2017/icons/components/custom-full_screen.js +22 -0
  39. package/es2017/icons/components/custom-like.d.ts +4 -0
  40. package/es2017/icons/components/custom-like.js +22 -0
  41. package/es2017/icons/components/custom-quote.d.ts +4 -0
  42. package/es2017/icons/components/custom-quote.js +31 -0
  43. package/es2017/icons/components/custom-record.d.ts +4 -0
  44. package/es2017/icons/components/custom-record.js +37 -0
  45. package/es2017/icons/components/custom-reloading.d.ts +4 -0
  46. package/es2017/icons/components/custom-reloading.js +26 -0
  47. package/es2017/icons/components/custom-retract.d.ts +4 -0
  48. package/es2017/icons/components/custom-retract.js +27 -0
  49. package/es2017/icons/components/custom-round_close.d.ts +4 -0
  50. package/es2017/icons/components/custom-round_close.js +24 -0
  51. package/es2017/icons/components/custom-sending.d.ts +4 -0
  52. package/es2017/icons/components/custom-sending.js +22 -0
  53. package/es2017/icons/components/custom-sound_recording.d.ts +4 -0
  54. package/es2017/icons/components/custom-sound_recording.js +22 -0
  55. package/es2017/icons/components/index.d.ts +15 -0
  56. package/es2017/icons/components/index.js +15 -0
  57. package/es2017/index.d.ts +1 -0
  58. package/es2017/index.js +1 -0
  59. package/es2017/provider/config.js +3 -3
  60. package/esm/customerService/contactsList/index.d.ts +13 -0
  61. package/esm/customerService/contactsList/index.js +326 -0
  62. package/esm/customerService/contactsList/index.module.less +187 -0
  63. package/esm/customerService/function.d.ts +17 -0
  64. package/esm/customerService/function.js +69 -0
  65. package/esm/customerService/historyFun/index.d.ts +13 -0
  66. package/esm/customerService/historyFun/index.js +256 -0
  67. package/esm/customerService/historyFun/index.module.less +189 -0
  68. package/esm/customerService/images/knowledge_icon.png +0 -0
  69. package/esm/customerService/images/voice_btn.gif +0 -0
  70. package/esm/customerService/index.d.ts +16 -0
  71. package/esm/customerService/index.js +2576 -0
  72. package/esm/customerService/index.module.less +727 -0
  73. package/esm/customerService/useMediaRecorder.d.ts +9 -0
  74. package/esm/customerService/useMediaRecorder.js +121 -0
  75. package/esm/customerService/voice_btn.gif +0 -0
  76. package/esm/icons/components/custom-ai_icon.d.ts +4 -0
  77. package/esm/icons/components/custom-ai_icon.js +60 -0
  78. package/esm/icons/components/custom-contacts.d.ts +4 -0
  79. package/esm/icons/components/custom-contacts.js +31 -0
  80. package/esm/icons/components/custom-copy.d.ts +4 -0
  81. package/esm/icons/components/custom-copy.js +38 -0
  82. package/esm/icons/components/custom-dislike.d.ts +4 -0
  83. package/esm/icons/components/custom-dislike.js +24 -0
  84. package/esm/icons/components/custom-duihao.d.ts +4 -0
  85. package/esm/icons/components/custom-duihao.js +24 -0
  86. package/esm/icons/components/custom-exit_full_screen.d.ts +4 -0
  87. package/esm/icons/components/custom-exit_full_screen.js +28 -0
  88. package/esm/icons/components/custom-full_screen.d.ts +4 -0
  89. package/esm/icons/components/custom-full_screen.js +24 -0
  90. package/esm/icons/components/custom-like.d.ts +4 -0
  91. package/esm/icons/components/custom-like.js +24 -0
  92. package/esm/icons/components/custom-quote.d.ts +4 -0
  93. package/esm/icons/components/custom-quote.js +33 -0
  94. package/esm/icons/components/custom-record.d.ts +4 -0
  95. package/esm/icons/components/custom-record.js +39 -0
  96. package/esm/icons/components/custom-reloading.d.ts +4 -0
  97. package/esm/icons/components/custom-reloading.js +28 -0
  98. package/esm/icons/components/custom-retract.d.ts +4 -0
  99. package/esm/icons/components/custom-retract.js +29 -0
  100. package/esm/icons/components/custom-round_close.d.ts +4 -0
  101. package/esm/icons/components/custom-round_close.js +26 -0
  102. package/esm/icons/components/custom-sending.d.ts +4 -0
  103. package/esm/icons/components/custom-sending.js +24 -0
  104. package/esm/icons/components/custom-sound_recording.d.ts +4 -0
  105. package/esm/icons/components/custom-sound_recording.js +24 -0
  106. package/esm/icons/components/index.d.ts +15 -0
  107. package/esm/icons/components/index.js +15 -0
  108. package/esm/index.d.ts +1 -0
  109. package/esm/index.js +1 -0
  110. package/esm/provider/config.js +3 -3
  111. package/package.json +10 -2
  112. package/dist/1951bd5c.esm.es5.development.js +0 -45417
  113. package/dist/28cd83d3.esm.es5.production.js +0 -256
  114. package/dist/table.esm.es5.development.css +0 -772
  115. package/dist/table.esm.es5.development.js +0 -289
  116. package/dist/table.esm.es5.production.css +0 -1
  117. package/dist/table.esm.es5.production.js +0 -1
@@ -0,0 +1,2576 @@
1
+ /* eslint-disable import/first */ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
5
+ import React, { useEffect, useState, useRef } from "react";
6
+ import styles from "./index.module.less";
7
+ import { Modal, Drawer, Input, Tooltip } from "antd";
8
+ import { CustomAiIcon, CustomRecord, CustomFullScreen, CustomExitFullScreen, CustomReloading, CustomCopy, CustomLike, CustomDislike, CustomQuote, CustomSending, CustomContacts, CustomDuihao, CustomSoundRecording, CustomRoundClose } from "../icons/index";
9
+ import { CloseOutlined } from "@ant-design/icons";
10
+ import HistoryFun from "./historyFun/index";
11
+ import ContactsList from "./contactsList/index";
12
+ // import { fetchEventSource } from "@microsoft/fetch-event-source";
13
+ import dayjs from "dayjs";
14
+ import { Remarkable } from "remarkable";
15
+ import hljs from "highlight.js";
16
+ import "highlight.js/styles/default.css";
17
+ import { render } from "react-dom";
18
+ import Provider from "../provider";
19
+ var TextArea = Input.TextArea;
20
+ import knowledge_icon from "./images/knowledge_icon.png";
21
+ import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
22
+ import { readMessage, getByteLen, serverUrl, copyText, getDataTime } from "./function"; //一些方法
23
+ var CustomerService = function(props) {
24
+ var userData = props.userData, http = props.http, urllocation = props.urllocation, onCancel = props.onCancel, serverName = props.serverName, fetchEventSource = props.fetchEventSource, initShowType = props.initShowType, onEvent = props.onEvent, stepIds = props.stepIds, stepId = props.stepId;
25
+ // urllocation = "/zhong";
26
+ var _useState = _sliced_to_array(useState(props.userData.mid), 2), mid = _useState[0], setmid = _useState[1]; //当前用户id
27
+ var _useMediaRecorder = useMediaRecorder(), bese64String = _useMediaRecorder.bese64String, startRecord = _useMediaRecorder.startRecord, stopRecord = _useMediaRecorder.stopRecord; //语音转文字
28
+ var _useState1 = _sliced_to_array(useState(3), 2), voiceRecordingStatus = _useState1[0], setVoiceRecordingStatus = _useState1[1]; //语音录制状态 3,语音识别完成 2,录制中, 1,录制结束
29
+ var _useState2 = _sliced_to_array(useState([]), 2), copyTextOBJ = _useState2[0], setCopyTextObj = _useState2[1]; //复制的消息id
30
+ var _useState3 = _sliced_to_array(useState({}), 2), citationContent = _useState3[0], setCitationContent = _useState3[1]; //引用内容
31
+ var _useState4 = _sliced_to_array(useState(""), 2), roomId = _useState4[0], setRoomId = _useState4[1]; //聊天室id
32
+ var _useState5 = _sliced_to_array(useState([]), 2), historyMessageList = _useState5[0], setHistoryMessageList = _useState5[1]; //历史消息
33
+ var _useState6 = _sliced_to_array(useState(""), 2), keyWord = _useState6[0], setKeyWord = _useState6[1]; //搜索内容
34
+ var _useState7 = _sliced_to_array(useState([]), 2), questionsList = _useState7[0], setQuestionsList = _useState7[1]; //问题列表
35
+ var _useState8 = _sliced_to_array(useState([]), 2), hotQuestionsList = _useState8[0], setHotQuestionsList = _useState8[1]; //热门问题
36
+ var _useState9 = _sliced_to_array(useState(false), 2), greetingMessage = _useState9[0], setGreetingMessage = _useState9[1]; //聊天记录列表是否请求完成
37
+ var _useState10 = _sliced_to_array(useState(1), 2), pageNum = _useState10[0], setPageNum = _useState10[1]; //页码
38
+ var _useState11 = _sliced_to_array(useState(0), 2), pageCount = _useState11[0], setPageCount = _useState11[1]; //总页数
39
+ var _useState12 = _sliced_to_array(useState(false), 2), loading = _useState12[0], setLoading = _useState12[1]; //是否显示加载图标
40
+ var _useState13 = _sliced_to_array(useState(true), 2), finished = _useState13[0], setFinished = _useState13[1]; //是否结束生成
41
+ var _useState14 = _sliced_to_array(useState(""), 2), lastId = _useState14[0], setLastId = _useState14[1]; //最后一条数据的id,可用于定位当前位置
42
+ var _useState15 = _sliced_to_array(useState({}), 2), chatWith = _useState15[0], setChatWith = _useState15[1]; //聊天的老师id或ai
43
+ var _useState16 = _sliced_to_array(useState(false), 2), firstLoad = _useState16[0], setFirstLoad = _useState16[1]; //第一次切换全屏时滚动到页面底部
44
+ var _useState17 = _sliced_to_array(useState(45), 2), buttomHei = _useState17[0], setButtomHei = _useState17[1]; //底部输入框的高度
45
+ var _useState18 = _sliced_to_array(useState(false), 2), showHistory = _useState18[0], setShowHistory = _useState18[1]; //是否显示历史记录
46
+ var _useState19 = _sliced_to_array(useState(false), 2), showContacts = _useState19[0], setShowContacts = _useState19[1]; //是否显示关联老师
47
+ var _useState20 = _sliced_to_array(useState(-1), 2), showType = _useState20[0], setShowType = _useState20[1]; //显示聊天框类型 1、侧边栏 2 modal 3 相应的div中 newlabo中使用
48
+ var _useState21 = _sliced_to_array(useState(-1), 2), answerMode = _useState21[0], setAnswerMode = _useState21[1]; //设置回答模式。1,召唤老师回答
49
+ var _useState22 = _sliced_to_array(useState([]), 2), teacherList = _useState22[0], setTeacherList = _useState22[1]; //老师列表
50
+ var _useState23 = _sliced_to_array(useState({}), 2), problem = _useState23[0], setProblem = _useState23[1]; //召唤老师回答的问题
51
+ var _useState24 = _sliced_to_array(useState([]), 2), roomList = _useState24[0], setRoomList = _useState24[1]; //聊天列表
52
+ var _useState25 = _sliced_to_array(useState([]), 2), chatObj = _useState25[0], setChatObj = _useState25[1]; //聊天记录id保存,用来在实验报告中记录
53
+ var timer = useRef(null); //文本框输入时
54
+ var receiveMessageTimer = useRef(null); //接收ai发回的消息
55
+ var voiceCountdownTimer = useRef(null); //语音录制倒计时
56
+ var listTimer = useRef(null); // 请求列表倒计时
57
+ var ctrl = useRef(); //停止生成ai回答时使用
58
+ var remarkable = new Remarkable({
59
+ highlight: function highlight(str, lang) {
60
+ if (lang && hljs.getLanguage(lang)) {
61
+ try {
62
+ return hljs.highlight(lang, str).value;
63
+ } catch (err) {}
64
+ }
65
+ try {
66
+ return hljs.highlightAuto(str).value;
67
+ } catch (err) {}
68
+ return ""; // use external default escaping
69
+ }
70
+ });
71
+ useEffect(function() {
72
+ return function() {
73
+ clearTimeout(receiveMessageTimer.current);
74
+ clearTimeout(voiceCountdownTimer.current);
75
+ clearTimeout(listTimer.current);
76
+ clearTimeout(timer.current);
77
+ };
78
+ }, []);
79
+ useEffect(function() {
80
+ var handleScroll = function handleScroll() {
81
+ var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
82
+ var scrollTop = container.scrollTop;
83
+ // const scrollBottom = container.scroll;
84
+ // console.log(container,'sdcsdcsdcsdc');
85
+ container.onscroll = function(e) {
86
+ //元素内部页面滚动到达底部
87
+ if (e.target.clientHeight + e.target.scrollTop >= e.target.scrollHeight) {
88
+ //console.log('元素内部页面滚动到达底部');
89
+ if (pageNum > 1) {
90
+ var number = pageNum - 1;
91
+ setPageNum(function(pageNum) {
92
+ return pageNum - 1;
93
+ });
94
+ clearTimeout(listTimer.current);
95
+ listTimer.current = setTimeout(function() {
96
+ console.log("加载下一页", number);
97
+ getHistoryMessage(number, 2);
98
+ }, 1000);
99
+ }
100
+ }
101
+ };
102
+ if (scrollTop == 0 && pageCount > pageNum && pageCount > 0) {
103
+ setLoading(true);
104
+ var number = pageNum + 1;
105
+ setPageNum(function(pageNum) {
106
+ return pageNum + 1;
107
+ });
108
+ clearTimeout(listTimer.current);
109
+ listTimer.current = setTimeout(function() {
110
+ console.log("加载下一页", number);
111
+ getHistoryMessage(number, 0);
112
+ }, 1000);
113
+ }
114
+ };
115
+ // console.log("重新加载",pageCount);
116
+ if (showType == 2 && !firstLoad && pageCount > 0) {
117
+ setFirstLoad(true);
118
+ setTimeout(function() {
119
+ scrollToBottom();
120
+ }, 100);
121
+ }
122
+ var content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
123
+ if (content) {
124
+ content.addEventListener("scroll", handleScroll);
125
+ }
126
+ return function() {
127
+ var content = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
128
+ if (content) {
129
+ content.removeEventListener("scroll", handleScroll);
130
+ }
131
+ };
132
+ }, [
133
+ historyMessageList,
134
+ showType,
135
+ pageCount
136
+ ]);
137
+ useEffect(function() {
138
+ resettingBottomHei();
139
+ var dom = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
140
+ if (dom) {
141
+ if (showType == 1) {
142
+ dom.style.maxHeight = "".concat(window.innerHeight - 60 - buttomHei, "px");
143
+ } else if (showType == 3) {
144
+ dom.style.maxHeight = "".concat(window.innerHeight - 50 - buttomHei, "px");
145
+ } else {
146
+ dom.style.maxHeight = "".concat(window.innerHeight - 160 - 60 - buttomHei, "px");
147
+ }
148
+ }
149
+ }, [
150
+ buttomHei,
151
+ showType
152
+ ]);
153
+ useEffect(function() {
154
+ console.log(props, "lsdkcmsdlcksd");
155
+ getQuestiionsList("", 1);
156
+ scrollToBottom();
157
+ // less.modifyVars({ "@color-border-Tr": "#f4523b" });
158
+ // console.log("9999999", less);
159
+ // getRoomList();
160
+ setShowType(initShowType);
161
+ }, [
162
+ initShowType
163
+ ]);
164
+ useEffect(function() {
165
+ // console.log(roomId,1111111)
166
+ if (roomId != "") {
167
+ // console.log(roomId,2222222)
168
+ var num = pageNum != 1 ? pageNum : 1;
169
+ getHistoryMessage(num, 0);
170
+ scrollToBottom();
171
+ }
172
+ }, [
173
+ roomId
174
+ ]);
175
+ useEffect(function() {
176
+ console.log(roomList, "roomListroomListroomListroomListroomList");
177
+ if (roomList.length > 0) {
178
+ //切换到有聊天的窗口
179
+ var message = roomList.filter(function(item) {
180
+ return item.unreadCount > 0;
181
+ });
182
+ if (message.length > 0) {
183
+ setRoomId(message[0].roomId);
184
+ readMessage(message[0].roomId, urllocation, userData, http);
185
+ } else {
186
+ setRoomId(roomList[0].roomId);
187
+ }
188
+ } else {
189
+ createRooms("AI").then(function(res) {
190
+ // console.log(res.data,'dlfkvdlkfvmdf');
191
+ setRoomId(res.data.id);
192
+ setRoomList([
193
+ {
194
+ roomId: res.data.id,
195
+ unreadCount: 0,
196
+ uid: mid
197
+ }
198
+ ]);
199
+ });
200
+ }
201
+ }, [
202
+ roomList
203
+ ]);
204
+ //进入页面,发送打招呼信息
205
+ useEffect(function() {
206
+ // console.log(historyMessageList, "dkjvndfkjvd33333f");
207
+ //老师的聊天窗口不发送打招呼信息
208
+ if (!(roomList.length > 0 && roomList[0].roomId != roomId)) {
209
+ //是否发送打招呼信息
210
+ if (greetingMessage && historyMessageList.length == 0) {
211
+ sendGreetingMessage(1);
212
+ } else {
213
+ try {
214
+ if (historyMessageList[historyMessageList.length - 1].extraInfo == null) {
215
+ sendGreetingMessage(1);
216
+ } else if (JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo).length > 0 && (JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo)[0].key == "questionId" || JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo)[0].value == "knowledgebase")) {
217
+ console.log(JSON.parse(historyMessageList[historyMessageList.length - 1].extraInfo, "sdklsdksd"));
218
+ sendGreetingMessage(1);
219
+ }
220
+ } catch (error) {}
221
+ }
222
+ }
223
+ scrollToBottom();
224
+ }, [
225
+ greetingMessage,
226
+ hotQuestionsList
227
+ ]);
228
+ //语音转文字
229
+ useEffect(function() {
230
+ if (bese64String != "") {
231
+ speechToText();
232
+ }
233
+ //发送给后端语音brse64
234
+ }, [
235
+ bese64String
236
+ ]);
237
+ //AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
238
+ var sendGreetingMessage = function(type) {
239
+ var questionsList = [];
240
+ var obj = {};
241
+ if (type == 1) {
242
+ questionsList = hotQuestionsList.map(function(item, index) {
243
+ if (index < 3) {
244
+ return {
245
+ key: "messageSource",
246
+ value: item.id,
247
+ question: item.question,
248
+ answer: item.answer
249
+ };
250
+ } else {
251
+ return null;
252
+ }
253
+ });
254
+ questionsList = questionsList.filter(function(i) {
255
+ return i != null;
256
+ });
257
+ obj = {
258
+ roomId: roomId,
259
+ sender: "AI",
260
+ recevier: mid,
261
+ message: "Hi!我是有问必答的实训云智能客服,请问您遇到了什么问题?",
262
+ extraInfos: questionsList
263
+ };
264
+ } else if (type == 2) {
265
+ obj = {
266
+ roomId: roomId,
267
+ sender: "AI",
268
+ recevier: mid,
269
+ message: "您的点赞是我最大的鼓励!",
270
+ createdAt: getDataTime(-1),
271
+ extraInfos: [
272
+ {
273
+ key: "messageSource",
274
+ value: "knowledgebase"
275
+ }
276
+ ]
277
+ };
278
+ } else if (type == 3) {
279
+ obj = {
280
+ roomId: roomId,
281
+ sender: "AI",
282
+ recevier: mid,
283
+ message: "谢谢您的反馈,我会努力改进的!",
284
+ createdAt: getDataTime(-1),
285
+ extraInfos: [
286
+ {
287
+ key: "messageSource",
288
+ value: "knowledgebase"
289
+ }
290
+ ]
291
+ };
292
+ } else if (type == 4) {
293
+ obj = {
294
+ roomId: roomId,
295
+ sender: mid,
296
+ recevier: "AI",
297
+ message: keyWord,
298
+ createdAt: getDataTime(-1),
299
+ quotedMessage: citationContent.content,
300
+ extraInfos: [
301
+ {
302
+ key: "messageSource",
303
+ value: "knowledgebase"
304
+ }
305
+ ]
306
+ };
307
+ } else if (type == 5) {
308
+ obj = {
309
+ roomId: roomId,
310
+ sender: "AI",
311
+ recevier: mid,
312
+ message: "抱歉!您今日的提问量已经达到最大限额,请您明日再来提问。",
313
+ createdAt: getDataTime(-1),
314
+ quotedMessage: citationContent.content,
315
+ extraInfos: [
316
+ {
317
+ key: "messageSource",
318
+ value: "knowledgebase"
319
+ }
320
+ ]
321
+ };
322
+ } else if (type == 6) {
323
+ questionsList = hotQuestionsList.map(function(item) {
324
+ return {
325
+ key: "messageSource",
326
+ value: item.id,
327
+ question: item.question,
328
+ answer: item.answer
329
+ };
330
+ });
331
+ obj = {
332
+ roomId: roomId,
333
+ sender: "AI",
334
+ recevier: mid,
335
+ message: "猜你想问:",
336
+ extraInfos: questionsList
337
+ };
338
+ }
339
+ setKeyWord("");
340
+ setQuestionsList([]);
341
+ setCitationContent({});
342
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj, {
343
+ headers: {
344
+ "x-module-id": userData.modules.find(function(ele) {
345
+ return ele.short == "IntelligentCustomerService";
346
+ }).id,
347
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
348
+ }
349
+ }).then(function(res) {
350
+ if (res.data.id) {
351
+ setHistoryMessageList(function(historyMessageList) {
352
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
353
+ id: res.data.id,
354
+ upvoted: false,
355
+ downvoted: false,
356
+ quotedMessage: "",
357
+ createdAt: getDataTime(-1),
358
+ extraInfo: JSON.stringify(obj.extraInfos)
359
+ }));
360
+ return newHistoryMessageList;
361
+ });
362
+ scrollToBottom();
363
+ if (type == 4) {
364
+ sendGreetingMessage(6);
365
+ }
366
+ }
367
+ }).catch(function(err) {
368
+ console.log(err);
369
+ });
370
+ };
371
+ //消息发送给老师type == 1,召唤老师时发送,type == 2,在老师聊天窗口聊天
372
+ var sendToTeacher = function(type) {
373
+ console.log("消息发送给老师111");
374
+ var obj = {};
375
+ if (type == 1) {
376
+ obj = {
377
+ roomId: roomId,
378
+ sender: mid,
379
+ recevier: chatWith.uid,
380
+ message: problem.question
381
+ };
382
+ } else if (type == 2) {
383
+ var list = roomList.filter(function(item) {
384
+ return item.roomId == roomId;
385
+ });
386
+ var recevier = "";
387
+ if (list.length > 0) {
388
+ recevier = list[0].sender;
389
+ }
390
+ obj = {
391
+ roomId: roomId,
392
+ sender: mid,
393
+ recevier: recevier,
394
+ message: keyWord
395
+ };
396
+ }
397
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj, {
398
+ headers: {
399
+ "x-module-id": userData.modules.find(function(ele) {
400
+ return ele.short == "TeacherAnswer";
401
+ }).id,
402
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
403
+ }
404
+ }).then(function(res) {
405
+ if (res.data.id) {
406
+ setHistoryMessageList(function(historyMessageList) {
407
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
408
+ id: res.data.id,
409
+ upvoted: false,
410
+ downvoted: false,
411
+ quotedMessage: "",
412
+ createdAt: getDataTime(-1)
413
+ }));
414
+ return newHistoryMessageList;
415
+ });
416
+ scrollToBottom();
417
+ //记录一个问题id,用于记录老师和学生之间的聊天保存到实验报告中
418
+ if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4)) {
419
+ // setChatObj({'roomId':roomId,'id':res.data.id});
420
+ var obj1 = [
421
+ {
422
+ "roomId": roomId,
423
+ "id": res.data.id
424
+ }
425
+ ];
426
+ setChatObj(function(list) {
427
+ var list2 = list.filter(function(item) {
428
+ return item.id != obj1[0].id;
429
+ });
430
+ return list2.concat(obj1);
431
+ });
432
+ }
433
+ }
434
+ }).catch(function(err) {
435
+ console.log(err);
436
+ });
437
+ };
438
+ //发送知识库问题 item,flag == 1 是获取问候信息的答案,flag == 2 是普通消息
439
+ var sendMessage = function(item, flag) {
440
+ var questions = [];
441
+ if (item && flag) {
442
+ questions = [
443
+ item
444
+ ];
445
+ }
446
+ //点击知识库的问题,或者是点击问候消息
447
+ if (questions.length > 0) {
448
+ questions = questions[0];
449
+ //向知识库发送问题 type 1,发送问题 2 发送答案 obj 需要的参数
450
+ var obj = {
451
+ roomId: roomId,
452
+ sender: mid,
453
+ recevier: "AI",
454
+ message: questions.question,
455
+ extraInfos: [
456
+ {
457
+ key: "questionId",
458
+ value: flag == 1 ? questions.value : questions.id
459
+ }
460
+ ]
461
+ };
462
+ //发送问题 1 类型,发送问题需要的参数,问题的答案id等
463
+ sendingExistingIssues(1, obj, {
464
+ key: "questionId",
465
+ value: flag == 1 ? questions.value : questions.id,
466
+ answer: questions.answer
467
+ });
468
+ setKeyWord("");
469
+ setQuestionsList([]);
470
+ setCitationContent({});
471
+ } else if (userData.modules.some(function(item) {
472
+ return item.short == "AIservice";
473
+ })) {
474
+ setHistoryMessageList(function(historyMessageList) {
475
+ var newHistoryMessageList = historyMessageList.concat({
476
+ roomId: roomId,
477
+ sender: mid,
478
+ recevier: "AI",
479
+ message: keyWord,
480
+ quotedMessage: citationContent.content,
481
+ id: "654321",
482
+ upvoted: false,
483
+ downvoted: false,
484
+ createdAt: getDataTime(-1),
485
+ extraInfo: JSON.stringify([])
486
+ });
487
+ return newHistoryMessageList;
488
+ });
489
+ setFinished(false);
490
+ aiSendQuestions(3, {
491
+ //相关数据
492
+ roomId: roomId,
493
+ message: keyWord,
494
+ quotedMessage: citationContent.content || "",
495
+ regenerate: citationContent.content != "" ? false : true,
496
+ generateUpvoteOrDownvoteMessage: false
497
+ }, 1);
498
+ //存在AI客服
499
+ } else {
500
+ //不存在AI客服
501
+ sendGreetingMessage(4);
502
+ }
503
+ };
504
+ //向知识库发送问题 或答案 type:1 发送问题 2 接受答案
505
+ var sendingExistingIssues = function(type, obj, questions) {
506
+ setHistoryMessageList(function(historyMessageList) {
507
+ var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
508
+ id: null,
509
+ upvoted: false,
510
+ downvoted: false,
511
+ createdAt: getDataTime(-1),
512
+ extraInfo: JSON.stringify(obj.extraInfos)
513
+ }));
514
+ return newHistoryMessageList;
515
+ });
516
+ scrollToBottom();
517
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj, {
518
+ headers: {
519
+ "x-module-id": userData.modules.find(function(ele) {
520
+ return ele.short == "IntelligentCustomerService";
521
+ }).id,
522
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
523
+ }
524
+ }).then(function(res) {
525
+ if (res.data.id) {
526
+ //更新聊天记录id
527
+ setHistoryMessageList(function(historyMessageList) {
528
+ var newHistoryMessageList = historyMessageList.map(function(item) {
529
+ if (item.id == null) {
530
+ return _object_spread_props(_object_spread({}, item), {
531
+ id: res.data.id
532
+ });
533
+ } else {
534
+ return item;
535
+ }
536
+ });
537
+ return newHistoryMessageList;
538
+ });
539
+ }
540
+ if (type == 1) {
541
+ //发送答案,调用自动回答
542
+ var dataObj = {
543
+ roomId: roomId,
544
+ sender: "AI",
545
+ recevier: mid,
546
+ message: questions.answer,
547
+ extraInfos: [
548
+ {
549
+ key: "questionId",
550
+ value: questions.value
551
+ }
552
+ ]
553
+ };
554
+ sendingExistingIssues(2, dataObj, "");
555
+ testLabQuestion(obj.message, questions.answer, "");
556
+ }
557
+ }).then(function(res) {
558
+ console.log(res);
559
+ });
560
+ };
561
+ //向AI发送问题 type == 1 发送点赞或踩消息,type == 2 发送重新生成消息,type == 3 正常发送消息
562
+ var content = ""; //用于实验报告的问题记录
563
+ var aiSendQuestions = function(type, obj, id) {
564
+ content = "";
565
+ // if (type == 3) {
566
+ // try {
567
+ // if (ctrl && ctrl.current) {
568
+ // ctrl.current.abort();
569
+ // }
570
+ // } catch (error) {}
571
+ // clearTimeout(receiveMessageTimer.current);
572
+ // setHistoryMessageList((historyMessageList) => {
573
+ // return historyMessageList.filter((item) => item.id != "123456");
574
+ // });
575
+ // setFinished(true);
576
+ // return;
577
+ // }
578
+ ctrl.current = new AbortController();
579
+ clearTimeout(receiveMessageTimer.current);
580
+ receiveMessageTimer.current = setTimeout(function() {
581
+ // console.log('超时终止1111')
582
+ setHistoryMessageList(function(historyMessageList) {
583
+ return historyMessageList.filter(function(item) {
584
+ return item.id != "123456" && item.id != "654321";
585
+ });
586
+ });
587
+ setFinished(true);
588
+ ctrl.current.abort();
589
+ setHistoryMessageList(function(historyMessageList) {
590
+ return historyMessageList.concat({
591
+ roomId: roomId,
592
+ sender: "AI",
593
+ recevier: mid,
594
+ message: "网络异常,请稍后重试!",
595
+ id: "123456",
596
+ createdAt: getDataTime(-1),
597
+ extraInfo: null
598
+ });
599
+ });
600
+ }, 60 * 1000);
601
+ var data = JSON.stringify(obj);
602
+ // if (type == 1 || type == 2) {
603
+ // data = JSON.stringify(obj);
604
+ // } else if(type == 3){
605
+ // data = JSON.stringify({
606
+ // //相关数据
607
+ // roomId: roomId,
608
+ // message: keyWord,
609
+ // quotedMessage: citationContent.content || "",
610
+ // regenerate: citationContent.content != "" ? false : true,
611
+ // generateUpvoteOrDownvoteMessage: false,
612
+ // });
613
+ // }
614
+ setKeyWord("");
615
+ setQuestionsList([]);
616
+ setTimeout(function() {
617
+ setQuestionsList([]);
618
+ }, 2000);
619
+ //占位信息
620
+ setHistoryMessageList(function(historyMessageList) {
621
+ if (type == 2) {
622
+ return historyMessageList.map(function(item) {
623
+ if (item.id == id) {
624
+ return {
625
+ roomId: roomId,
626
+ sender: "AI",
627
+ recevier: mid,
628
+ message: "正在输入...",
629
+ id: "123456",
630
+ createdAt: getDataTime(-1),
631
+ extraInfo: null
632
+ };
633
+ } else {
634
+ return item;
635
+ }
636
+ });
637
+ } else {
638
+ return historyMessageList.concat({
639
+ roomId: roomId,
640
+ sender: "AI",
641
+ recevier: mid,
642
+ message: "正在输入...",
643
+ id: "123456",
644
+ createdAt: getDataTime(-1),
645
+ extraInfo: null
646
+ });
647
+ }
648
+ });
649
+ setTimeout(function() {
650
+ scrollToBottom();
651
+ }, 10);
652
+ //使用fetchEventSource接收数据
653
+ var eventSource = fetchEventSource("".concat(urllocation, "/chat-service/public/v1.0/chat-with-ai/messages"), {
654
+ method: "POST",
655
+ headers: {
656
+ "Content-Type": "application/json",
657
+ Accept: "text/event-stream,application/json",
658
+ "X-Auth-Jwt": window.localStorage.getItem("usertoken") || "",
659
+ "Auth-Token": userData.token,
660
+ "X-Module-Id": userData.modules.find(function(ele) {
661
+ return ele.short == "AIservice";
662
+ }).id
663
+ },
664
+ body: data,
665
+ signal: ctrl.current.signal,
666
+ openWhenHidden: true,
667
+ onopen: function onopen(res) {
668
+ console.info("eventSource open: ", res);
669
+ clearTimeout(receiveMessageTimer.current);
670
+ if (res.status >= 300) {
671
+ console.log("sdckjsdncskdcjsdc", res.status);
672
+ setFinished(true);
673
+ setHistoryMessageList(function(historyMessageList) {
674
+ return historyMessageList.filter(function(item) {
675
+ return item.id != "123456" && item.id != "654321";
676
+ });
677
+ });
678
+ ctrl.current.abort();
679
+ }
680
+ if (res.status == 200) {
681
+ setFinished(false);
682
+ }
683
+ if (res.status == 401) {
684
+ //身份认证未通过,从新请求新的token后再次发送请求
685
+ verifyJWT(urllocation).then(function() {
686
+ console.log("重新请求");
687
+ setHistoryMessageList(function(historyMessageList) {
688
+ return historyMessageList.filter(function(item) {
689
+ return item.id != "123456" && item.id != "654321";
690
+ });
691
+ });
692
+ aiSendQuestions(type, obj, id);
693
+ });
694
+ }
695
+ if (res.status == 403) {
696
+ //暂无权限
697
+ console.log("暂无权限");
698
+ setHistoryMessageList(function(historyMessageList) {
699
+ return historyMessageList.concat({
700
+ roomId: roomId,
701
+ sender: "AI",
702
+ recevier: mid,
703
+ message: "暂无权限",
704
+ id: "123456",
705
+ createdAt: "",
706
+ extraInfo: null
707
+ });
708
+ });
709
+ }
710
+ if (res.status == 429) {
711
+ //同一时间只允许进行一个对话。
712
+ }
713
+ if (res.status == 429) {
714
+ //每天问答的 Token 数必须小于等于 10 万。
715
+ sendGreetingMessage(5);
716
+ }
717
+ if (res.status == 500) {
718
+ // 系统错误,请稍后再试。
719
+ setHistoryMessageList(function(historyMessageList) {
720
+ return historyMessageList.concat({
721
+ roomId: roomId,
722
+ sender: "AI",
723
+ recevier: mid,
724
+ message: "系统出错了,请稍后重试!",
725
+ id: "123456",
726
+ createdAt: "",
727
+ extraInfo: null
728
+ });
729
+ });
730
+ }
731
+ },
732
+ onerror: function onerror(err) {
733
+ console.log(err, "dflkvdmfvlkdfv");
734
+ var state = err.response;
735
+ setHistoryMessageList(function(historyMessageList) {
736
+ return historyMessageList.concat({
737
+ roomId: roomId,
738
+ sender: "AI",
739
+ recevier: mid,
740
+ message: "系统出错了,请稍后重试!",
741
+ id: "123456",
742
+ createdAt: "",
743
+ extraInfo: null
744
+ });
745
+ });
746
+ },
747
+ onmessage: function onmessage(event) {
748
+ //识别的内容
749
+ // console.log("eventSource msg: ", event.data);
750
+ var msg = JSON.parse(event.data);
751
+ if (msg.message) {
752
+ content = content + msg.message;
753
+ renderAiAnswer(msg, id, type);
754
+ }
755
+ if (msg.finished) {
756
+ setFinished(true); //发送结束
757
+ console.log(content, JSON.parse(data), "sdklcksdlcms");
758
+ testLabQuestion(JSON.parse(data).message, content, "");
759
+ }
760
+ },
761
+ onclose: function onclose() {
762
+ setFinished(true); //发送结束
763
+ setHistoryMessageList(function(historyMessageList) {
764
+ return historyMessageList.filter(function(item) {
765
+ return item.id != "123456";
766
+ });
767
+ });
768
+ }
769
+ });
770
+ };
771
+ //渲染AI回答
772
+ var renderAiAnswer = function(msg, message_id, type) {
773
+ // console.log(aiSendQuestions().abort(),'slkdsdsdsd')
774
+ var obj = msg;
775
+ var id = msg.messageId;
776
+ setHistoryMessageList(function(historyMessageList) {
777
+ var list1 = historyMessageList;
778
+ //删除临时数据
779
+ list1 = list1.filter(function(item) {
780
+ return item.id != "123456";
781
+ });
782
+ //重新生成答案时,使用原来的消息
783
+ if (message_id != undefined) {
784
+ list1 = list1.filter(function(item) {
785
+ return item.id != message_id;
786
+ });
787
+ }
788
+ var list = historyMessageList.filter(function(item) {
789
+ return item.id == id;
790
+ });
791
+ var message = "";
792
+ if (list.length == 0) {
793
+ message = obj.message;
794
+ var newHistoryMessageList = list1.concat({
795
+ roomId: roomId,
796
+ sender: "AI",
797
+ recevier: mid,
798
+ message: message,
799
+ id: id,
800
+ upvoted: false,
801
+ downvoted: false,
802
+ createdAt: getDataTime(-1),
803
+ extraInfo: type == 1 ? JSON.stringify([
804
+ {
805
+ key: "isVoteMessage",
806
+ value: true
807
+ }
808
+ ]) : null
809
+ });
810
+ return newHistoryMessageList;
811
+ } else {
812
+ var newHistoryMessageList2 = list1.map(function(item) {
813
+ message = item.message + obj.message;
814
+ if (item.id == id) {
815
+ return _object_spread_props(_object_spread({}, item), {
816
+ message: message
817
+ });
818
+ } else {
819
+ return item;
820
+ }
821
+ });
822
+ return newHistoryMessageList2;
823
+ }
824
+ });
825
+ setTimeout(function() {
826
+ scrollToBottom();
827
+ }, 10);
828
+ };
829
+ //问题记录到实验报告中
830
+ var testLabQuestion = function(title, content, teachId) {
831
+ console.log(title, content, "记录到实验报告中");
832
+ if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4)) {
833
+ http.post("".concat(urllocation, "/sandboxes/public/v1.0/labquestion"), {
834
+ title: title,
835
+ content: content,
836
+ teachId: teachId != undefined ? teachId : chatWith.uid | mid,
837
+ stepId: stepId,
838
+ stepIds: stepIds
839
+ }, {
840
+ headers: {
841
+ "x-module-id": userData.modules.find(function(ele) {
842
+ return ele.short == "IntelligentCustomerService";
843
+ }).id,
844
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
845
+ }
846
+ });
847
+ }
848
+ };
849
+ //语音转文字
850
+ var speechToText = function() {
851
+ http.post("".concat(urllocation, "/chat-service/public/v1.0/speech:recognize"), {
852
+ audio: bese64String
853
+ }, {
854
+ headers: {
855
+ "x-module-id": userData.modules.find(function(ele) {
856
+ return ele.short == "AIservice";
857
+ }).id,
858
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
859
+ }
860
+ }).then(function(res) {
861
+ setVoiceRecordingStatus(3);
862
+ if (res.data) {
863
+ setKeyWord(res.data.text);
864
+ resettingBottomHei();
865
+ }
866
+ }).catch(function(err) {
867
+ setKeyWord("");
868
+ setVoiceRecordingStatus(3);
869
+ });
870
+ };
871
+ //创建聊天室
872
+ var createRooms = function(uid) {
873
+ return http.post("".concat(urllocation, "/chat-service/public/v1.0/rooms"), {
874
+ chatWith: uid
875
+ }, {
876
+ headers: {
877
+ "x-module-id": userData.modules.find(function(ele) {
878
+ return ele.short == "IntelligentCustomerService";
879
+ }).id,
880
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
881
+ }
882
+ });
883
+ };
884
+ //获取历史消息 flag:1,历史记录点击定位,2,代表是下拉加载,3,存在新的消息-->老师回答等
885
+ var getHistoryMessage = function(pageNum, flag) {
886
+ console.log(pageNum, flag, "重新加载数据2222");
887
+ if (roomId == "") return;
888
+ return http.get("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), {
889
+ params: {
890
+ roomId: roomId,
891
+ page: pageNum != undefined && pageNum != -1 ? pageNum : 1,
892
+ maxPageSize: 30,
893
+ direction: "desc"
894
+ },
895
+ headers: {
896
+ "x-module-id": userData.modules.find(function(ele) {
897
+ return ele.short == "IntelligentCustomerService";
898
+ }).id,
899
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
900
+ }
901
+ }).then(function(res) {
902
+ if (res.data.messages.length > 0) {
903
+ clearTimeout(listTimer.current);
904
+ var last_id = "";
905
+ var total = res.data.total;
906
+ var maxPageSize = 30;
907
+ var dataList = res.data.messages.reverse();
908
+ setPageCount(Math.ceil(total / maxPageSize));
909
+ var newHistoryMessageList = [];
910
+ setHistoryMessageList(function(historyMessageList) {
911
+ if (flag != 1 && historyMessageList.length > 0) {
912
+ if (flag == 2) {
913
+ last_id = historyMessageList[historyMessageList.length - 1].id;
914
+ } else {
915
+ last_id = historyMessageList[0].id;
916
+ }
917
+ }
918
+ newHistoryMessageList = [];
919
+ //查找历史记录flag==1
920
+ if (pageNum == 1 || flag == 1 || flag == 3) {
921
+ newHistoryMessageList = dataList;
922
+ } else if (flag == 2) {
923
+ //下拉加载
924
+ newHistoryMessageList = historyMessageList.concat(dataList);
925
+ } else {
926
+ newHistoryMessageList = dataList.concat(historyMessageList);
927
+ }
928
+ var _$res = new Map();
929
+ newHistoryMessageList = newHistoryMessageList.filter(function(a) {
930
+ return !_$res.has(a.id) && _$res.set(a.id, 1);
931
+ });
932
+ return newHistoryMessageList;
933
+ });
934
+ //如果在跟老师的聊天窗口,用于找到与老师的最新的聊天,并不在与老师对话的窗口中,并聊天窗口相同
935
+ try {
936
+ if (stepIds != undefined && stepIds != "" && (showType == 3 || showType == 4) && roomList.length > 0 && roomList[0].roomId != roomId) {
937
+ fildChatRecords(newHistoryMessageList);
938
+ }
939
+ } catch (error) {}
940
+ if (flag != 1) {
941
+ setLastId(last_id);
942
+ }
943
+ if (pageNum == 1 && flag != 1 || flag == 3) {
944
+ scrollToBottom();
945
+ } else {
946
+ console.log("滚动到相应为止3333");
947
+ scrollTo("li_flag");
948
+ }
949
+ setGreetingMessage(true);
950
+ //召唤老师回答
951
+ console.log(problem, 8888888);
952
+ if (problem != undefined && problem.user != undefined && problem.question != undefined) {
953
+ console.log(problem, 77777);
954
+ sendToTeacher(1);
955
+ }
956
+ } else {
957
+ setPageCount(0);
958
+ setGreetingMessage(true);
959
+ setLoading(false);
960
+ setHistoryMessageList([]);
961
+ //召唤老师回答
962
+ console.log(problem, 8888888);
963
+ if (problem != undefined && problem.user != undefined && problem.question != undefined) {
964
+ console.log(problem, 77777);
965
+ sendToTeacher(1);
966
+ }
967
+ }
968
+ }).catch(function(res) {
969
+ setLoading(false);
970
+ });
971
+ };
972
+ //在聊天对话框中查找需要记录的问题及答案
973
+ var fildChatRecords = function(newHistoryMessageList) {
974
+ //1、找到对应的聊天室
975
+ //2、找到与老师对话的新聊天
976
+ //3、保存聊天到实验报告
977
+ console.log("查找聊天111", chatObj);
978
+ var room = chatObj.filter(function(item) {
979
+ return item.roomId == roomId;
980
+ });
981
+ if (room.length > 0) {
982
+ console.log(room, "dfvdfvdfvdfv");
983
+ var roomIDnumber = room[0].roomId;
984
+ var chatID = room[0].id;
985
+ var index = -1;
986
+ newHistoryMessageList.forEach(function(item, i) {
987
+ console.log(item, item.id, "lskdcmsldksdcsdc");
988
+ if (item.id == chatID) {
989
+ index = i;
990
+ return false;
991
+ }
992
+ });
993
+ //有新的消息
994
+ if (index != -1) {
995
+ var newMessage = newHistoryMessageList.slice(index);
996
+ console.log(newMessage, "需要记录的聊天");
997
+ //1、查找 sender发送者
998
+ var objList = [];
999
+ var obj = {};
1000
+ var position = -1;
1001
+ newMessage.map(function(item, i) {
1002
+ if (item.sender == mid && position != i) {
1003
+ objList.push(obj);
1004
+ obj = {};
1005
+ }
1006
+ //发送者
1007
+ if (item.sender == mid) {
1008
+ obj.title = item.message;
1009
+ position = i;
1010
+ }
1011
+ if (item.sender != mid) {
1012
+ obj.con = item.message;
1013
+ obj.teachId = item.receiver;
1014
+ }
1015
+ });
1016
+ //需要保存的记录
1017
+ objList = objList.filter(function(item) {
1018
+ return item.title != undefined;
1019
+ });
1020
+ objList.map(function(item) {
1021
+ //保存聊天记录
1022
+ testLabQuestion(item.title, item.con, item.teachId);
1023
+ //删除已经保存的记录
1024
+ setChatObj(function(list) {
1025
+ return list.filter(function(a) {
1026
+ return a.roomId != roomIDnumber;
1027
+ });
1028
+ });
1029
+ });
1030
+ console.log(objList, "sdkcjnsdkjcsd");
1031
+ }
1032
+ }
1033
+ };
1034
+ //点赞消息
1035
+ var likeMessage = function(id, state) {
1036
+ var url = "";
1037
+ //点赞状态
1038
+ if (!state) {
1039
+ url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:upvote");
1040
+ } else {
1041
+ url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:cancelUpvote");
1042
+ }
1043
+ http.post(url, {
1044
+ messageId: id
1045
+ }, {
1046
+ headers: {
1047
+ "x-module-id": userData.modules.find(function(ele) {
1048
+ return ele.short == "IntelligentCustomerService";
1049
+ }).id,
1050
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1051
+ }
1052
+ }).then(function(res) {
1053
+ setHistoryMessageList(function(historyMessageList) {
1054
+ var list = historyMessageList;
1055
+ list = list.map(function(item) {
1056
+ return _object_spread_props(_object_spread({}, item), {
1057
+ upvoted: item.id == id ? !state : item.upvoted,
1058
+ downvoted: item.id == id && !state ? state : item.downvoted
1059
+ });
1060
+ });
1061
+ return list;
1062
+ });
1063
+ });
1064
+ };
1065
+ //踩
1066
+ var disagreeMessage = function(id, state) {
1067
+ var url = "";
1068
+ //点赞状态
1069
+ if (!state) {
1070
+ url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:downvote");
1071
+ } else {
1072
+ url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:cancelDownvote");
1073
+ }
1074
+ http.post(url, {
1075
+ messageId: id
1076
+ }, {
1077
+ headers: {
1078
+ "x-module-id": userData.modules.find(function(ele) {
1079
+ return ele.short == "IntelligentCustomerService";
1080
+ }).id,
1081
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1082
+ }
1083
+ }).then(function(res) {
1084
+ setHistoryMessageList(function(historyMessageList) {
1085
+ var list = historyMessageList;
1086
+ list = list.map(function(item) {
1087
+ return _object_spread_props(_object_spread({}, item), {
1088
+ downvoted: item.id == id ? !state : item.downvoted,
1089
+ upvoted: item.id == id && !state ? state : item.upvoted
1090
+ });
1091
+ });
1092
+ return list;
1093
+ });
1094
+ });
1095
+ };
1096
+ //获取问题列表flag ==1 是问候消息 2,搜索列表 展示相关问题
1097
+ var getQuestiionsList = function(value, flag) {
1098
+ var data = {};
1099
+ if (flag == 1) {
1100
+ data = {
1101
+ page: 1,
1102
+ maxPageSize: 5
1103
+ };
1104
+ } else {
1105
+ data = {
1106
+ page: 1,
1107
+ maxPageSize: 4,
1108
+ question: value
1109
+ };
1110
+ }
1111
+ http.get("".concat(urllocation, "/chat-service/public/v1.0/knowledge-base/questions"), {
1112
+ params: data,
1113
+ headers: {
1114
+ "x-module-id": userData.modules.find(function(ele) {
1115
+ return ele.short == "IntelligentCustomerService";
1116
+ }).id,
1117
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1118
+ }
1119
+ }).then(function(res) {
1120
+ if (res.data.questions) {
1121
+ if (flag == 1) {
1122
+ setHotQuestionsList(res.data.questions);
1123
+ } else {
1124
+ setQuestionsList(res.data.questions);
1125
+ }
1126
+ }
1127
+ });
1128
+ };
1129
+ //获取老师列表
1130
+ var getTeacherList = function(keyWord) {
1131
+ http.get("".concat(urllocation, "/chat-service/public/v1.0/teachers"), {
1132
+ params: {
1133
+ name: keyWord
1134
+ },
1135
+ headers: {
1136
+ "x-module-id": userData.modules.find(function(ele) {
1137
+ return ele.short == "TeacherAnswer";
1138
+ }).id,
1139
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
1140
+ }
1141
+ }).then(function(res) {
1142
+ console.log(res);
1143
+ if (res.data) {
1144
+ setTeacherList(res.data.teachers);
1145
+ }
1146
+ });
1147
+ };
1148
+ //设置滚动条滚动到底部
1149
+ var scrollToBottom = function() {
1150
+ console.log("滚动条滚动到底部");
1151
+ var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1152
+ if (container) {
1153
+ container.scrollTop = container.scrollHeight;
1154
+ }
1155
+ };
1156
+ var scrollTo = function(id) {
1157
+ console.log(id, "滚动到指定位置");
1158
+ var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
1159
+ var container2 = document.getElementById(id);
1160
+ // clearTimeout(listTimer.current)
1161
+ if (container && container2) {
1162
+ // container.scrollTop = container2.scrollHeight;
1163
+ // if(container2.scrollTop == 0){
1164
+ container.scrollTop = 60;
1165
+ setTimeout(function() {
1166
+ var top = showType == 1 ? $("#li_flag").offset().top - 20 : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top + 24;
1167
+ $("#".concat(showType == 1 ? "chat_content" : "chat_content_modal")).animate({
1168
+ scrollTop: top
1169
+ }, 0);
1170
+ }, 10);
1171
+ // }
1172
+ // clearTimeout(listTimer.current)
1173
+ setLoading(false);
1174
+ }
1175
+ };
1176
+ // 获取新的JWT
1177
+ var verifyJWT = function(url) {
1178
+ return new Promise(function(resolve) {
1179
+ http.get("".concat(url, "/regusers/login/Refreshtoken")).then(function(res) {
1180
+ if (res.data.code == 200) {
1181
+ window.localStorage.setItem("usertoken", res.data.data);
1182
+ resolve(res.data.data);
1183
+ } else {
1184
+ throw new Error(res.data.code);
1185
+ }
1186
+ }).catch(function(err) {
1187
+ resolve(err);
1188
+ });
1189
+ });
1190
+ };
1191
+ //渲染头部
1192
+ var renderHeader = function() {
1193
+ if (showType == 4) {
1194
+ return /*#__PURE__*/ _jsxs("div", {
1195
+ className: styles.top,
1196
+ children: [
1197
+ /*#__PURE__*/ _jsx("div", {
1198
+ className: styles.user,
1199
+ children: /*#__PURE__*/ _jsx("p", {
1200
+ children: "智能回答"
1201
+ })
1202
+ }),
1203
+ /*#__PURE__*/ _jsxs("div", {
1204
+ className: styles.operate,
1205
+ children: [
1206
+ /*#__PURE__*/ _jsx("i", {
1207
+ onClick: function() {
1208
+ setShowHistory(true);
1209
+ },
1210
+ children: /*#__PURE__*/ _jsx(CustomRecord, {})
1211
+ }),
1212
+ /*#__PURE__*/ _jsx("span", {
1213
+ className: styles.line
1214
+ }),
1215
+ /*#__PURE__*/ _jsx("i", {
1216
+ onClick: function() {
1217
+ onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
1218
+ setShowType(3);
1219
+ },
1220
+ children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
1221
+ }),
1222
+ /*#__PURE__*/ _jsx("i", {
1223
+ onClick: function() {
1224
+ onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
1225
+ setShowType(3);
1226
+ },
1227
+ children: /*#__PURE__*/ _jsx(CloseOutlined, {})
1228
+ })
1229
+ ]
1230
+ })
1231
+ ]
1232
+ });
1233
+ } else if (showType == 3) {
1234
+ return /*#__PURE__*/ _jsxs("div", {
1235
+ className: styles.top,
1236
+ children: [
1237
+ /*#__PURE__*/ _jsx("div", {
1238
+ className: styles.user,
1239
+ children: /*#__PURE__*/ _jsx("p", {
1240
+ children: "智能回答"
1241
+ })
1242
+ }),
1243
+ /*#__PURE__*/ _jsxs("div", {
1244
+ className: styles.operate,
1245
+ children: [
1246
+ /*#__PURE__*/ _jsx("i", {
1247
+ onClick: function() {
1248
+ setShowHistory(true);
1249
+ },
1250
+ children: /*#__PURE__*/ _jsx(CustomRecord, {})
1251
+ }),
1252
+ /*#__PURE__*/ _jsx("span", {
1253
+ className: styles.line
1254
+ }),
1255
+ /*#__PURE__*/ _jsx("i", {
1256
+ onClick: function() {
1257
+ onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
1258
+ setShowType(4);
1259
+ },
1260
+ children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
1261
+ }),
1262
+ /*#__PURE__*/ _jsx("i", {
1263
+ className: "lianxiren21",
1264
+ onClick: function() {
1265
+ setShowContacts(true);
1266
+ },
1267
+ children: /*#__PURE__*/ _jsx(CustomContacts, {})
1268
+ })
1269
+ ]
1270
+ })
1271
+ ]
1272
+ });
1273
+ } else {
1274
+ return /*#__PURE__*/ _jsxs("div", {
1275
+ className: styles.top,
1276
+ children: [
1277
+ /*#__PURE__*/ _jsx("div", {
1278
+ className: styles.user,
1279
+ children: /*#__PURE__*/ _jsxs("p", {
1280
+ children: [
1281
+ showType == 1 && /*#__PURE__*/ _jsx("i", {
1282
+ className: "lianxiren21",
1283
+ onClick: function() {
1284
+ setShowContacts(true);
1285
+ },
1286
+ children: /*#__PURE__*/ _jsx(CustomContacts, {})
1287
+ }),
1288
+ "智能回答"
1289
+ ]
1290
+ })
1291
+ }),
1292
+ /*#__PURE__*/ _jsxs("div", {
1293
+ className: styles.operate,
1294
+ children: [
1295
+ /*#__PURE__*/ _jsx("i", {
1296
+ className: "_lishixiao22",
1297
+ onClick: function() {
1298
+ setShowHistory(true);
1299
+ },
1300
+ children: /*#__PURE__*/ _jsx(CustomRecord, {})
1301
+ }),
1302
+ /*#__PURE__*/ _jsx("span", {
1303
+ className: styles.line
1304
+ }),
1305
+ showType == 1 ? /*#__PURE__*/ _jsx("i", {
1306
+ onClick: function() {
1307
+ onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
1308
+ // switchDialogBox(3, true);
1309
+ setShowType(2);
1310
+ },
1311
+ children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
1312
+ }) : /*#__PURE__*/ _jsx("i", {
1313
+ onClick: function() {
1314
+ onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
1315
+ // switchDialogBox(1, true);
1316
+ setShowType(1);
1317
+ },
1318
+ children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
1319
+ }),
1320
+ /*#__PURE__*/ _jsx("i", {
1321
+ onClick: onCancel,
1322
+ children: /*#__PURE__*/ _jsx(CloseOutlined, {})
1323
+ })
1324
+ ]
1325
+ })
1326
+ ]
1327
+ });
1328
+ }
1329
+ };
1330
+ //重置底部输入框高度
1331
+ var resettingBottomHei = function() {
1332
+ setTimeout(function() {
1333
+ if (showType == 1 || showType == 3) {
1334
+ var hei = document.getElementById("Drawer_buttom").offsetHeight;
1335
+ setButtomHei(hei);
1336
+ } else {
1337
+ var hei1 = document.getElementById("Drawer_buttom_modal").offsetHeight;
1338
+ setButtomHei(hei1);
1339
+ }
1340
+ }, 50);
1341
+ };
1342
+ //切换聊天室 type == renew ,存在新消息
1343
+ var switchChatRoom = function(id, type) {
1344
+ if (type == "renew") {
1345
+ getHistoryMessage(1, 3);
1346
+ }
1347
+ setRoomId(id);
1348
+ readMessage(id, urllocation, userData, http);
1349
+ };
1350
+ var saveContactsList = function(list) {
1351
+ if (list != undefined) {
1352
+ setRoomList(list);
1353
+ }
1354
+ };
1355
+ //渲染问答
1356
+ var renderQuestion = function() {
1357
+ // console.log(mid, historyMessageList, "ddkfdscksdcs");
1358
+ if (historyMessageList.length > 0) {
1359
+ // let historyData = "";
1360
+ // let showData = true;
1361
+ return /*#__PURE__*/ _jsx("ul", {
1362
+ className: styles.message_con,
1363
+ children: historyMessageList.map(function(item, i) {
1364
+ // console.log(item.message);
1365
+ var message = item.message;
1366
+ var li;
1367
+ // 是否需要显示日期
1368
+ var itemIndex = historyMessageList.findIndex(function(ite) {
1369
+ return ite.id === item.id;
1370
+ });
1371
+ var time = "";
1372
+ if (itemIndex <= 0) {
1373
+ //第一项
1374
+ time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
1375
+ } else {
1376
+ //非第一项 与上一项进行对比
1377
+ var beforeTime = historyMessageList[itemIndex - 1].createdAt;
1378
+ //判断与上一条数据 是否跨天
1379
+ if (dayjs(beforeTime).format("YYYY-MM-DD") !== dayjs(item.createdAt).format("YYYY-MM-DD")) {
1380
+ time = dayjs(item.createdAt).format("YYYY-MM-DD HH:mm");
1381
+ } else {
1382
+ //没有跨天 判断是否相隔超过10分钟
1383
+ if (dayjs(item.createdAt).valueOf() - dayjs(beforeTime).valueOf() > 10 * 60 * 1000) {
1384
+ time = dayjs(item.createdAt).format("HH:mm");
1385
+ }
1386
+ }
1387
+ }
1388
+ var dataTime = time;
1389
+ if (item.sender == mid) {
1390
+ //只有引用和复制功能
1391
+ li = /*#__PURE__*/ _jsxs(_Fragment, {
1392
+ children: [
1393
+ dataTime ? /*#__PURE__*/ _jsx("li", {
1394
+ className: styles.time,
1395
+ children: dataTime
1396
+ }) : "",
1397
+ /*#__PURE__*/ _jsxs("li", {
1398
+ className: styles.left,
1399
+ id: lastId == item.id ? "li_flag" : "",
1400
+ children: [
1401
+ /*#__PURE__*/ _jsxs("div", {
1402
+ className: styles.main,
1403
+ children: [
1404
+ /*#__PURE__*/ _jsxs("div", {
1405
+ className: styles.main_content,
1406
+ children: [
1407
+ /*#__PURE__*/ _jsx("div", {
1408
+ className: styles.operate_modal,
1409
+ children: /*#__PURE__*/ _jsxs("p", {
1410
+ className: styles.operate,
1411
+ children: [
1412
+ /*#__PURE__*/ _jsx("i", {
1413
+ className: "yinyong_quote1",
1414
+ onClick: function() {
1415
+ setCitationContent({
1416
+ content: item.message,
1417
+ id: item.id
1418
+ });
1419
+ resettingBottomHei();
1420
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1421
+ },
1422
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1423
+ }),
1424
+ copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
1425
+ return list == item.id;
1426
+ }) ? /*#__PURE__*/ _jsx("i", {
1427
+ className: "tongyong-xuanzhongdui",
1428
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1429
+ }) : /*#__PURE__*/ _jsx("i", {
1430
+ className: "fuzhi21",
1431
+ onClick: function() {
1432
+ var bol = copyText(item.message);
1433
+ if (bol) {
1434
+ var obj = copyTextOBJ;
1435
+ obj = obj.filter(function(list) {
1436
+ return list != item.id;
1437
+ });
1438
+ obj.push(item.id);
1439
+ setCopyTextObj(obj);
1440
+ }
1441
+ setTimeout(function() {
1442
+ var obj = copyTextOBJ;
1443
+ obj = obj.filter(function(list) {
1444
+ return list != item.id;
1445
+ });
1446
+ setCopyTextObj(obj);
1447
+ }, 3000);
1448
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1449
+ },
1450
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1451
+ })
1452
+ ]
1453
+ })
1454
+ }),
1455
+ /*#__PURE__*/ _jsx("div", {
1456
+ className: styles.content,
1457
+ children: /*#__PURE__*/ _jsx("p", {
1458
+ dangerouslySetInnerHTML: {
1459
+ __html: remarkable.render(message)
1460
+ },
1461
+ className: styles.content_child
1462
+ })
1463
+ })
1464
+ ]
1465
+ }),
1466
+ //引用消息
1467
+ item.quotedMessage != "" && item.quotedMessage != null && item.quotedMessage != undefined ? /*#__PURE__*/ _jsx("div", {
1468
+ className: styles.citation_content,
1469
+ children: getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
1470
+ overlayClassName: styles.popover_main_content,
1471
+ title: item.quotedMessage,
1472
+ placement: "leftTop",
1473
+ children: /*#__PURE__*/ _jsx("p", {
1474
+ children: item.quotedMessage
1475
+ })
1476
+ }) : /*#__PURE__*/ _jsx("p", {
1477
+ children: item.quotedMessage
1478
+ })
1479
+ }) : ""
1480
+ ]
1481
+ }),
1482
+ showType == 2 || showType == 4 ? /*#__PURE__*/ _jsx("div", {
1483
+ className: styles.head_sculpture,
1484
+ style: {
1485
+ marginLeft: "12px"
1486
+ },
1487
+ children: /*#__PURE__*/ _jsx("img", {
1488
+ src: userData.avatar
1489
+ })
1490
+ }) : ""
1491
+ ]
1492
+ }, item.id)
1493
+ ]
1494
+ });
1495
+ } else {
1496
+ //获取用户头像
1497
+ var headImg = "";
1498
+ var chatWindow = roomList.filter(function(item) {
1499
+ return item.roomId == roomId;
1500
+ });
1501
+ if (chatWindow.length > 0 && chatWindow[0].headImg != "") {
1502
+ headImg = chatWindow[0].headImg;
1503
+ }
1504
+ //是否在智能客服窗口
1505
+ var isAiChatWindow = chatWindow[0].sender == "AI" ? true : false;
1506
+ li = /*#__PURE__*/ _jsxs(_Fragment, {
1507
+ children: [
1508
+ dataTime ? /*#__PURE__*/ _jsx("li", {
1509
+ className: styles.time,
1510
+ children: dataTime
1511
+ }) : "",
1512
+ /*#__PURE__*/ _jsxs("li", {
1513
+ className: styles.right,
1514
+ id: lastId == item.id ? "li_flag" : "",
1515
+ children: [
1516
+ showType == 2 || showType == 4 && /*#__PURE__*/ _jsx("div", {
1517
+ className: styles.head_sculpture,
1518
+ style: {
1519
+ marginRight: "12px"
1520
+ },
1521
+ children: isAiChatWindow ? item.extraInfo == null ? /*#__PURE__*/ _jsx(CustomAiIcon, {}) : /*#__PURE__*/ _jsx("img", {
1522
+ src: knowledge_icon
1523
+ }) : /*#__PURE__*/ _jsx("img", {
1524
+ src: headImg
1525
+ })
1526
+ }),
1527
+ /*#__PURE__*/ _jsx("div", {
1528
+ className: styles.main,
1529
+ children: /*#__PURE__*/ _jsxs("div", {
1530
+ className: styles.main_content,
1531
+ children: [
1532
+ /*#__PURE__*/ _jsx("div", {
1533
+ className: styles.operate_modal,
1534
+ children: historyMessageList.length - 1 == i && item.extraInfo == null || item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && (JSON.parse(item.extraInfo)[0].key == "messageSource" || JSON.parse(item.extraInfo)[0].key == "isVoteMessage") ? "" : /*#__PURE__*/ _jsxs("p", {
1535
+ className: styles.operate,
1536
+ children: [
1537
+ /*#__PURE__*/ _jsx("span", {
1538
+ className: styles.ask_question,
1539
+ onClick: function() {
1540
+ setAnswerMode(1);
1541
+ setProblem({
1542
+ question: historyMessageList[i - 1].message,
1543
+ user: problem.user
1544
+ });
1545
+ setHistoryMessageList(function(historyMessageList) {
1546
+ var newHistoryMessageList = historyMessageList.concat({
1547
+ id: -1,
1548
+ roomId: roomId,
1549
+ sender: "AI",
1550
+ recevier: mid,
1551
+ message: "请在输入框中输入您要召唤的老师的姓名",
1552
+ createdAt: getDataTime(-1),
1553
+ findTeacher: true
1554
+ });
1555
+ return newHistoryMessageList;
1556
+ });
1557
+ scrollToBottom();
1558
+ },
1559
+ children: "召唤老师回答"
1560
+ }),
1561
+ /*#__PURE__*/ _jsx("i", {
1562
+ className: "yinyong_quote1",
1563
+ onClick: function() {
1564
+ setCitationContent({
1565
+ content: item.message,
1566
+ id: item.id
1567
+ });
1568
+ resettingBottomHei();
1569
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1570
+ console.log("引用222222");
1571
+ },
1572
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1573
+ }),
1574
+ copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
1575
+ return list == item.id;
1576
+ }) ? /*#__PURE__*/ _jsx("i", {
1577
+ className: "tongyong-xuanzhongdui",
1578
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1579
+ }) : /*#__PURE__*/ _jsx("i", {
1580
+ className: "fuzhi21",
1581
+ onClick: function() {
1582
+ var bol = copyText(item.message);
1583
+ if (bol) {
1584
+ var obj = copyTextOBJ;
1585
+ obj = obj.filter(function(list) {
1586
+ return list != item.id;
1587
+ });
1588
+ obj.push(item.id);
1589
+ setCopyTextObj(obj);
1590
+ }
1591
+ setTimeout(function() {
1592
+ var obj = copyTextOBJ;
1593
+ obj = obj.filter(function(list) {
1594
+ return list != item.id;
1595
+ });
1596
+ setCopyTextObj(obj);
1597
+ }, 3000);
1598
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1599
+ },
1600
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1601
+ }),
1602
+ /*#__PURE__*/ _jsx("span", {
1603
+ children: "|"
1604
+ }),
1605
+ /*#__PURE__*/ _jsx("i", {
1606
+ className: "Frame427319094 ".concat(item.upvoted ? styles.active : ""),
1607
+ onClick: function() {
1608
+ likeMessage(item.id, item.upvoted);
1609
+ console.log("判断是AI还是智能回答", item);
1610
+ //只有最后一条回答,支持发送点赞或踩
1611
+ if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1612
+ console.log("判断是AI还是智能回答", item);
1613
+ if (!item.extraInfo && item.sender == "AI") {
1614
+ aiSendQuestions(1, {
1615
+ roomId: roomId,
1616
+ message: "你给出的答案我非常满意,赞!",
1617
+ quotedMessage: "",
1618
+ regenerate: false,
1619
+ generateUpvoteOrDownvoteMessage: true
1620
+ }, 1);
1621
+ } else {
1622
+ console.log("AI回答2255555");
1623
+ sendGreetingMessage(2);
1624
+ }
1625
+ }
1626
+ },
1627
+ children: /*#__PURE__*/ _jsx(CustomLike, {})
1628
+ }),
1629
+ /*#__PURE__*/ _jsx("i", {
1630
+ className: "Frame427319095 ".concat(item.downvoted ? styles.active : ""),
1631
+ onClick: function() {
1632
+ disagreeMessage(item.id, item.downvoted);
1633
+ //只有最后一条回答,支持发送点赞或踩
1634
+ console.log(item, "dlfkvmdflkv");
1635
+ if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1636
+ if (!item.extraInfo && item.sender == "AI") {
1637
+ aiSendQuestions(1, {
1638
+ roomId: roomId,
1639
+ message: "你给出的答案很糟糕,我不满意,踩!",
1640
+ quotedMessage: "",
1641
+ regenerate: false,
1642
+ generateUpvoteOrDownvoteMessage: true
1643
+ }, 1);
1644
+ } else {
1645
+ sendGreetingMessage(3);
1646
+ }
1647
+ }
1648
+ },
1649
+ children: /*#__PURE__*/ _jsx(CustomDislike, {})
1650
+ })
1651
+ ]
1652
+ })
1653
+ }),
1654
+ /*#__PURE__*/ _jsxs("div", {
1655
+ className: styles.content,
1656
+ children: [
1657
+ /*#__PURE__*/ _jsx("p", {
1658
+ dangerouslySetInnerHTML: {
1659
+ __html: remarkable.render(message)
1660
+ },
1661
+ className: styles.content_child
1662
+ }),
1663
+ 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", {
1664
+ className: styles.association_problem,
1665
+ children: JSON.parse(item.extraInfo).map(function(list, index) {
1666
+ return /*#__PURE__*/ _jsxs("li", {
1667
+ onClick: function() {
1668
+ sendMessage(list, 1);
1669
+ },
1670
+ children: [
1671
+ index + 1,
1672
+ ".",
1673
+ list.question
1674
+ ]
1675
+ }, i + "_" + index + "_" + list.value);
1676
+ })
1677
+ }) : ""
1678
+ ]
1679
+ }),
1680
+ !item.findTeacher && historyMessageList.length - 1 == i && item.extraInfo == null && item.id != "123456" ? /*#__PURE__*/ _jsx("div", {
1681
+ className: "".concat(styles.operate_modal_bottom),
1682
+ children: item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && (JSON.parse(item.extraInfo)[0].key == "messageSource" || JSON.parse(item.extraInfo)[0].key == "isVoteMessage") ? "" : /*#__PURE__*/ _jsxs(_Fragment, {
1683
+ children: [
1684
+ /*#__PURE__*/ _jsx("p", {
1685
+ className: styles.stop_generate,
1686
+ children: !finished ? /*#__PURE__*/ _jsxs(_Fragment, {
1687
+ children: [
1688
+ /*#__PURE__*/ _jsx("span", {
1689
+ onClick: function() {
1690
+ // aiSendQuestions(3,{},1);
1691
+ // if (type == 3) {
1692
+ try {
1693
+ if (ctrl && ctrl.current) {
1694
+ ctrl.current.abort();
1695
+ }
1696
+ } catch (error) {}
1697
+ clearTimeout(receiveMessageTimer.current);
1698
+ setHistoryMessageList(function(historyMessageList) {
1699
+ return historyMessageList.filter(function(item) {
1700
+ return item.id != "123456";
1701
+ });
1702
+ });
1703
+ setFinished(true);
1704
+ // return;
1705
+ // }
1706
+ onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
1707
+ }
1708
+ }),
1709
+ /*#__PURE__*/ _jsx("i", {
1710
+ onClick: function() {
1711
+ // aiSendQuestions(3,{},1);
1712
+ try {
1713
+ if (ctrl && ctrl.current) {
1714
+ ctrl.current.abort();
1715
+ }
1716
+ } catch (error) {}
1717
+ clearTimeout(receiveMessageTimer.current);
1718
+ setHistoryMessageList(function(historyMessageList) {
1719
+ return historyMessageList.filter(function(item) {
1720
+ return item.id != "123456";
1721
+ });
1722
+ });
1723
+ setFinished(true);
1724
+ onEvent(serverName + serverUrl(), "click_智能问答_停止生成", "提交");
1725
+ },
1726
+ children: "停止生成"
1727
+ })
1728
+ ]
1729
+ }) : ""
1730
+ }),
1731
+ finished ? /*#__PURE__*/ _jsxs("p", {
1732
+ className: "".concat(styles.operate),
1733
+ children: [
1734
+ /*#__PURE__*/ _jsx("i", {
1735
+ onClick: function() {
1736
+ setFinished(false);
1737
+ aiSendQuestions(2, {
1738
+ roomId: roomId,
1739
+ message: historyMessageList[i - 1].message,
1740
+ quotedMessage: citationContent.content || "",
1741
+ regenerate: true,
1742
+ generateUpvoteOrDownvoteMessage: false
1743
+ }, item.id);
1744
+ onEvent(serverName + serverUrl(), "click_智能问答_重新生成", "提交");
1745
+ },
1746
+ children: /*#__PURE__*/ _jsx(CustomReloading, {})
1747
+ }),
1748
+ /*#__PURE__*/ _jsx("i", {
1749
+ className: "yinyong_quote1",
1750
+ onClick: function() {
1751
+ setCitationContent({
1752
+ content: item.message,
1753
+ id: item.id
1754
+ });
1755
+ resettingBottomHei();
1756
+ onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
1757
+ },
1758
+ children: /*#__PURE__*/ _jsx(CustomQuote, {})
1759
+ }),
1760
+ copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
1761
+ return list == item.id;
1762
+ }) ? /*#__PURE__*/ _jsx("i", {
1763
+ className: "tongyong-xuanzhongdui",
1764
+ children: /*#__PURE__*/ _jsx(CustomDuihao, {})
1765
+ }) : /*#__PURE__*/ _jsx("i", {
1766
+ className: "fuzhi21",
1767
+ onClick: function() {
1768
+ var bol = copyText(item.message);
1769
+ if (bol) {
1770
+ var obj = copyTextOBJ;
1771
+ obj = obj.filter(function(list) {
1772
+ return list != item.id;
1773
+ });
1774
+ obj.push(item.id);
1775
+ setCopyTextObj(obj);
1776
+ }
1777
+ setTimeout(function() {
1778
+ var obj = copyTextOBJ;
1779
+ obj = obj.filter(function(list) {
1780
+ return list != item.id;
1781
+ });
1782
+ setCopyTextObj(obj);
1783
+ }, 3000);
1784
+ onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
1785
+ },
1786
+ children: /*#__PURE__*/ _jsx(CustomCopy, {})
1787
+ }),
1788
+ /*#__PURE__*/ _jsx("span", {
1789
+ children: "|"
1790
+ }),
1791
+ /*#__PURE__*/ _jsx("i", {
1792
+ className: "Frame427319094 ".concat(item.upvoted ? styles.active : ""),
1793
+ onClick: function() {
1794
+ likeMessage(item.id, item.upvoted);
1795
+ console.log("判断是AI还是智能回答", item);
1796
+ //只有最后一条回答,支持发送点赞或踩
1797
+ if (!item.upvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1798
+ console.log("判断是AI还是智能回答", item);
1799
+ if (!item.extraInfo && item.sender == "AI") {
1800
+ aiSendQuestions(1, {
1801
+ roomId: roomId,
1802
+ message: "你给出的答案我非常满意,赞!",
1803
+ quotedMessage: "",
1804
+ regenerate: false,
1805
+ generateUpvoteOrDownvoteMessage: true
1806
+ }, 1);
1807
+ } else {
1808
+ console.log("AI回答2255555");
1809
+ sendGreetingMessage(2);
1810
+ }
1811
+ }
1812
+ },
1813
+ children: /*#__PURE__*/ _jsx(CustomLike, {})
1814
+ }),
1815
+ /*#__PURE__*/ _jsx("i", {
1816
+ className: "Frame427319095 ".concat(item.downvoted ? styles.active : ""),
1817
+ onClick: function() {
1818
+ disagreeMessage(item.id, item.downvoted);
1819
+ //只有最后一条回答,支持发送点赞或踩
1820
+ console.log(item, "dlfkvmdflkv");
1821
+ if (!item.downvoted && (historyMessageList.length == i + 1 || historyMessageList.length - 2 == i)) {
1822
+ if (!item.extraInfo && item.sender == "AI") {
1823
+ console.log("AI回答2222");
1824
+ //AI回答
1825
+ aiSendQuestions(1, {
1826
+ roomId: roomId,
1827
+ message: "你给出的答案很糟糕,我不满意,踩!",
1828
+ quotedMessage: "",
1829
+ regenerate: false,
1830
+ generateUpvoteOrDownvoteMessage: true
1831
+ }, 1);
1832
+ } else {
1833
+ sendGreetingMessage(3);
1834
+ }
1835
+ }
1836
+ },
1837
+ children: /*#__PURE__*/ _jsx(CustomDislike, {})
1838
+ })
1839
+ ]
1840
+ }) : ""
1841
+ ]
1842
+ })
1843
+ }) : "",
1844
+ //召唤老师回答按钮
1845
+ item.findTeacher ? /*#__PURE__*/ _jsx("div", {
1846
+ className: "".concat(styles.operate_modal_bottom),
1847
+ children: /*#__PURE__*/ _jsx("p", {
1848
+ className: styles.stop_findTeacher,
1849
+ children: /*#__PURE__*/ _jsx("span", {
1850
+ onClick: function() {
1851
+ setAnswerMode(-1);
1852
+ setTeacherList([]);
1853
+ setHistoryMessageList(function(historyMessageList) {
1854
+ return historyMessageList.filter(function(item) {
1855
+ return item.id != "-1";
1856
+ });
1857
+ });
1858
+ },
1859
+ children: "停止召唤老师"
1860
+ })
1861
+ })
1862
+ }) : ""
1863
+ ]
1864
+ })
1865
+ })
1866
+ ]
1867
+ }, item.id)
1868
+ ]
1869
+ });
1870
+ }
1871
+ return li;
1872
+ })
1873
+ });
1874
+ } else {
1875
+ return "";
1876
+ }
1877
+ };
1878
+ //渲染底部按钮
1879
+ var renderBottomAnt = function() {
1880
+ var placeholder = "";
1881
+ var disabled = false;
1882
+ if (voiceRecordingStatus == 2) {
1883
+ placeholder = "录制中...";
1884
+ } else if (voiceRecordingStatus == 1) {
1885
+ placeholder = "正在语音识别文字,请稍后...";
1886
+ } else if (!finished) {
1887
+ placeholder = "答案生成中,请稍后再发送...";
1888
+ } else {
1889
+ placeholder = "请输入问题,按Enter发送,Shift+Enter换行";
1890
+ disabled = true;
1891
+ }
1892
+ return /*#__PURE__*/ _jsxs(_Fragment, {
1893
+ children: [
1894
+ /*#__PURE__*/ _jsxs("div", {
1895
+ className: styles.input_wrap,
1896
+ onChange: function() {
1897
+ resettingBottomHei();
1898
+ },
1899
+ children: [
1900
+ /*#__PURE__*/ _jsxs("div", {
1901
+ className: "".concat(styles.input, " ").concat(userData.modules.some(function(item) {
1902
+ return item.short == "AIservice";
1903
+ }) ? "" : styles.no_AI),
1904
+ children: [
1905
+ /*#__PURE__*/ _jsx(TextArea, {
1906
+ placeholder: placeholder,
1907
+ autoSize: {
1908
+ minRows: 1,
1909
+ maxRows: 6
1910
+ },
1911
+ value: keyWord,
1912
+ onChange: function(e) {
1913
+ setKeyWord(e.target.value);
1914
+ if (e.target.value == "") {
1915
+ setQuestionsList([]);
1916
+ clearTimeout(timer.current);
1917
+ } else {
1918
+ clearTimeout(timer.current);
1919
+ timer.current = setTimeout(function() {
1920
+ if (answerMode == 1) {
1921
+ getTeacherList(String(e.target.value));
1922
+ } else {
1923
+ if (roomList.length > 0 && roomList[0].roomId != roomId) return;
1924
+ getQuestiionsList(String(e.target.value), 2);
1925
+ }
1926
+ }, 1000);
1927
+ }
1928
+ },
1929
+ onPressEnter: function(e) {
1930
+ // console.log('发送内容22222',props)
1931
+ console.log(roomList, roomId, "发送内容22222wewewewewewewe");
1932
+ if (!e.shiftKey && !e.altKey && !e.ctrlKey && keyWord.trim() != "") {
1933
+ e.stopPropagation();
1934
+ e.preventDefault();
1935
+ clearTimeout(timer.current);
1936
+ setKeyWord("");
1937
+ setCitationContent({});
1938
+ //跟老师对话
1939
+ if (roomList.length > 0 && roomList[0].roomId != roomId) {
1940
+ sendToTeacher(2);
1941
+ } else {
1942
+ sendMessage();
1943
+ }
1944
+ setButtomHei(45);
1945
+ } else {
1946
+ console.log("回车事件");
1947
+ resettingBottomHei();
1948
+ }
1949
+ },
1950
+ onFocus: function() {
1951
+ onEvent(serverName + serverUrl(), "click_智能问答_输入框", "提交");
1952
+ },
1953
+ disabled: !disabled,
1954
+ maxLength: 1000
1955
+ }),
1956
+ citationContent.content != undefined && citationContent.content != "" ? /*#__PURE__*/ _jsxs("div", {
1957
+ className: styles.content_main,
1958
+ children: [
1959
+ /*#__PURE__*/ _jsx("div", {
1960
+ className: styles.content_con,
1961
+ children: /*#__PURE__*/ _jsx("p", {
1962
+ children: citationContent.content
1963
+ })
1964
+ }),
1965
+ /*#__PURE__*/ _jsx("i", {
1966
+ className: styles.delete_quote,
1967
+ onClick: function() {
1968
+ setCitationContent({});
1969
+ resettingBottomHei();
1970
+ },
1971
+ children: /*#__PURE__*/ _jsx(CustomRoundClose, {})
1972
+ })
1973
+ ]
1974
+ }) : ""
1975
+ ]
1976
+ }),
1977
+ userData.modules.some(function(item) {
1978
+ return item.short == "AIservice";
1979
+ }) ? /*#__PURE__*/ _jsxs("p", {
1980
+ className: styles.voice,
1981
+ children: [
1982
+ voiceRecordingStatus == 1 || voiceRecordingStatus == 3 ? /*#__PURE__*/ _jsx("i", {
1983
+ className: "yuyin-kai12",
1984
+ style: {
1985
+ color: disabled ? "rgba(0, 0, 0, 0.65)" : "rgba(0, 0, 0, 0.25)"
1986
+ },
1987
+ onClick: function() {
1988
+ //开始录音
1989
+ if (!disabled) return;
1990
+ startRecord();
1991
+ setVoiceRecordingStatus(2);
1992
+ setKeyWord("");
1993
+ voiceCountdownTimer.current = setTimeout(function() {
1994
+ stopRecord();
1995
+ setVoiceRecordingStatus(1);
1996
+ }, 120000);
1997
+ onEvent(serverName + serverUrl(), "click_智能问答_ 麦克风", "提交");
1998
+ },
1999
+ children: /*#__PURE__*/ _jsx(CustomSoundRecording, {})
2000
+ }) : "",
2001
+ voiceRecordingStatus == 2 ? /*#__PURE__*/ _jsx("img", {
2002
+ // src={Voice_btn}
2003
+ src: "/new_yun/images/aiService/voice_btn.gif",
2004
+ className: styles.voice_btn,
2005
+ onClick: function() {
2006
+ //结束录音
2007
+ // console.log(mediaRecorder,'3333333');
2008
+ // mediaRecorder.stop();
2009
+ stopRecord();
2010
+ setVoiceRecordingStatus(1);
2011
+ clearTimeout(voiceCountdownTimer.current);
2012
+ }
2013
+ }) : ""
2014
+ ]
2015
+ }) : ""
2016
+ ]
2017
+ }),
2018
+ /*#__PURE__*/ _jsx("p", {
2019
+ className: "".concat(styles.sending),
2020
+ children: /*#__PURE__*/ _jsx("i", {
2021
+ className: "".concat(!disabled ? styles.disabled : ""),
2022
+ onClick: function() {
2023
+ if (!disabled) return;
2024
+ setCitationContent({});
2025
+ setButtomHei(45);
2026
+ if (keyWord.trim() != "") {
2027
+ setKeyWord("");
2028
+ //跟老师对话
2029
+ if (roomList.length > 0 && roomList[0].roomId != roomId) {
2030
+ sendToTeacher(2);
2031
+ } else {
2032
+ sendMessage();
2033
+ }
2034
+ onEvent(serverName + serverUrl(), "click_智能问答_ Enter", "提交");
2035
+ }
2036
+ },
2037
+ children: /*#__PURE__*/ _jsx(CustomSending, {})
2038
+ })
2039
+ })
2040
+ ]
2041
+ });
2042
+ };
2043
+ //渲染联想问题及联想的老师名称
2044
+ var renderAssociationProblem = function() {
2045
+ if (answerMode == 1) {
2046
+ return /*#__PURE__*/ _jsx("div", {
2047
+ className: "".concat(styles.issues_list, " ").concat(styles.issues_list_teacherList),
2048
+ style: {
2049
+ bottom: "".concat(buttomHei + 6, "px")
2050
+ },
2051
+ children: teacherList.map(function(item) {
2052
+ var span = item.name.replaceAll(keyWord, function() {
2053
+ return "<span class=".concat(styles.sign, ">").concat(keyWord, "</span>");
2054
+ });
2055
+ return /*#__PURE__*/ _jsx("p", {
2056
+ className: styles.item,
2057
+ children: /*#__PURE__*/ _jsx("span", {
2058
+ onClick: function() {
2059
+ setTeacherList([]);
2060
+ //提问的问题
2061
+ setProblem({
2062
+ question: problem.question,
2063
+ user: item.uid
2064
+ });
2065
+ setKeyWord("");
2066
+ //setUpdateRecords(true);
2067
+ setAnswerMode(-1);
2068
+ setChatWith(item);
2069
+ createRooms(item.uid).then(function(res) {
2070
+ var id = res.data.id;
2071
+ setRoomId(id); //新的聊天室id
2072
+ });
2073
+ },
2074
+ dangerouslySetInnerHTML: {
2075
+ __html: span
2076
+ }
2077
+ })
2078
+ });
2079
+ })
2080
+ });
2081
+ } else {
2082
+ return /*#__PURE__*/ _jsx("div", {
2083
+ className: styles.issues_list,
2084
+ style: {
2085
+ bottom: "".concat(buttomHei + 6, "px")
2086
+ },
2087
+ children: questionsList.map(function(item) {
2088
+ console.log(item, 44444444);
2089
+ var span = item.question.replaceAll(keyWord, function() {
2090
+ return "<span class=".concat(styles.sign, ">").concat(keyWord, "</span>");
2091
+ });
2092
+ return /*#__PURE__*/ _jsx("p", {
2093
+ className: styles.item,
2094
+ children: /*#__PURE__*/ _jsx("span", {
2095
+ onClick: function() {
2096
+ sendMessage(item, 2);
2097
+ setKeyWord("");
2098
+ onEvent(serverName + serverUrl(), "click_智能问答_ 发送", "提交");
2099
+ },
2100
+ dangerouslySetInnerHTML: {
2101
+ __html: span
2102
+ }
2103
+ })
2104
+ });
2105
+ })
2106
+ });
2107
+ }
2108
+ };
2109
+ //加载指定数据,点击历史记录
2110
+ var loadSpecifiedData = function(renewRoomId, page, id) {
2111
+ setPageNum(page);
2112
+ setLastId(id); //用于定位
2113
+ //如果是当前聊天室
2114
+ if (renewRoomId == roomId) {
2115
+ console.log("当前聊天窗口111111");
2116
+ getHistoryMessage(page, 1);
2117
+ } else {
2118
+ setRoomId(renewRoomId);
2119
+ }
2120
+ };
2121
+ return /*#__PURE__*/ _jsxs(_Fragment, {
2122
+ children: [
2123
+ /*#__PURE__*/ _jsxs(Drawer, {
2124
+ title: "智能回答",
2125
+ width: 560,
2126
+ onClose: function() {
2127
+ onCancel();
2128
+ onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
2129
+ },
2130
+ open: showType == 1 ? true : false,
2131
+ className: styles.ChatWindow_Drawer,
2132
+ mask: false,
2133
+ // maskClosable={false}
2134
+ rootClassName: styles.service_ChatWindow_Drawer,
2135
+ children: [
2136
+ /*#__PURE__*/ _jsx("div", {
2137
+ style: {
2138
+ display: "".concat(showContacts && roomId != "" ? "block" : "none")
2139
+ },
2140
+ children: /*#__PURE__*/ _jsx(ContactsList, {
2141
+ type: 1,
2142
+ roomId: roomId,
2143
+ userData: userData,
2144
+ http: http,
2145
+ urllocation: urllocation,
2146
+ onClose: function() {
2147
+ setShowContacts(false);
2148
+ },
2149
+ // roomIdAi={roomIdAi}
2150
+ switchChatRoom: switchChatRoom,
2151
+ saveContactsList: saveContactsList
2152
+ })
2153
+ }),
2154
+ /*#__PURE__*/ _jsx("div", {
2155
+ className: styles.header_wrap,
2156
+ children: renderHeader()
2157
+ }),
2158
+ /*#__PURE__*/ _jsxs("div", {
2159
+ className: "".concat(styles.Drawer_main),
2160
+ id: "chat_content",
2161
+ style: {
2162
+ maxHeight: "calc(100vh-".concat(buttomHei + 48, "px)")
2163
+ },
2164
+ children: [
2165
+ loading ? /*#__PURE__*/ _jsx("div", {
2166
+ className: styles.loading,
2167
+ children: /*#__PURE__*/ _jsx("img", {
2168
+ src: "/new_yun/images/loading_d.gif",
2169
+ alt: ""
2170
+ })
2171
+ }) : "",
2172
+ renderQuestion()
2173
+ ]
2174
+ }),
2175
+ /*#__PURE__*/ _jsxs("div", {
2176
+ className: styles.Drawer_buttom_Issues_List,
2177
+ children: [
2178
+ renderAssociationProblem(),
2179
+ /*#__PURE__*/ _jsx("div", {
2180
+ className: styles.Drawer_buttom,
2181
+ id: "Drawer_buttom",
2182
+ children: renderBottomAnt()
2183
+ })
2184
+ ]
2185
+ }),
2186
+ showType == 1 && showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
2187
+ type: 1,
2188
+ roomId: roomId,
2189
+ userData: userData,
2190
+ http: http,
2191
+ urllocation: urllocation,
2192
+ onClose: function() {
2193
+ setShowHistory(false);
2194
+ },
2195
+ loadSpecifiedData: loadSpecifiedData,
2196
+ roomList: roomList
2197
+ })
2198
+ ]
2199
+ }),
2200
+ /*#__PURE__*/ _jsxs(Modal, {
2201
+ title: "智能回答",
2202
+ open: showType == 2 ? true : false,
2203
+ onCancel: function() {
2204
+ onCancel();
2205
+ onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
2206
+ },
2207
+ centered: true,
2208
+ width: 1014,
2209
+ height: window.innerHeight - 160,
2210
+ wrapClassName: styles.ChatWindow_Modal,
2211
+ footer: false,
2212
+ maskClosable: false,
2213
+ closeIcon: null,
2214
+ children: [
2215
+ /*#__PURE__*/ _jsx("div", {
2216
+ className: styles.header_wrap,
2217
+ children: renderHeader()
2218
+ }),
2219
+ /*#__PURE__*/ _jsxs("div", {
2220
+ className: "".concat(styles.Drawer_wrap_main),
2221
+ children: [
2222
+ /*#__PURE__*/ _jsxs("div", {
2223
+ className: "".concat(styles.Drawer_main, " ChatWindow_Modal_history_list"),
2224
+ id: "chat_content_modal",
2225
+ style: {
2226
+ maxHeight: "".concat(window.innerHeight - 148 - buttomHei, "px")
2227
+ },
2228
+ children: [
2229
+ /*#__PURE__*/ _jsx(ContactsList, {
2230
+ type: 2,
2231
+ roomId: roomId,
2232
+ userData: userData,
2233
+ http: http,
2234
+ urllocation: urllocation,
2235
+ onClose: function() {
2236
+ setShowContacts(false);
2237
+ },
2238
+ switchChatRoom: switchChatRoom,
2239
+ saveContactsList: saveContactsList
2240
+ }),
2241
+ /*#__PURE__*/ _jsxs("div", {
2242
+ className: styles.chat_content,
2243
+ children: [
2244
+ loading ? /*#__PURE__*/ _jsx("div", {
2245
+ className: styles.loading,
2246
+ children: /*#__PURE__*/ _jsx("img", {
2247
+ src: "/new_yun/images/loading_d.gif",
2248
+ alt: ""
2249
+ })
2250
+ }) : "",
2251
+ renderQuestion()
2252
+ ]
2253
+ })
2254
+ ]
2255
+ }),
2256
+ /*#__PURE__*/ _jsxs("div", {
2257
+ className: styles.Drawer_buttom_Issues_List,
2258
+ children: [
2259
+ renderAssociationProblem(),
2260
+ /*#__PURE__*/ _jsx("div", {
2261
+ className: styles.Drawer_buttom,
2262
+ id: "Drawer_buttom_modal",
2263
+ children: renderBottomAnt()
2264
+ })
2265
+ ]
2266
+ }),
2267
+ showType == 2 && showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
2268
+ type: 2,
2269
+ roomId: roomId,
2270
+ userData: userData,
2271
+ http: http,
2272
+ urllocation: urllocation,
2273
+ onClose: function() {
2274
+ setShowHistory(false);
2275
+ },
2276
+ loadSpecifiedData: loadSpecifiedData,
2277
+ roomList: roomList
2278
+ })
2279
+ ]
2280
+ })
2281
+ ]
2282
+ }),
2283
+ showType == 3 && /*#__PURE__*/ _jsxs("div", {
2284
+ className: "".concat(styles.ChatWindow_Drawer),
2285
+ id: "",
2286
+ children: [
2287
+ /*#__PURE__*/ _jsx("div", {
2288
+ className: "".concat(styles.header_wrap, " ").concat(styles.header_wrap_newlabo),
2289
+ children: /*#__PURE__*/ _jsxs("div", {
2290
+ className: styles.top,
2291
+ children: [
2292
+ /*#__PURE__*/ _jsx("div", {
2293
+ className: styles.user,
2294
+ children: /*#__PURE__*/ _jsx("p", {
2295
+ children: "智能回答"
2296
+ })
2297
+ }),
2298
+ /*#__PURE__*/ _jsxs("div", {
2299
+ className: styles.operate,
2300
+ children: [
2301
+ /*#__PURE__*/ _jsx("i", {
2302
+ onClick: function() {
2303
+ setShowHistory(true);
2304
+ },
2305
+ children: /*#__PURE__*/ _jsx(CustomRecord, {})
2306
+ }),
2307
+ /*#__PURE__*/ _jsx("span", {
2308
+ className: styles.line
2309
+ }),
2310
+ /*#__PURE__*/ _jsx("i", {
2311
+ onClick: function() {
2312
+ onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2313
+ setShowType(4);
2314
+ },
2315
+ children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
2316
+ }),
2317
+ /*#__PURE__*/ _jsx("i", {
2318
+ className: "lianxiren21",
2319
+ onClick: function() {
2320
+ setShowContacts(true);
2321
+ },
2322
+ children: /*#__PURE__*/ _jsx(CustomContacts, {})
2323
+ })
2324
+ ]
2325
+ })
2326
+ ]
2327
+ })
2328
+ }),
2329
+ /*#__PURE__*/ _jsxs("div", {
2330
+ className: "".concat(styles.Drawer_main, " ").concat(styles.Drawer_main_newlabo),
2331
+ id: "chat_content",
2332
+ style: {
2333
+ maxHeight: "calc(100vh-".concat(100, "-").concat(buttomHei, "px)")
2334
+ },
2335
+ children: [
2336
+ loading ? /*#__PURE__*/ _jsx("div", {
2337
+ className: styles.loading,
2338
+ children: /*#__PURE__*/ _jsx("img", {
2339
+ src: "/new_yun/images/loading_d.gif",
2340
+ alt: ""
2341
+ })
2342
+ }) : "",
2343
+ renderQuestion()
2344
+ ]
2345
+ }),
2346
+ /*#__PURE__*/ _jsxs("div", {
2347
+ className: "".concat(styles.Drawer_buttom_Issues_List, " ").concat(styles.Drawer_buttom_Issues_List_newlabo),
2348
+ children: [
2349
+ renderAssociationProblem(),
2350
+ /*#__PURE__*/ _jsx("div", {
2351
+ className: styles.Drawer_buttom,
2352
+ id: "Drawer_buttom",
2353
+ children: renderBottomAnt()
2354
+ })
2355
+ ]
2356
+ }),
2357
+ showType == 3 && showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
2358
+ type: 3,
2359
+ roomId: roomId,
2360
+ userData: userData,
2361
+ http: http,
2362
+ urllocation: urllocation,
2363
+ onClose: function() {
2364
+ setShowHistory(false);
2365
+ },
2366
+ loadSpecifiedData: loadSpecifiedData,
2367
+ roomList: roomList
2368
+ }),
2369
+ /*#__PURE__*/ _jsx("div", {
2370
+ style: {
2371
+ display: "".concat(showType == 3 && showContacts && roomId != "" ? "block" : "none")
2372
+ },
2373
+ children: /*#__PURE__*/ _jsx(ContactsList, {
2374
+ type: 3,
2375
+ roomId: roomId,
2376
+ userData: userData,
2377
+ http: http,
2378
+ urllocation: urllocation,
2379
+ onClose: function() {
2380
+ setShowContacts(false);
2381
+ },
2382
+ switchChatRoom: switchChatRoom,
2383
+ saveContactsList: saveContactsList
2384
+ })
2385
+ })
2386
+ ]
2387
+ }),
2388
+ showType == 4 && /*#__PURE__*/ _jsxs(_Fragment, {
2389
+ children: [
2390
+ /*#__PURE__*/ _jsxs(Modal, {
2391
+ title: "智能回答",
2392
+ open: true,
2393
+ onCancel: function() {
2394
+ onCancel();
2395
+ onEvent(serverName + serverUrl(), "click_智能问答_收起侧边栏", "提交");
2396
+ },
2397
+ centered: true,
2398
+ width: 1014,
2399
+ height: window.innerHeight - 160,
2400
+ wrapClassName: "".concat(styles.ChatWindow_Modal),
2401
+ footer: false,
2402
+ maskClosable: false,
2403
+ closeIcon: null,
2404
+ children: [
2405
+ /*#__PURE__*/ _jsx("div", {
2406
+ className: styles.header_wrap,
2407
+ children: renderHeader()
2408
+ }),
2409
+ /*#__PURE__*/ _jsxs("div", {
2410
+ className: "".concat(styles.Drawer_wrap_main),
2411
+ children: [
2412
+ /*#__PURE__*/ _jsxs("div", {
2413
+ className: "".concat(styles.Drawer_main, " ").concat(styles.Drawer_main_newlabo),
2414
+ id: "chat_content_modal",
2415
+ style: {
2416
+ maxHeight: "".concat(window.innerHeight - 148 - buttomHei, "px")
2417
+ },
2418
+ children: [
2419
+ /*#__PURE__*/ _jsx(ContactsList, {
2420
+ type: 4,
2421
+ roomId: roomId,
2422
+ userData: userData,
2423
+ http: http,
2424
+ urllocation: urllocation,
2425
+ onClose: function() {
2426
+ setShowContacts(false);
2427
+ },
2428
+ switchChatRoom: switchChatRoom,
2429
+ saveContactsList: saveContactsList
2430
+ }),
2431
+ /*#__PURE__*/ _jsxs("div", {
2432
+ className: styles.chat_content,
2433
+ children: [
2434
+ loading ? /*#__PURE__*/ _jsx("div", {
2435
+ className: styles.loading,
2436
+ children: /*#__PURE__*/ _jsx("img", {
2437
+ src: "/new_yun/images/loading_d.gif",
2438
+ alt: ""
2439
+ })
2440
+ }) : "",
2441
+ renderQuestion()
2442
+ ]
2443
+ })
2444
+ ]
2445
+ }),
2446
+ /*#__PURE__*/ _jsxs("div", {
2447
+ className: styles.Drawer_buttom_Issues_List,
2448
+ children: [
2449
+ renderAssociationProblem(),
2450
+ /*#__PURE__*/ _jsx("div", {
2451
+ className: styles.Drawer_buttom,
2452
+ id: "Drawer_buttom_modal",
2453
+ children: renderBottomAnt()
2454
+ })
2455
+ ]
2456
+ }),
2457
+ showHistory && /*#__PURE__*/ _jsx(HistoryFun, {
2458
+ type: 2,
2459
+ roomId: roomId,
2460
+ userData: userData,
2461
+ http: http,
2462
+ urllocation: urllocation,
2463
+ onClose: function() {
2464
+ setShowHistory(false);
2465
+ },
2466
+ loadSpecifiedData: loadSpecifiedData,
2467
+ roomList: roomList
2468
+ })
2469
+ ]
2470
+ })
2471
+ ]
2472
+ }),
2473
+ /*#__PURE__*/ _jsxs("div", {
2474
+ className: "".concat(styles.ChatWindow_Drawer),
2475
+ id: "",
2476
+ children: [
2477
+ /*#__PURE__*/ _jsx("div", {
2478
+ className: "".concat(styles.header_wrap, " ").concat(styles.header_wrap_newlabo),
2479
+ children: /*#__PURE__*/ _jsxs("div", {
2480
+ className: styles.top,
2481
+ children: [
2482
+ /*#__PURE__*/ _jsx("div", {
2483
+ className: styles.user,
2484
+ children: /*#__PURE__*/ _jsx("p", {
2485
+ children: "智能回答"
2486
+ })
2487
+ }),
2488
+ /*#__PURE__*/ _jsxs("div", {
2489
+ className: styles.operate,
2490
+ children: [
2491
+ /*#__PURE__*/ _jsx("i", {
2492
+ onClick: function() {
2493
+ setShowHistory(true);
2494
+ },
2495
+ children: /*#__PURE__*/ _jsx(CustomRecord, {})
2496
+ }),
2497
+ /*#__PURE__*/ _jsx("span", {
2498
+ className: styles.line
2499
+ }),
2500
+ /*#__PURE__*/ _jsx("i", {
2501
+ onClick: function() {
2502
+ onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
2503
+ setShowType(4);
2504
+ },
2505
+ children: /*#__PURE__*/ _jsx(CustomExitFullScreen, {})
2506
+ }),
2507
+ /*#__PURE__*/ _jsx("i", {
2508
+ className: "lianxiren21",
2509
+ onClick: function() {
2510
+ setShowContacts(true);
2511
+ },
2512
+ children: /*#__PURE__*/ _jsx(CustomContacts, {})
2513
+ })
2514
+ ]
2515
+ })
2516
+ ]
2517
+ })
2518
+ }),
2519
+ /*#__PURE__*/ _jsxs("div", {
2520
+ className: "".concat(styles.Drawer_main, " ").concat(styles.Drawer_main_newlabo),
2521
+ id: "chat_content",
2522
+ style: {
2523
+ maxHeight: "calc(100vh-".concat(100, "-").concat(buttomHei, "px)")
2524
+ },
2525
+ children: [
2526
+ loading ? /*#__PURE__*/ _jsx("div", {
2527
+ className: styles.loading,
2528
+ children: /*#__PURE__*/ _jsx("img", {
2529
+ src: "/new_yun/images/loading_d.gif",
2530
+ alt: ""
2531
+ })
2532
+ }) : "",
2533
+ renderQuestion()
2534
+ ]
2535
+ }),
2536
+ /*#__PURE__*/ _jsxs("div", {
2537
+ className: "".concat(styles.Drawer_buttom_Issues_List, " ").concat(styles.Drawer_buttom_Issues_List_newlabo),
2538
+ children: [
2539
+ renderAssociationProblem(),
2540
+ /*#__PURE__*/ _jsx("div", {
2541
+ className: styles.Drawer_buttom,
2542
+ id: "Drawer_buttom",
2543
+ children: renderBottomAnt()
2544
+ })
2545
+ ]
2546
+ }),
2547
+ /*#__PURE__*/ _jsx("div", {
2548
+ style: {
2549
+ display: "".concat(showContacts && roomId != "" ? "block" : "none")
2550
+ },
2551
+ children: /*#__PURE__*/ _jsx(ContactsList, {
2552
+ type: 3,
2553
+ roomId: roomId,
2554
+ userData: userData,
2555
+ http: http,
2556
+ urllocation: urllocation,
2557
+ onClose: function() {
2558
+ setShowContacts(false);
2559
+ },
2560
+ switchChatRoom: switchChatRoom,
2561
+ saveContactsList: saveContactsList
2562
+ })
2563
+ })
2564
+ ]
2565
+ })
2566
+ ]
2567
+ })
2568
+ ]
2569
+ });
2570
+ };
2571
+ window.appendDom = function(root, props) {
2572
+ render(/*#__PURE__*/ _jsx(Provider.Component, {
2573
+ children: /*#__PURE__*/ _jsx(CustomerService, _object_spread({}, props))
2574
+ }), root);
2575
+ };
2576
+ export default CustomerService;