bhd-components 0.6.4 → 0.6.6
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.
- package/README.md +1 -1
- package/dist/{9674e68c.esm.es5.development.js → 869a16fb.esm.es5.development.js} +1402 -1140
- package/dist/{a57a24b2.esm.es5.production.js → c220442c.esm.es5.production.js} +1 -1
- package/dist/index.esm.es5.development.css +888 -753
- package/dist/index.esm.es5.development.js +786 -686
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/bhdSelect/index.d.ts +3 -0
- package/es2017/bhdSelect/index.js +30 -14
- package/es2017/bhdSelect/index.module.less +4 -5
- package/es2017/customerService/contactsList.d.ts +1 -1
- package/es2017/customerService/contactsList.js +11 -145
- package/es2017/customerService/function.js +1 -1
- package/es2017/customerService/historyFun.js +325 -154
- package/es2017/customerService/index.js +412 -341
- package/es2017/customerService/index.module.less +169 -65
- package/es2017/customerService/index2.module.less +170 -65
- package/es2017/icons/components/custom-expand.d.ts +4 -0
- package/es2017/icons/components/custom-expand.js +22 -0
- package/es2017/icons/components/index.d.ts +1 -0
- package/es2017/icons/components/index.js +1 -0
- package/esm/bhdSelect/index.d.ts +3 -0
- package/esm/bhdSelect/index.js +30 -14
- package/esm/bhdSelect/index.module.less +4 -5
- package/esm/customerService/contactsList.d.ts +1 -1
- package/esm/customerService/contactsList.js +11 -158
- package/esm/customerService/function.js +1 -1
- package/esm/customerService/historyFun.js +329 -167
- package/esm/customerService/index.js +397 -348
- package/esm/customerService/index.module.less +169 -65
- package/esm/customerService/index2.module.less +170 -65
- package/esm/icons/components/custom-expand.d.ts +4 -0
- package/esm/icons/components/custom-expand.js +24 -0
- package/esm/icons/components/index.d.ts +1 -0
- package/esm/icons/components/index.js +1 -0
- 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
|
-
|
|
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,13 +84,13 @@ 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')
|
|
@@ -103,7 +104,6 @@ var CustomerService = function(props) {
|
|
|
103
104
|
clearTimeout(listTimer.current);
|
|
104
105
|
setBottomLoading(true);
|
|
105
106
|
listTimer.current = setTimeout(function() {
|
|
106
|
-
// console.log("加载下一页", number);
|
|
107
107
|
getHistoryMessage(number, 4);
|
|
108
108
|
}, 1000);
|
|
109
109
|
} else {
|
|
@@ -167,13 +167,11 @@ var CustomerService = function(props) {
|
|
|
167
167
|
// console.log(props,'lsdkcmsdlcksd')
|
|
168
168
|
getQuestiionsList("", 1);
|
|
169
169
|
scrollToBottom();
|
|
170
|
-
// less.modifyVars({ "@color-border-Tr": "#f4523b" });
|
|
171
170
|
setShowType(initShowType);
|
|
172
171
|
}, [
|
|
173
172
|
initShowType
|
|
174
173
|
]);
|
|
175
174
|
useEffect(function() {
|
|
176
|
-
// console.log(roomId,1111111)
|
|
177
175
|
if (roomId != "") {
|
|
178
176
|
if (lastId == "") {
|
|
179
177
|
getHistoryMessage(pageNum, 2);
|
|
@@ -185,30 +183,28 @@ var CustomerService = function(props) {
|
|
|
185
183
|
}, [
|
|
186
184
|
roomId
|
|
187
185
|
]);
|
|
186
|
+
//创建聊天室并获取聊天室列表
|
|
188
187
|
useEffect(function() {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
]);
|
|
188
|
+
createRooms("AI").then(function(res) {
|
|
189
|
+
setRoomId(res.data.id);
|
|
190
|
+
});
|
|
191
|
+
roomsListTimer();
|
|
192
|
+
return function() {
|
|
193
|
+
clearTimeout(chatRoomList.current);
|
|
194
|
+
};
|
|
195
|
+
}, []);
|
|
208
196
|
//进入页面,发送打招呼信息
|
|
209
197
|
useEffect(function() {
|
|
210
|
-
// console.log(historyMessageList, "dkjvndfkjvd33333f");
|
|
211
198
|
//老师的聊天窗口不发送打招呼信息
|
|
199
|
+
var roomList = contactsList;
|
|
200
|
+
// console.log(roomList,'dkfvdfkjvndfkjvdfv')
|
|
201
|
+
var count = 0;
|
|
202
|
+
roomList.map(function(item) {
|
|
203
|
+
count += item.unreadCount;
|
|
204
|
+
});
|
|
205
|
+
if (count > 0) {
|
|
206
|
+
setShowContacts(true);
|
|
207
|
+
}
|
|
212
208
|
if (!(roomList.length > 0 && roomList[0].roomId != roomId)) {
|
|
213
209
|
//是否发送打招呼信息
|
|
214
210
|
if (greetingMessage && historyMessageList.length == 0) {
|
|
@@ -243,7 +239,7 @@ var CustomerService = function(props) {
|
|
|
243
239
|
}, [
|
|
244
240
|
bese64String
|
|
245
241
|
]);
|
|
246
|
-
//AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
|
|
242
|
+
//AI窗口,type:1发送打招呼信息 2点赞消息 3踩消息 4没有AI客服权限,5,发送超过10万字消息 6, 没有AI客服权限,发送最热的问题
|
|
247
243
|
var sendGreetingMessage = function(type) {
|
|
248
244
|
var questionsList = [];
|
|
249
245
|
var obj = {};
|
|
@@ -348,14 +344,7 @@ var CustomerService = function(props) {
|
|
|
348
344
|
setKeyWord("");
|
|
349
345
|
setQuestionsList([]);
|
|
350
346
|
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) {
|
|
347
|
+
http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
|
|
359
348
|
if (res.data.id) {
|
|
360
349
|
setHistoryMessageList(function(historyMessageList) {
|
|
361
350
|
var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
|
|
@@ -390,7 +379,7 @@ var CustomerService = function(props) {
|
|
|
390
379
|
};
|
|
391
380
|
setProblem({});
|
|
392
381
|
} else if (type == 2) {
|
|
393
|
-
var list =
|
|
382
|
+
var list = contactsList.filter(function(item) {
|
|
394
383
|
return item.roomId == roomId;
|
|
395
384
|
});
|
|
396
385
|
var recevier = "";
|
|
@@ -405,16 +394,9 @@ var CustomerService = function(props) {
|
|
|
405
394
|
quotedMessage: citationContent.content || ""
|
|
406
395
|
};
|
|
407
396
|
}
|
|
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) {
|
|
397
|
+
http.post("".concat(urllocation, "/chat-service/public/v1.0/chat-with-user/messages"), obj).then(function(res) {
|
|
416
398
|
if (res.data.id) {
|
|
417
|
-
console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
|
|
399
|
+
// console.log(pageNum, pageNumHistory, lastId, "dlskskdsd4444");
|
|
418
400
|
if (pageNum == 1 || pageNumHistory == 1 || pageNumHistory == 0) {
|
|
419
401
|
setHistoryMessageList(function(historyMessageList) {
|
|
420
402
|
var newHistoryMessageList = historyMessageList.concat(_object_spread_props(_object_spread({}, obj), {
|
|
@@ -435,8 +417,8 @@ var CustomerService = function(props) {
|
|
|
435
417
|
if (type == 1) {
|
|
436
418
|
var roomList = [
|
|
437
419
|
{
|
|
438
|
-
|
|
439
|
-
|
|
420
|
+
roomId: roomId,
|
|
421
|
+
id: res.data.id
|
|
440
422
|
}
|
|
441
423
|
];
|
|
442
424
|
setChatObj(function(list) {
|
|
@@ -530,14 +512,7 @@ var CustomerService = function(props) {
|
|
|
530
512
|
return newHistoryMessageList;
|
|
531
513
|
});
|
|
532
514
|
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) {
|
|
515
|
+
http.post("".concat(urllocation, "/chat-service/public/v1.0/history-messages"), obj).then(function(res) {
|
|
541
516
|
if (res.data.id) {
|
|
542
517
|
//更新聊天记录id
|
|
543
518
|
setHistoryMessageList(function(historyMessageList) {
|
|
@@ -570,31 +545,15 @@ var CustomerService = function(props) {
|
|
|
570
545
|
sendingExistingIssues(2, dataObj, "");
|
|
571
546
|
testLabQuestion(obj.message, questions.answer, "");
|
|
572
547
|
}
|
|
573
|
-
}).then(function(res) {
|
|
574
|
-
console.log(res);
|
|
575
548
|
});
|
|
576
549
|
};
|
|
577
550
|
//向AI发送问题 type == 1 发送点赞或踩消息,type == 2 发送重新生成消息,type == 3 正常发送消息
|
|
578
551
|
var content = ""; //用于实验报告的问题记录
|
|
579
552
|
var aiSendQuestions = function(type, obj, id) {
|
|
580
553
|
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
554
|
ctrl.current = new AbortController();
|
|
595
555
|
clearTimeout(receiveMessageTimer.current);
|
|
596
556
|
receiveMessageTimer.current = setTimeout(function() {
|
|
597
|
-
// console.log('超时终止1111')
|
|
598
557
|
setHistoryMessageList(function(historyMessageList) {
|
|
599
558
|
return historyMessageList.filter(function(item) {
|
|
600
559
|
return item.id != "123456" && item.id != "654321";
|
|
@@ -674,7 +633,7 @@ var CustomerService = function(props) {
|
|
|
674
633
|
"X-Auth-Jwt": window.localStorage.getItem("usertoken") || "",
|
|
675
634
|
"Auth-Token": userData.token,
|
|
676
635
|
"X-Module-Id": userData.modules.find(function(ele) {
|
|
677
|
-
return ele.short == "
|
|
636
|
+
return ele.short == "IntelligentCustomerService";
|
|
678
637
|
}).id
|
|
679
638
|
},
|
|
680
639
|
body: data,
|
|
@@ -837,9 +796,9 @@ var CustomerService = function(props) {
|
|
|
837
796
|
return newHistoryMessageList2;
|
|
838
797
|
}
|
|
839
798
|
});
|
|
840
|
-
setTimeout(
|
|
841
|
-
|
|
842
|
-
|
|
799
|
+
// setTimeout(() => {
|
|
800
|
+
scrollToBottom();
|
|
801
|
+
// }, 10);
|
|
843
802
|
};
|
|
844
803
|
//问题记录到实验报告中
|
|
845
804
|
var testLabQuestion = function(title, content, teachId) {
|
|
@@ -851,13 +810,6 @@ var CustomerService = function(props) {
|
|
|
851
810
|
teachId: teachId != undefined ? teachId : chatWith.uid | mid,
|
|
852
811
|
stepId: stepId,
|
|
853
812
|
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
813
|
}).then(function() {
|
|
862
814
|
console.log(roomId, chatObj, "roomIdroomIdroomIdroomId");
|
|
863
815
|
setChatObj(function(list1) {
|
|
@@ -873,13 +825,6 @@ var CustomerService = function(props) {
|
|
|
873
825
|
var speechToText = function() {
|
|
874
826
|
http.post("".concat(urllocation, "/chat-service/public/v1.0/speech:recognize"), {
|
|
875
827
|
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
828
|
}).then(function(res) {
|
|
884
829
|
setVoiceRecordingStatus(3);
|
|
885
830
|
if (res.data) {
|
|
@@ -895,20 +840,13 @@ var CustomerService = function(props) {
|
|
|
895
840
|
var createRooms = function(uid) {
|
|
896
841
|
return http.post("".concat(urllocation, "/chat-service/public/v1.0/rooms"), {
|
|
897
842
|
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
843
|
});
|
|
906
844
|
};
|
|
907
845
|
//获取历史消息 flag:1,历史记录点击定位,2,代表是上拉加载,3,存在新的消息-->老师回答等,4,下拉加载,滚动到底部时,主要用于查看历史记录
|
|
908
846
|
var getHistoryMessage = function(pageNum, flag) {
|
|
909
847
|
var id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "1";
|
|
910
848
|
clearTimeout(roomMessage.current);
|
|
911
|
-
console.log(pageNum,
|
|
849
|
+
// console.log(pageNum,flag,'dkfjvndfjvndfkvdf')
|
|
912
850
|
// flag == 1 时已经设置好了位置标记
|
|
913
851
|
var last_id = "";
|
|
914
852
|
if (flag == 2 && historyMessageList.length > 0) {
|
|
@@ -929,20 +867,10 @@ var CustomerService = function(props) {
|
|
|
929
867
|
page: pageNum ? pageNum : 1,
|
|
930
868
|
maxPageSize: 30,
|
|
931
869
|
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
870
|
}
|
|
939
871
|
}).then(function(res) {
|
|
940
872
|
var totalNumber = 0;
|
|
941
|
-
var roomList =
|
|
942
|
-
setRoomList(function(list) {
|
|
943
|
-
roomList = list;
|
|
944
|
-
return list;
|
|
945
|
-
});
|
|
873
|
+
var roomList = contactsList;
|
|
946
874
|
if (res.data.messages.length > 0) {
|
|
947
875
|
clearTimeout(listTimer.current);
|
|
948
876
|
var total = res.data.total;
|
|
@@ -1015,6 +943,7 @@ var CustomerService = function(props) {
|
|
|
1015
943
|
});
|
|
1016
944
|
var isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
|
|
1017
945
|
if (!isAiChatWindow && roomList.length > 0 && (pageNum == 1 || pageNumHistory == 0)) {
|
|
946
|
+
//&& pageNum == 1
|
|
1018
947
|
getRoomidHistoryMessage(totalNumber, rid);
|
|
1019
948
|
}
|
|
1020
949
|
}).catch(function(res) {
|
|
@@ -1033,14 +962,8 @@ var CustomerService = function(props) {
|
|
|
1033
962
|
params: {
|
|
1034
963
|
roomId: rid,
|
|
1035
964
|
page: 1,
|
|
1036
|
-
maxPageSize: totalNumber,
|
|
965
|
+
maxPageSize: totalNumber == 0 ? 30 : totalNumber,
|
|
1037
966
|
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
967
|
}
|
|
1045
968
|
}).then(function(res) {
|
|
1046
969
|
var newHistoryMessageList = [];
|
|
@@ -1059,7 +982,7 @@ var CustomerService = function(props) {
|
|
|
1059
982
|
newList = newHistoryMessageList.length;
|
|
1060
983
|
return newHistoryMessageList;
|
|
1061
984
|
});
|
|
1062
|
-
console.log(dataList.length, originList,
|
|
985
|
+
// console.log(dataList.length , originList,lastId,'dfkvdnfkvdfj44444');
|
|
1063
986
|
if (!lastId && originList != newList) {
|
|
1064
987
|
setTimeout(function() {
|
|
1065
988
|
scrollToBottom();
|
|
@@ -1107,8 +1030,7 @@ var CustomerService = function(props) {
|
|
|
1107
1030
|
console.log(newMessage, "newMessagenewMessage");
|
|
1108
1031
|
var result = [];
|
|
1109
1032
|
newMessage.forEach(function(item, index) {
|
|
1110
|
-
var isQuestion = item.receiver !== mid //是否为问题
|
|
1111
|
-
;
|
|
1033
|
+
var isQuestion = item.receiver !== mid; //是否为问题
|
|
1112
1034
|
if (isQuestion) {
|
|
1113
1035
|
//问题
|
|
1114
1036
|
if (newMessage[index + 1] && newMessage[index + 1].receiver === mid) {
|
|
@@ -1140,13 +1062,6 @@ var CustomerService = function(props) {
|
|
|
1140
1062
|
}
|
|
1141
1063
|
http.post(url, {
|
|
1142
1064
|
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
1065
|
}).then(function(res) {
|
|
1151
1066
|
setHistoryMessageList(function(historyMessageList) {
|
|
1152
1067
|
var list = historyMessageList;
|
|
@@ -1171,13 +1086,6 @@ var CustomerService = function(props) {
|
|
|
1171
1086
|
}
|
|
1172
1087
|
http.post(url, {
|
|
1173
1088
|
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
1089
|
}).then(function(res) {
|
|
1182
1090
|
setHistoryMessageList(function(historyMessageList) {
|
|
1183
1091
|
var list = historyMessageList;
|
|
@@ -1207,13 +1115,7 @@ var CustomerService = function(props) {
|
|
|
1207
1115
|
};
|
|
1208
1116
|
}
|
|
1209
1117
|
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
|
-
}
|
|
1118
|
+
params: data
|
|
1217
1119
|
}).then(function(res) {
|
|
1218
1120
|
if (res.data.questions) {
|
|
1219
1121
|
if (flag == 1) {
|
|
@@ -1229,12 +1131,6 @@ var CustomerService = function(props) {
|
|
|
1229
1131
|
http.get("".concat(urllocation, "/chat-service/public/v1.0/teachers"), {
|
|
1230
1132
|
params: {
|
|
1231
1133
|
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
1134
|
}
|
|
1239
1135
|
}).then(function(res) {
|
|
1240
1136
|
console.log(res);
|
|
@@ -1243,6 +1139,90 @@ var CustomerService = function(props) {
|
|
|
1243
1139
|
}
|
|
1244
1140
|
});
|
|
1245
1141
|
};
|
|
1142
|
+
//获取聊天室列表
|
|
1143
|
+
var roomsListTimer = function() {
|
|
1144
|
+
if (chatRoomList != null) clearTimeout(chatRoomList.current);
|
|
1145
|
+
chatRoomList.current = setTimeout(function() {
|
|
1146
|
+
return roomsListTimer();
|
|
1147
|
+
}, 60000);
|
|
1148
|
+
http.get("".concat(urllocation, "/chat-service/public/v1.0/rooms"), {
|
|
1149
|
+
params: {
|
|
1150
|
+
page: 1,
|
|
1151
|
+
maxPageSize: 100002
|
|
1152
|
+
}
|
|
1153
|
+
}).then(function(res) {
|
|
1154
|
+
if (res.data) {
|
|
1155
|
+
var list = res.data.contacts;
|
|
1156
|
+
setContactsList(function(list1) {
|
|
1157
|
+
list = list.map(function(item, index) {
|
|
1158
|
+
var c_list = list1.filter(function(e) {
|
|
1159
|
+
return e.sender == item.sender;
|
|
1160
|
+
});
|
|
1161
|
+
var obj = {};
|
|
1162
|
+
if (c_list.length > 0) {
|
|
1163
|
+
obj = c_list[0];
|
|
1164
|
+
}
|
|
1165
|
+
return _object_spread({}, obj, item);
|
|
1166
|
+
});
|
|
1167
|
+
return list;
|
|
1168
|
+
});
|
|
1169
|
+
getUserInfo(list);
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
};
|
|
1173
|
+
//获取老师的信息等
|
|
1174
|
+
var getUserInfo = function(list) {
|
|
1175
|
+
var getUserid = [];
|
|
1176
|
+
//查找需要用户名和头像的
|
|
1177
|
+
list.map(function(item, i) {
|
|
1178
|
+
if (!item.name && !item.headImg && item.sender != "AI") {
|
|
1179
|
+
getUserid.push(item.sender);
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
if (getUserid.length > 0) {
|
|
1183
|
+
getUserName(getUserid.join(",")).then(function(res) {
|
|
1184
|
+
if (res.data) {
|
|
1185
|
+
var nameList = res.data;
|
|
1186
|
+
// console.log(nameList,contactsList,'kdsjnvjdkvdfj')
|
|
1187
|
+
setContactsList(function(contactsList) {
|
|
1188
|
+
list = list.map(function(item, index) {
|
|
1189
|
+
var name = nameList.filter(function(v) {
|
|
1190
|
+
return v.uid == item.sender;
|
|
1191
|
+
});
|
|
1192
|
+
if (name.length > 0) {
|
|
1193
|
+
return _object_spread({}, item, name[0]);
|
|
1194
|
+
} else {
|
|
1195
|
+
return item;
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
return list;
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
} else {
|
|
1203
|
+
setContactsList(function(contactsList) {
|
|
1204
|
+
list = list.map(function(item, index) {
|
|
1205
|
+
var c_list = contactsList.filter(function(e) {
|
|
1206
|
+
return e.sender == item.sender;
|
|
1207
|
+
});
|
|
1208
|
+
var obj = {};
|
|
1209
|
+
if (c_list.length > 0) {
|
|
1210
|
+
obj = c_list[0];
|
|
1211
|
+
}
|
|
1212
|
+
return _object_spread({}, obj, item);
|
|
1213
|
+
});
|
|
1214
|
+
return list;
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
//获取老师用户名
|
|
1219
|
+
var getUserName = function(uid) {
|
|
1220
|
+
return http.get("".concat(urllocation, "/chat-service/public/v1.0/userinfo"), {
|
|
1221
|
+
params: {
|
|
1222
|
+
uid: uid
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
};
|
|
1246
1226
|
//设置滚动条滚动到底部
|
|
1247
1227
|
var scrollToBottom = function() {
|
|
1248
1228
|
var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
|
|
@@ -1257,11 +1237,18 @@ var CustomerService = function(props) {
|
|
|
1257
1237
|
container.scrollTop = 60;
|
|
1258
1238
|
try {
|
|
1259
1239
|
setTimeout(function() {
|
|
1260
|
-
|
|
1240
|
+
// let top2 =
|
|
1241
|
+
// showType == 1 || showType == 3
|
|
1242
|
+
// ? $("#li_flag").offset().top - 20
|
|
1243
|
+
// : $("#chat_content_modal #li_flag").offset().top -
|
|
1244
|
+
// $("#chat_content_modal").offset().top +
|
|
1245
|
+
// 24;
|
|
1246
|
+
var top = showType == 1 || showType == 3 ? $("#li_flag").offset().top : $("#chat_content_modal #li_flag").offset().top - $("#chat_content_modal").offset().top;
|
|
1247
|
+
// console.log(top2,top,444444444444)
|
|
1261
1248
|
$("#".concat(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal")).animate({
|
|
1262
1249
|
scrollTop: top
|
|
1263
1250
|
}, 0);
|
|
1264
|
-
},
|
|
1251
|
+
}, 100);
|
|
1265
1252
|
} catch (error) {}
|
|
1266
1253
|
setLoading(false);
|
|
1267
1254
|
}
|
|
@@ -1281,19 +1268,34 @@ var CustomerService = function(props) {
|
|
|
1281
1268
|
});
|
|
1282
1269
|
});
|
|
1283
1270
|
};
|
|
1284
|
-
|
|
1285
|
-
var
|
|
1286
|
-
var
|
|
1271
|
+
//显示未读消息
|
|
1272
|
+
var showUnreadMessage = function() {
|
|
1273
|
+
var count = 0;
|
|
1274
|
+
contactsList.map(function(item) {
|
|
1275
|
+
count = count + item.unreadCount;
|
|
1276
|
+
});
|
|
1277
|
+
if (count > 0) {
|
|
1278
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
1279
|
+
className: styles.count,
|
|
1280
|
+
children: count > 99 ? "99+" : count
|
|
1281
|
+
});
|
|
1282
|
+
} else {
|
|
1283
|
+
return "";
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
//显示聊天室名字
|
|
1287
|
+
var showChatRoomName = function() {
|
|
1288
|
+
var title = "AI助手";
|
|
1289
|
+
var list = contactsList.filter(function(e) {
|
|
1287
1290
|
return e.roomId == roomId;
|
|
1288
1291
|
});
|
|
1289
|
-
var title = "智能问答";
|
|
1290
1292
|
if (list.length > 0 && list[0].name) {
|
|
1291
1293
|
title = list[0].name;
|
|
1292
1294
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1295
|
+
return title;
|
|
1296
|
+
};
|
|
1297
|
+
//渲染头部
|
|
1298
|
+
var renderHeader = function() {
|
|
1297
1299
|
if (showType == 4) {
|
|
1298
1300
|
return /*#__PURE__*/ _jsxs("div", {
|
|
1299
1301
|
className: styles.top,
|
|
@@ -1301,7 +1303,7 @@ var CustomerService = function(props) {
|
|
|
1301
1303
|
/*#__PURE__*/ _jsx("div", {
|
|
1302
1304
|
className: styles.user,
|
|
1303
1305
|
children: /*#__PURE__*/ _jsx("p", {
|
|
1304
|
-
children:
|
|
1306
|
+
children: showChatRoomName()
|
|
1305
1307
|
})
|
|
1306
1308
|
}),
|
|
1307
1309
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -1352,13 +1354,10 @@ var CustomerService = function(props) {
|
|
|
1352
1354
|
},
|
|
1353
1355
|
children: [
|
|
1354
1356
|
/*#__PURE__*/ _jsx(CustomContacts, {}),
|
|
1355
|
-
|
|
1356
|
-
className: styles.count,
|
|
1357
|
-
children: count > 99 ? "99+" : count
|
|
1358
|
-
}) : ""
|
|
1357
|
+
showUnreadMessage()
|
|
1359
1358
|
]
|
|
1360
1359
|
}),
|
|
1361
|
-
|
|
1360
|
+
showChatRoomName()
|
|
1362
1361
|
]
|
|
1363
1362
|
})
|
|
1364
1363
|
}),
|
|
@@ -1381,7 +1380,13 @@ var CustomerService = function(props) {
|
|
|
1381
1380
|
onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
|
|
1382
1381
|
// switchDialogBox(3, true);
|
|
1383
1382
|
setShowType(2);
|
|
1384
|
-
|
|
1383
|
+
setTimeout(function() {
|
|
1384
|
+
setKeyWord(" ");
|
|
1385
|
+
}, 100);
|
|
1386
|
+
setTimeout(function() {
|
|
1387
|
+
setKeyWord("");
|
|
1388
|
+
}, 300);
|
|
1389
|
+
// childRef.current.roomsListTimer();
|
|
1385
1390
|
},
|
|
1386
1391
|
children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
|
|
1387
1392
|
}) : /*#__PURE__*/ _jsx("i", {
|
|
@@ -1406,7 +1411,7 @@ var CustomerService = function(props) {
|
|
|
1406
1411
|
var resettingBottomHei = function() {
|
|
1407
1412
|
setTimeout(function() {
|
|
1408
1413
|
if (showType == 1 || showType == 3) {
|
|
1409
|
-
if (document.getElementById("
|
|
1414
|
+
if (document.getElementById("Drawer_buttom")) {
|
|
1410
1415
|
var hei = document.getElementById("Drawer_buttom").offsetHeight;
|
|
1411
1416
|
setButtomHei(hei);
|
|
1412
1417
|
}
|
|
@@ -1420,28 +1425,50 @@ var CustomerService = function(props) {
|
|
|
1420
1425
|
};
|
|
1421
1426
|
//切换聊天室 type == renew ,存在新消息
|
|
1422
1427
|
var switchChatRoom = function(id, type) {
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1428
|
+
if (type != "1") {
|
|
1429
|
+
readMessage(id, urllocation, userData, http);
|
|
1430
|
+
setLastId("");
|
|
1431
|
+
setPageNum(1);
|
|
1432
|
+
setPageCount(0);
|
|
1433
|
+
setRoomId(id);
|
|
1434
|
+
try {
|
|
1435
|
+
if (ctrl && ctrl.current) {
|
|
1436
|
+
ctrl.current.abort();
|
|
1437
|
+
}
|
|
1438
|
+
setFinished(true);
|
|
1439
|
+
} catch (error) {}
|
|
1440
|
+
setTimeout(function() {
|
|
1441
|
+
roomsListTimer();
|
|
1442
|
+
}, 500);
|
|
1443
|
+
}
|
|
1444
|
+
//删除聊天室
|
|
1445
|
+
if (type == "1") {
|
|
1446
|
+
if (id == roomId) {
|
|
1447
|
+
// console.log(contactsList,888888);
|
|
1448
|
+
switchChatRoom(contactsList[0].roomId, "");
|
|
1449
|
+
}
|
|
1450
|
+
setContactsList(function(list) {
|
|
1451
|
+
var newList = list;
|
|
1452
|
+
newList = newList.filter(function(v) {
|
|
1453
|
+
return v.roomId != id;
|
|
1454
|
+
});
|
|
1455
|
+
return newList;
|
|
1456
|
+
});
|
|
1438
1457
|
}
|
|
1458
|
+
// if (type == "renew") {
|
|
1459
|
+
// getHistoryMessage(1, 3,id);
|
|
1460
|
+
// }else{
|
|
1461
|
+
// setRoomId(id);
|
|
1462
|
+
// }
|
|
1439
1463
|
};
|
|
1464
|
+
// const saveContactsList = (list: any)=>{
|
|
1465
|
+
// console.log(list,44444444)
|
|
1466
|
+
// // if(list != undefined){
|
|
1467
|
+
// // setRoomList(list);
|
|
1468
|
+
// // }
|
|
1469
|
+
// }
|
|
1440
1470
|
//渲染问答
|
|
1441
1471
|
var renderQuestion = function() {
|
|
1442
|
-
// 2023-12-01T14:34:07
|
|
1443
|
-
// console.log(lastId,'lastIdlastIdlastId')
|
|
1444
|
-
// console.log(mid, historyMessageList, "ddkfdscksdcs");
|
|
1445
1472
|
if (historyMessageList.length > 0) {
|
|
1446
1473
|
return /*#__PURE__*/ _jsx("ul", {
|
|
1447
1474
|
className: styles.message_con,
|
|
@@ -1492,62 +1519,67 @@ var CustomerService = function(props) {
|
|
|
1492
1519
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
1493
1520
|
className: styles.main_content,
|
|
1494
1521
|
children: [
|
|
1495
|
-
/*#__PURE__*/
|
|
1496
|
-
className: styles.
|
|
1497
|
-
children:
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
/*#__PURE__*/
|
|
1501
|
-
className:
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1522
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1523
|
+
className: styles.main_content_flag,
|
|
1524
|
+
children: [
|
|
1525
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1526
|
+
className: styles.operate_modal,
|
|
1527
|
+
children: /*#__PURE__*/ _jsxs("p", {
|
|
1528
|
+
className: styles.operate,
|
|
1529
|
+
children: [
|
|
1530
|
+
/*#__PURE__*/ _jsx("i", {
|
|
1531
|
+
className: "yinyong_quote1",
|
|
1532
|
+
onClick: function() {
|
|
1533
|
+
setCitationContent({
|
|
1534
|
+
content: item.message,
|
|
1535
|
+
id: item.id
|
|
1536
|
+
});
|
|
1537
|
+
resettingBottomHei();
|
|
1538
|
+
onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
|
|
1539
|
+
},
|
|
1540
|
+
children: /*#__PURE__*/ _jsx(CustomQuote, {})
|
|
1541
|
+
}),
|
|
1542
|
+
copyTextOBJ.length > 0 && copyTextOBJ.some(function(list) {
|
|
1543
|
+
return list == item.id;
|
|
1544
|
+
}) ? /*#__PURE__*/ _jsx("i", {
|
|
1545
|
+
className: "tongyong-xuanzhongdui",
|
|
1546
|
+
children: /*#__PURE__*/ _jsx(CustomDuihao, {})
|
|
1547
|
+
}) : /*#__PURE__*/ _jsx("i", {
|
|
1548
|
+
className: "fuzhi21",
|
|
1549
|
+
onClick: function() {
|
|
1550
|
+
var bol = copyText(item.message);
|
|
1551
|
+
if (bol) {
|
|
1552
|
+
var obj = copyTextOBJ;
|
|
1553
|
+
obj = obj.filter(function(list) {
|
|
1554
|
+
return list != item.id;
|
|
1555
|
+
});
|
|
1556
|
+
obj.push(item.id);
|
|
1557
|
+
setCopyTextObj(obj);
|
|
1558
|
+
}
|
|
1559
|
+
setTimeout(function() {
|
|
1560
|
+
var obj = copyTextOBJ;
|
|
1561
|
+
obj = obj.filter(function(list) {
|
|
1562
|
+
return list != item.id;
|
|
1563
|
+
});
|
|
1564
|
+
setCopyTextObj(obj);
|
|
1565
|
+
}, 3000);
|
|
1566
|
+
onEvent(serverName + serverUrl(), "click_智能问答_复制", "提交");
|
|
1567
|
+
},
|
|
1568
|
+
children: /*#__PURE__*/ _jsx(CustomCopy, {})
|
|
1569
|
+
})
|
|
1570
|
+
]
|
|
1571
|
+
})
|
|
1572
|
+
}),
|
|
1573
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1574
|
+
className: styles.content,
|
|
1575
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
1576
|
+
dangerouslySetInnerHTML: {
|
|
1577
|
+
__html: remarkable.render(message)
|
|
1537
1578
|
},
|
|
1538
|
-
|
|
1579
|
+
className: styles.content_child
|
|
1539
1580
|
})
|
|
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
|
-
})
|
|
1581
|
+
})
|
|
1582
|
+
]
|
|
1551
1583
|
}),
|
|
1552
1584
|
//引用消息
|
|
1553
1585
|
item.quotedMessage && /*#__PURE__*/ _jsx("div", {
|
|
@@ -1586,14 +1618,17 @@ var CustomerService = function(props) {
|
|
|
1586
1618
|
} else {
|
|
1587
1619
|
//获取用户头像
|
|
1588
1620
|
var headImg = "";
|
|
1589
|
-
var chatWindow =
|
|
1621
|
+
var chatWindow = [];
|
|
1622
|
+
var isAiChatWindow;
|
|
1623
|
+
chatWindow = contactsList.filter(function(item) {
|
|
1590
1624
|
return item.roomId == roomId;
|
|
1591
1625
|
});
|
|
1592
1626
|
if (chatWindow.length > 0 && chatWindow[0].headImg != "") {
|
|
1593
1627
|
headImg = chatWindow[0].headImg;
|
|
1594
1628
|
}
|
|
1629
|
+
// console.log(chatWindow,'chatWindowchatWindow')
|
|
1595
1630
|
//是否在智能客服窗口
|
|
1596
|
-
|
|
1631
|
+
isAiChatWindow = chatWindow.length > 0 && chatWindow[0].sender != undefined && chatWindow[0].sender == "AI" ? true : false;
|
|
1597
1632
|
var header = 2; //代表是ai头像
|
|
1598
1633
|
if (isAiChatWindow && item.extraInfo != undefined && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "isVoteMessage") {
|
|
1599
1634
|
//使用AI头像
|
|
@@ -1625,34 +1660,39 @@ var CustomerService = function(props) {
|
|
|
1625
1660
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
1626
1661
|
className: styles.main_content,
|
|
1627
1662
|
children: [
|
|
1628
|
-
/*#__PURE__*/ _jsx("div", {
|
|
1629
|
-
className: styles.operate_modal,
|
|
1630
|
-
children: // 不是最后一行,
|
|
1631
|
-
historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
|
|
1632
|
-
}),
|
|
1633
1663
|
/*#__PURE__*/ _jsxs("div", {
|
|
1634
|
-
className: styles.
|
|
1664
|
+
className: styles.main_content_flag,
|
|
1635
1665
|
children: [
|
|
1636
|
-
/*#__PURE__*/ _jsx("
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
className: styles.content_child
|
|
1666
|
+
/*#__PURE__*/ _jsx("div", {
|
|
1667
|
+
className: styles.operate_modal,
|
|
1668
|
+
children: // 不是最后一行,
|
|
1669
|
+
historyMessageList.length - 1 != i && renderOperateBtn(item, isAiChatWindow, i)
|
|
1641
1670
|
}),
|
|
1642
|
-
|
|
1643
|
-
className: styles.
|
|
1644
|
-
children:
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1671
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1672
|
+
className: styles.content,
|
|
1673
|
+
children: [
|
|
1674
|
+
/*#__PURE__*/ _jsx("p", {
|
|
1675
|
+
dangerouslySetInnerHTML: {
|
|
1676
|
+
__html: remarkable.render(message)
|
|
1648
1677
|
},
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1678
|
+
className: styles.content_child
|
|
1679
|
+
}),
|
|
1680
|
+
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", {
|
|
1681
|
+
className: styles.association_problem,
|
|
1682
|
+
children: JSON.parse(item.extraInfo).map(function(list, index) {
|
|
1683
|
+
return /*#__PURE__*/ _jsxs("li", {
|
|
1684
|
+
onClick: function() {
|
|
1685
|
+
sendMessage(list, 1);
|
|
1686
|
+
},
|
|
1687
|
+
children: [
|
|
1688
|
+
index + 1,
|
|
1689
|
+
".",
|
|
1690
|
+
list.question
|
|
1691
|
+
]
|
|
1692
|
+
}, i + "_" + index + "_" + list.value);
|
|
1693
|
+
})
|
|
1694
|
+
})
|
|
1695
|
+
]
|
|
1656
1696
|
})
|
|
1657
1697
|
]
|
|
1658
1698
|
}),
|
|
@@ -1680,7 +1720,7 @@ var CustomerService = function(props) {
|
|
|
1680
1720
|
isAiChatWindow && item.findTeacher && userData.modules.some(function(item) {
|
|
1681
1721
|
return item.short == "TeacherAnswer";
|
|
1682
1722
|
}) ? /*#__PURE__*/ _jsx("div", {
|
|
1683
|
-
className: "".concat(styles.operate_modal_bottom),
|
|
1723
|
+
className: "".concat(styles.operate_modal_bottom, " "),
|
|
1684
1724
|
children: /*#__PURE__*/ _jsx("p", {
|
|
1685
1725
|
className: styles.stop_findTeacher,
|
|
1686
1726
|
children: /*#__PURE__*/ _jsx("span", {
|
|
@@ -1855,7 +1895,8 @@ var CustomerService = function(props) {
|
|
|
1855
1895
|
};
|
|
1856
1896
|
//渲染最后一条的操作按钮
|
|
1857
1897
|
var renderLastOperateBtn = function(item, isAiChatWindow, i) {
|
|
1858
|
-
{
|
|
1898
|
+
{
|
|
1899
|
+
/* 停止生成按钮 最后一次生成答案的支持点击 */ }
|
|
1859
1900
|
//问候语及点赞下面不需要展示相关按钮
|
|
1860
1901
|
var extraInfo = item.extraInfo;
|
|
1861
1902
|
//JSON.parse(extraInfo)[0].key == 'questionId' 是联想问题
|
|
@@ -1879,6 +1920,9 @@ var CustomerService = function(props) {
|
|
|
1879
1920
|
}
|
|
1880
1921
|
return /*#__PURE__*/ _jsxs("div", {
|
|
1881
1922
|
className: "".concat(styles.operate_modal_bottom),
|
|
1923
|
+
style: {
|
|
1924
|
+
position: showStopBtn ? "sticky" : "relative"
|
|
1925
|
+
},
|
|
1882
1926
|
children: [
|
|
1883
1927
|
/*#__PURE__*/ _jsxs("p", {
|
|
1884
1928
|
className: styles.stop_generate,
|
|
@@ -1935,8 +1979,6 @@ var CustomerService = function(props) {
|
|
|
1935
1979
|
question: historyMessageList[i - 1].message,
|
|
1936
1980
|
user: problem.user
|
|
1937
1981
|
});
|
|
1938
|
-
console.log(item, "88888999999");
|
|
1939
|
-
// if(item.extraInfo == null){
|
|
1940
1982
|
setHistoryMessageList(function(historyMessageList) {
|
|
1941
1983
|
var newHistoryMessageList = historyMessageList.concat({
|
|
1942
1984
|
id: -1,
|
|
@@ -1955,30 +1997,6 @@ var CustomerService = function(props) {
|
|
|
1955
1997
|
});
|
|
1956
1998
|
return newHistoryMessageList;
|
|
1957
1999
|
});
|
|
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
2000
|
setTimeout(function() {
|
|
1983
2001
|
scrollToBottom();
|
|
1984
2002
|
}, 200);
|
|
@@ -2149,6 +2167,7 @@ var CustomerService = function(props) {
|
|
|
2149
2167
|
if (answerMode == 1) {
|
|
2150
2168
|
getTeacherList(String(e.target.value));
|
|
2151
2169
|
} else {
|
|
2170
|
+
var roomList = contactsList;
|
|
2152
2171
|
if (roomList.length > 0 && roomList[0].roomId != roomId) return;
|
|
2153
2172
|
getQuestiionsList(String(e.target.value), 2);
|
|
2154
2173
|
}
|
|
@@ -2164,10 +2183,26 @@ var CustomerService = function(props) {
|
|
|
2164
2183
|
clearTimeout(timer.current);
|
|
2165
2184
|
setKeyWord("");
|
|
2166
2185
|
setCitationContent({});
|
|
2186
|
+
//查找是否是召唤老师回答并有相应的老师名称
|
|
2187
|
+
if (answerMode == 1 && teacherList.length > 0) {
|
|
2188
|
+
var list = teacherList.filter(function(v) {
|
|
2189
|
+
return v.name == keyWord.trim();
|
|
2190
|
+
});
|
|
2191
|
+
if (list.length > 0) {
|
|
2192
|
+
//直接进入召唤老师回答模式
|
|
2193
|
+
enterTeacherChat(list[0]);
|
|
2194
|
+
setButtomHei(45);
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
} else {}
|
|
2167
2198
|
//跟老师对话
|
|
2199
|
+
var roomList = contactsList;
|
|
2168
2200
|
if (roomList.length > 0 && roomList[0].roomId != roomId) {
|
|
2169
2201
|
sendToTeacher(2);
|
|
2170
2202
|
} else {
|
|
2203
|
+
setAnswerMode(-1);
|
|
2204
|
+
setQuestionsList([]);
|
|
2205
|
+
setTeacherList([]);
|
|
2171
2206
|
sendMessage("", 0);
|
|
2172
2207
|
}
|
|
2173
2208
|
setButtomHei(45);
|
|
@@ -2250,8 +2285,21 @@ var CustomerService = function(props) {
|
|
|
2250
2285
|
setCitationContent({});
|
|
2251
2286
|
setButtomHei(45);
|
|
2252
2287
|
if (keyWord.trim() != "") {
|
|
2288
|
+
//查找是否是召唤老师回答并有相应的老师名称
|
|
2289
|
+
if (answerMode == 1 && teacherList.length > 0) {
|
|
2290
|
+
var list = teacherList.filter(function(v) {
|
|
2291
|
+
return v.name == keyWord.trim();
|
|
2292
|
+
});
|
|
2293
|
+
if (list.length > 0) {
|
|
2294
|
+
//直接进入召唤老师回答模式
|
|
2295
|
+
enterTeacherChat(list[0]);
|
|
2296
|
+
setButtomHei(45);
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2253
2300
|
setKeyWord("");
|
|
2254
2301
|
//跟老师对话
|
|
2302
|
+
var roomList = contactsList;
|
|
2255
2303
|
if (roomList.length > 0 && roomList[0].roomId != roomId) {
|
|
2256
2304
|
sendToTeacher(2);
|
|
2257
2305
|
} else {
|
|
@@ -2266,6 +2314,34 @@ var CustomerService = function(props) {
|
|
|
2266
2314
|
]
|
|
2267
2315
|
});
|
|
2268
2316
|
};
|
|
2317
|
+
//进入与老师的聊天
|
|
2318
|
+
var enterTeacherChat = function(item) {
|
|
2319
|
+
setTeacherList([]);
|
|
2320
|
+
//提问的问题
|
|
2321
|
+
setProblem({
|
|
2322
|
+
question: problem.question,
|
|
2323
|
+
user: item.uid
|
|
2324
|
+
});
|
|
2325
|
+
setKeyWord("");
|
|
2326
|
+
//setUpdateRecords(true);
|
|
2327
|
+
setAnswerMode(-1);
|
|
2328
|
+
setChatWith(item);
|
|
2329
|
+
var roomList = contactsList;
|
|
2330
|
+
var list = roomList.filter(function(e) {
|
|
2331
|
+
return e.sender == item.uid;
|
|
2332
|
+
});
|
|
2333
|
+
setShowContacts(true);
|
|
2334
|
+
if (list.length > 0) {
|
|
2335
|
+
setRoomId(list[0].roomId); //已有聊天室
|
|
2336
|
+
} else {
|
|
2337
|
+
createRooms(item.uid).then(function(res) {
|
|
2338
|
+
// childRef.current.roomsListTimer();
|
|
2339
|
+
roomsListTimer();
|
|
2340
|
+
var id = res.data.id;
|
|
2341
|
+
setRoomId(id); //新的聊天室id
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
};
|
|
2269
2345
|
//渲染联想问题及联想的老师名称
|
|
2270
2346
|
var renderAssociationProblem = function() {
|
|
2271
2347
|
if (answerMode == 1) {
|
|
@@ -2275,35 +2351,14 @@ var CustomerService = function(props) {
|
|
|
2275
2351
|
bottom: "".concat(buttomHei + 14, "px")
|
|
2276
2352
|
},
|
|
2277
2353
|
children: teacherList.map(function(item) {
|
|
2278
|
-
var span = item.name.replaceAll(keyWord, function() {
|
|
2279
|
-
return "<span class=".concat(styles.sign, ">").concat(
|
|
2354
|
+
var span = item.name.replaceAll(new RegExp(keyWord, "ig"), function(i) {
|
|
2355
|
+
return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
|
|
2280
2356
|
});
|
|
2281
2357
|
return /*#__PURE__*/ _jsx("p", {
|
|
2282
2358
|
className: styles.item,
|
|
2283
2359
|
children: /*#__PURE__*/ _jsx("span", {
|
|
2284
2360
|
onClick: function() {
|
|
2285
|
-
|
|
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
|
-
}
|
|
2361
|
+
enterTeacherChat(item);
|
|
2307
2362
|
},
|
|
2308
2363
|
dangerouslySetInnerHTML: {
|
|
2309
2364
|
__html: span
|
|
@@ -2319,8 +2374,8 @@ var CustomerService = function(props) {
|
|
|
2319
2374
|
bottom: "".concat(buttomHei + 6, "px")
|
|
2320
2375
|
},
|
|
2321
2376
|
children: questionsList.map(function(item) {
|
|
2322
|
-
var span = item.question.replaceAll(keyWord, function() {
|
|
2323
|
-
return "<span class=".concat(styles.sign, ">").concat(
|
|
2377
|
+
var span = item.question.replaceAll(new RegExp(keyWord, "ig"), function(i) {
|
|
2378
|
+
return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
|
|
2324
2379
|
});
|
|
2325
2380
|
return /*#__PURE__*/ _jsx("p", {
|
|
2326
2381
|
className: styles.item,
|
|
@@ -2351,20 +2406,22 @@ var CustomerService = function(props) {
|
|
|
2351
2406
|
getHistoryMessage(page, 1);
|
|
2352
2407
|
} else {
|
|
2353
2408
|
setRoomId(renewRoomId);
|
|
2354
|
-
if (childRef.current) {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
}
|
|
2358
|
-
setTimeout(function() {
|
|
2359
|
-
childRef.current.roomsListTimer();
|
|
2360
|
-
}, 500);
|
|
2409
|
+
// if (childRef.current) {
|
|
2410
|
+
if (receiver != mid) {
|
|
2411
|
+
createRooms(receiver);
|
|
2361
2412
|
}
|
|
2413
|
+
setTimeout(function() {
|
|
2414
|
+
// childRef.current.roomsListTimer();
|
|
2415
|
+
roomsListTimer();
|
|
2416
|
+
}, 500);
|
|
2417
|
+
// }
|
|
2362
2418
|
}
|
|
2419
|
+
setShowContacts(true);
|
|
2363
2420
|
};
|
|
2364
2421
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2365
2422
|
children: [
|
|
2366
2423
|
/*#__PURE__*/ _jsxs(Drawer, {
|
|
2367
|
-
title: "
|
|
2424
|
+
title: "AI助手",
|
|
2368
2425
|
width: 560,
|
|
2369
2426
|
onClose: function() {
|
|
2370
2427
|
onCancel();
|
|
@@ -2389,9 +2446,9 @@ var CustomerService = function(props) {
|
|
|
2389
2446
|
onClose: function() {
|
|
2390
2447
|
setShowContacts(false);
|
|
2391
2448
|
},
|
|
2392
|
-
// roomIdAi={roomIdAi}
|
|
2393
2449
|
switchChatRoom: switchChatRoom,
|
|
2394
|
-
|
|
2450
|
+
// saveContactsList={saveContactsList}
|
|
2451
|
+
contactsList: contactsList,
|
|
2395
2452
|
ref: childRef
|
|
2396
2453
|
})
|
|
2397
2454
|
}),
|
|
@@ -2448,7 +2505,7 @@ var CustomerService = function(props) {
|
|
|
2448
2505
|
]
|
|
2449
2506
|
}),
|
|
2450
2507
|
/*#__PURE__*/ _jsxs(Modal, {
|
|
2451
|
-
title: "
|
|
2508
|
+
title: "AI助手",
|
|
2452
2509
|
open: showType == 2 ? true : false,
|
|
2453
2510
|
onCancel: function() {
|
|
2454
2511
|
onCancel();
|
|
@@ -2487,7 +2544,8 @@ var CustomerService = function(props) {
|
|
|
2487
2544
|
setShowContacts(false);
|
|
2488
2545
|
},
|
|
2489
2546
|
switchChatRoom: switchChatRoom,
|
|
2490
|
-
|
|
2547
|
+
contactsList: contactsList,
|
|
2548
|
+
// saveContactsList={saveContactsList}
|
|
2491
2549
|
ref: childRef
|
|
2492
2550
|
}),
|
|
2493
2551
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -2543,13 +2601,7 @@ var CustomerService = function(props) {
|
|
|
2543
2601
|
/*#__PURE__*/ _jsx("div", {
|
|
2544
2602
|
className: styles.user,
|
|
2545
2603
|
children: /*#__PURE__*/ _jsx("p", {
|
|
2546
|
-
children:
|
|
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 : "智能问答"
|
|
2604
|
+
children: showChatRoomName()
|
|
2553
2605
|
})
|
|
2554
2606
|
}),
|
|
2555
2607
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -2570,7 +2622,7 @@ var CustomerService = function(props) {
|
|
|
2570
2622
|
onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
|
|
2571
2623
|
setFirstLoad(false);
|
|
2572
2624
|
setShowType(4);
|
|
2573
|
-
|
|
2625
|
+
// childRef.current.roomsListTimer();
|
|
2574
2626
|
},
|
|
2575
2627
|
children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
|
|
2576
2628
|
}),
|
|
@@ -2638,8 +2690,9 @@ var CustomerService = function(props) {
|
|
|
2638
2690
|
onClose: function() {
|
|
2639
2691
|
setShowContacts(false);
|
|
2640
2692
|
},
|
|
2693
|
+
contactsList: contactsList,
|
|
2641
2694
|
switchChatRoom: switchChatRoom,
|
|
2642
|
-
|
|
2695
|
+
// saveContactsList={saveContactsList}
|
|
2643
2696
|
ref: childRef
|
|
2644
2697
|
})
|
|
2645
2698
|
})
|
|
@@ -2648,7 +2701,7 @@ var CustomerService = function(props) {
|
|
|
2648
2701
|
showType == 4 && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
2649
2702
|
children: [
|
|
2650
2703
|
/*#__PURE__*/ _jsxs(Modal, {
|
|
2651
|
-
title: "
|
|
2704
|
+
title: "AI助手",
|
|
2652
2705
|
open: true,
|
|
2653
2706
|
onCancel: function() {
|
|
2654
2707
|
onCancel();
|
|
@@ -2686,8 +2739,9 @@ var CustomerService = function(props) {
|
|
|
2686
2739
|
onClose: function() {
|
|
2687
2740
|
setShowContacts(false);
|
|
2688
2741
|
},
|
|
2742
|
+
contactsList: contactsList,
|
|
2689
2743
|
switchChatRoom: switchChatRoom,
|
|
2690
|
-
|
|
2744
|
+
// saveContactsList={saveContactsList}
|
|
2691
2745
|
ref: childRef
|
|
2692
2746
|
}),
|
|
2693
2747
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -2743,13 +2797,7 @@ var CustomerService = function(props) {
|
|
|
2743
2797
|
/*#__PURE__*/ _jsx("div", {
|
|
2744
2798
|
className: styles.user,
|
|
2745
2799
|
children: /*#__PURE__*/ _jsx("p", {
|
|
2746
|
-
children:
|
|
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 : "智能问答"
|
|
2800
|
+
children: showChatRoomName()
|
|
2753
2801
|
})
|
|
2754
2802
|
}),
|
|
2755
2803
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -2768,7 +2816,7 @@ var CustomerService = function(props) {
|
|
|
2768
2816
|
onClick: function() {
|
|
2769
2817
|
onEvent(serverName + serverUrl(), "click_智能问答_全屏", "提交");
|
|
2770
2818
|
setShowType(4);
|
|
2771
|
-
|
|
2819
|
+
// childRef.current.roomsListTimer();
|
|
2772
2820
|
},
|
|
2773
2821
|
children: /*#__PURE__*/ _jsx(CustomFullScreen, {})
|
|
2774
2822
|
}),
|
|
@@ -2825,8 +2873,9 @@ var CustomerService = function(props) {
|
|
|
2825
2873
|
onClose: function() {
|
|
2826
2874
|
setShowContacts(false);
|
|
2827
2875
|
},
|
|
2876
|
+
contactsList: contactsList,
|
|
2828
2877
|
switchChatRoom: switchChatRoom,
|
|
2829
|
-
|
|
2878
|
+
// saveContactsList={saveContactsList}
|
|
2830
2879
|
ref: childRef
|
|
2831
2880
|
})
|
|
2832
2881
|
})
|