bhd-components 0.7.19 → 0.7.21

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.
@@ -1874,7 +1874,16 @@
1874
1874
  }
1875
1875
  }
1876
1876
  }
1877
-
1877
+ //老师列表
1878
+ .teacher_list{
1879
+ .name{
1880
+ margin-bottom: 0!important;
1881
+ font-weight: 400 !important;
1882
+ .sign{
1883
+ color: @color-text-primary;
1884
+ }
1885
+ }
1886
+ }
1878
1887
  //截图功能
1879
1888
  .screenshot_Modal{
1880
1889
  position: fixed;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ interface data {
3
+ type: number;
4
+ userData: any;
5
+ http: any;
6
+ urllocation: String;
7
+ onClose: any;
8
+ enterTeacherChat: any;
9
+ }
10
+ declare const TeacherList: (props: data) => JSX.Element;
11
+ export default TeacherList;
@@ -0,0 +1,215 @@
1
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
3
+ import React, { useEffect, useState, useRef } from "react";
4
+ import styles from "./index.module.less";
5
+ import { Input } from "antd";
6
+ import { CustomClose } from "../icons/index";
7
+ import { SearchOutlined } from "@ant-design/icons";
8
+ const TeacherList = (props)=>{
9
+ let { type , userData , http , urllocation , onClose , enterTeacherChat } = props;
10
+ const [keyWordProblem, setKeyWordProblem] = useState(""); //搜索内容
11
+ const [showLoadingState, setShowLoadingState] = useState(1); //1,初始状态,2、无数据 ,3、不显示图片
12
+ const [totalData, setTotalData] = useState([]); //总数据
13
+ const [teacher_list, setTeacher_list] = useState([]); //老师列表,有头像
14
+ const timer = useRef(null); //文本框输入时
15
+ useEffect(()=>{
16
+ getList("");
17
+ return ()=>{
18
+ clearTimeout(timer.current);
19
+ };
20
+ }, []);
21
+ const getList = (val)=>{
22
+ http.get(`${urllocation}/chat-service/public/v1.0/teachers`, {
23
+ params: {
24
+ name: val
25
+ }
26
+ }).then((res)=>{
27
+ console.log(res);
28
+ let data = res.data;
29
+ if (data.total > 0) {
30
+ setShowLoadingState(3);
31
+ setTotalData(res.data.teachers);
32
+ getUserName(res.data.teachers);
33
+ }
34
+ });
35
+ };
36
+ const getUserName = (dataList)=>{
37
+ try {
38
+ let list = dataList;
39
+ let ids = [];
40
+ list = list.map((item)=>{
41
+ if (!item.headImg && teacher_list.filter((v)=>v.uid == item.uid).length <= 0) {
42
+ ids.push(item.uid);
43
+ }
44
+ });
45
+ if (ids.length > 0) {
46
+ userName(ids.join(",")).then((res)=>{
47
+ if (res.data) {
48
+ let nameList = res.data;
49
+ setTotalData((list1)=>{
50
+ let list = list1;
51
+ list = list.map((item)=>{
52
+ let name = nameList.filter((v)=>v.uid == item.uid);
53
+ if (name.length > 0) {
54
+ return _object_spread({}, item, name[0]);
55
+ } else {
56
+ return item;
57
+ }
58
+ });
59
+ setTeacher_list(list);
60
+ return list;
61
+ });
62
+ }
63
+ });
64
+ } else {
65
+ let nameList = teacher_list;
66
+ setTotalData((list1)=>{
67
+ let list = list1;
68
+ list = list.map((item)=>{
69
+ let name = nameList.filter((v)=>v.uid == item.uid);
70
+ if (name.length > 0) {
71
+ return _object_spread({}, item, name[0]);
72
+ } else {
73
+ return item;
74
+ }
75
+ });
76
+ setTeacher_list(list);
77
+ return list;
78
+ });
79
+ }
80
+ } catch (error) {}
81
+ };
82
+ const userName = (uid)=>{
83
+ return http.get(`${urllocation}/chat-service/public/v1.0/userinfo`, {
84
+ params: {
85
+ uid: uid
86
+ },
87
+ headers: {
88
+ "x-module-id": userData.modules.find((ele)=>ele.short == "IntelligentCustomerService").id,
89
+ "x-auth-jwt": window.localStorage.getItem("usertoken") || ""
90
+ }
91
+ });
92
+ };
93
+ return /*#__PURE__*/ _jsx("div", {
94
+ className: `${styles.history_list} ${type == 2 ? styles.history_list_broadside : ""} ${styles.teacher_list}`,
95
+ children: /*#__PURE__*/ _jsxs("div", {
96
+ className: styles.search_layout,
97
+ children: [
98
+ /*#__PURE__*/ _jsxs("div", {
99
+ className: styles.title,
100
+ children: [
101
+ /*#__PURE__*/ _jsx("span", {
102
+ children: "召唤老师回答"
103
+ }),
104
+ /*#__PURE__*/ _jsx("span", {
105
+ onClick: ()=>{
106
+ // loadSpecifiedData();
107
+ onClose();
108
+ },
109
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
110
+ })
111
+ ]
112
+ }),
113
+ /*#__PURE__*/ _jsxs("div", {
114
+ className: styles.search_top,
115
+ children: [
116
+ /*#__PURE__*/ _jsx(SearchOutlined, {}),
117
+ /*#__PURE__*/ _jsx(Input, {
118
+ placeholder: "请输入您要召唤的老师姓名",
119
+ value: keyWordProblem,
120
+ onChange: (e)=>{
121
+ let val = String(e.target.value);
122
+ setKeyWordProblem(val);
123
+ clearTimeout(timer.current);
124
+ timer.current = setTimeout(()=>{
125
+ if (val != "") {
126
+ setTotalData([]);
127
+ getList(val);
128
+ } else {
129
+ setShowLoadingState(1);
130
+ setTotalData([]);
131
+ }
132
+ }, 1000);
133
+ }
134
+ }),
135
+ /*#__PURE__*/ _jsx("i", {
136
+ className: "guanbi_Close",
137
+ onClick: ()=>{
138
+ setShowLoadingState(1);
139
+ setKeyWordProblem("");
140
+ setTotalData([]);
141
+ },
142
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
143
+ })
144
+ ]
145
+ }),
146
+ /*#__PURE__*/ _jsxs("div", {
147
+ className: styles.main_list,
148
+ id: "history_list",
149
+ children: [
150
+ showLoadingState == 1 && /*#__PURE__*/ _jsxs("div", {
151
+ className: styles.no_data,
152
+ children: [
153
+ /*#__PURE__*/ _jsx("img", {
154
+ src: "/new_yun/images/aiService/search_for_icon.png"
155
+ }),
156
+ /*#__PURE__*/ _jsx("p", {
157
+ children: "输入关键词,搜索老师姓名"
158
+ })
159
+ ]
160
+ }),
161
+ showLoadingState == 2 && /*#__PURE__*/ _jsxs("div", {
162
+ className: styles.no_data,
163
+ children: [
164
+ /*#__PURE__*/ _jsx("img", {
165
+ src: "/new_yun/images/aiService/no_data.png"
166
+ }),
167
+ /*#__PURE__*/ _jsx("p", {
168
+ children: "暂无记录"
169
+ })
170
+ ]
171
+ }),
172
+ /*#__PURE__*/ _jsx("div", {
173
+ className: styles.list_item,
174
+ children: totalData.map((item)=>{
175
+ let span = item.name.replaceAll(new RegExp(keyWordProblem, "ig"), (i)=>{
176
+ return `<span class=${styles.sign}>${i}</span>`;
177
+ });
178
+ return /*#__PURE__*/ _jsx(_Fragment, {
179
+ children: /*#__PURE__*/ _jsxs("div", {
180
+ className: `${styles.list_summary}`,
181
+ id: item.roomId,
182
+ onClick: ()=>{
183
+ enterTeacherChat(item);
184
+ },
185
+ children: [
186
+ /*#__PURE__*/ _jsx("div", {
187
+ className: styles.head_img,
188
+ children: /*#__PURE__*/ _jsx("img", {
189
+ src: item.headImg
190
+ })
191
+ }),
192
+ /*#__PURE__*/ _jsx("div", {
193
+ className: styles.list_desc,
194
+ children: /*#__PURE__*/ _jsx("p", {
195
+ className: styles.name,
196
+ style: {
197
+ width: "calc(100% - 36px)"
198
+ },
199
+ dangerouslySetInnerHTML: {
200
+ __html: span
201
+ }
202
+ })
203
+ })
204
+ ]
205
+ })
206
+ });
207
+ })
208
+ })
209
+ ]
210
+ })
211
+ ]
212
+ })
213
+ });
214
+ };
215
+ export default TeacherList;
@@ -4,19 +4,12 @@ import styles from "./index.module.less";
4
4
  import { Tooltip } from "antd";
5
5
  import { CustomAiIcon, CustomRetract } from "../icons/index";
6
6
  import { CloseOutlined } from "@ant-design/icons";
7
- import { getDataTime, getByteLen } from "./function"; //录音使用文件
7
+ import { getByteLen, formatDate } from "./function"; //录音使用文件
8
8
  var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
9
9
  var type = props.type, roomId = props.roomId, userData = props.userData, http = props.http, urllocation = props.urllocation, onClose = props.onClose, switchChatRoom = props.switchChatRoom, contactsList = props.contactsList;
10
- // useImperativeHandle(ref, () => ({
11
- // roomsListTimer: () => {
12
- // return roomsListTimer();
13
- // },
14
- // roomsList:contactsList,
15
- // }),[contactsList]);
16
10
  //删除聊天室
17
11
  var deleteRoom = function(roomId) {
18
- http.delete("".concat(urllocation, "/chat-service/public/v1.0/rooms/").concat(roomId), {
19
- }).then(function(res) {
12
+ http.delete("".concat(urllocation, "/chat-service/public/v1.0/rooms/").concat(roomId), {}).then(function(res) {
20
13
  // roomsListTimer();
21
14
  switchChatRoom(roomId, "1");
22
15
  });
@@ -45,7 +38,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
45
38
  }) ? "AI助手" : "智能问答",
46
39
  /*#__PURE__*/ _jsx("span", {
47
40
  className: styles.time,
48
- children: contactsList.length > 0 && contactsList[0].createdAt != undefined && getDataTime(contactsList[0].createdAt)
41
+ children: contactsList.length > 0 && contactsList[0].createdAt != undefined && formatDate(contactsList[0].createdAt)
49
42
  })
50
43
  ]
51
44
  }),
@@ -60,18 +53,10 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
60
53
  }),
61
54
  userData.modules.some(function(item) {
62
55
  return item.short == "TeacherAnswer";
63
- }) ? /*#__PURE__*/ _jsx("div", {
56
+ }) && /*#__PURE__*/ _jsx("div", {
64
57
  className: styles.bottom,
65
58
  children: contactsList.map(function(item, index) {
66
59
  if (index != 0) {
67
- var time = "";
68
- var currentTime = getDataTime(-1, 1); //当前时间
69
- var updatedAt = getDataTime(item.createdAt, 1);
70
- if (currentTime == updatedAt) {
71
- time = getDataTime(item.createdAt, 2);
72
- } else {
73
- time = getDataTime(item.createdAt);
74
- }
75
60
  return /*#__PURE__*/ _jsxs("div", {
76
61
  className: "".concat(styles.ai, " ").concat(item.roomId != undefined && roomId != "" && item.roomId == roomId ? styles.active : ""),
77
62
  onClick: function() {
@@ -99,7 +84,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
99
84
  }),
100
85
  /*#__PURE__*/ _jsx("span", {
101
86
  className: styles.time,
102
- children: getDataTime(item.createdAt)
87
+ children: formatDate(item.createdAt)
103
88
  })
104
89
  ]
105
90
  }),
@@ -115,7 +100,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
115
100
  return null;
116
101
  }
117
102
  })
118
- }) : ""
103
+ })
119
104
  ]
120
105
  }) : /*#__PURE__*/ _jsxs("div", {
121
106
  className: "".concat(styles.teacher_layout, " ").concat(type == 3 ? styles.teacher_layout_newlabo : ""),
@@ -19,4 +19,6 @@ declare const getQuery: (name: string) => string;
19
19
  declare const findParent: (e: any, className: string) => any;
20
20
  declare const delegate: (element: any, eventType: string, selector: string, callback: any) => void;
21
21
  declare const getBase64Image: (src: any) => Promise<unknown>;
22
- export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image };
22
+ declare const formatDate: (dateStr: any) => any;
23
+ declare const urlToBase64: (url: string) => Promise<unknown>;
24
+ export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image, formatDate, urlToBase64 };
@@ -137,4 +137,48 @@ var getBase64Image = function(src) {
137
137
  };
138
138
  });
139
139
  };
140
- export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image };
140
+ var formatDate = function(dateStr) {
141
+ var today = new Date();
142
+ var date = new Date(dateStr);
143
+ var dayDiff = Math.ceil((today - date) / (1000 * 60 * 60 * 24)); // 计算天数差
144
+ // console.log(dayDiff,'dayDiffdayDiff',today,'___',date);
145
+ if (dayDiff === 0 || dayDiff === 1) {
146
+ // 今天
147
+ return date.toLocaleTimeString("zh-CN", {
148
+ hour12: false
149
+ }).substring(0, 5);
150
+ } else if (dayDiff <= 7) {
151
+ // 一周内
152
+ return date.toLocaleString("zh-CN", {
153
+ weekday: "short"
154
+ }).replace("周", "星期");
155
+ } else {
156
+ // 超过一周
157
+ return date.toLocaleDateString("zh-CN");
158
+ }
159
+ };
160
+ var urlToBase64 = function(url) {
161
+ return new Promise(function(resolve) {
162
+ var image = new Image();
163
+ // 先设置图片跨域属性
164
+ image.crossOrigin = "Anonymous";
165
+ // 再给image赋值src属性,先后顺序不能颠倒
166
+ image.src = url;
167
+ image.onload = function() {
168
+ var canvas = document.createElement("CANVAS");
169
+ // 设置canvas宽高等于图片实际宽高
170
+ canvas.width = image.width;
171
+ canvas.height = image.height;
172
+ canvas.getContext("2d").drawImage(image, 0, 0);
173
+ // toDataUrl可以接收2个参数,参数一:图片类型,参数二: 图片质量0-1(不传默认为0.92)
174
+ var dataURL = canvas.toDataURL("image/jpeg");
175
+ resolve(dataURL);
176
+ };
177
+ image.onerror = function() {
178
+ resolve({
179
+ message: "相片处理失败"
180
+ });
181
+ };
182
+ });
183
+ };
184
+ export { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, getBase64Image, formatDate, urlToBase64 };
@@ -8,7 +8,7 @@ import "highlight.js/styles/default.css";
8
8
  import { Input } from "antd";
9
9
  import { CustomClose, CustomExpand, CustomAiIcon } from "../icons/index";
10
10
  import { SearchOutlined } from "@ant-design/icons";
11
- import { getDataTime } from "./function"; //录音使用文件
11
+ import { formatDate } from "./function"; //录音使用文件
12
12
  var HistoryFun = function(props) {
13
13
  var type = props.type, roomId = props.roomId, userData = props.userData, http = props.http, urllocation = props.urllocation, onClose = props.onClose, loadSpecifiedData = props.loadSpecifiedData;
14
14
  var _useState = _sliced_to_array(useState(""), 2), keyWordProblem = _useState[0], setKeyWordProblem = _useState[1]; //搜索内容
@@ -56,13 +56,11 @@ var HistoryFun = function(props) {
56
56
  maxPageSize: maxPageSize
57
57
  }
58
58
  }).then(function(res) {
59
- console.log(res, 7777779999);
60
59
  var data = res.data;
61
60
  if (data.total > 0) {
62
61
  setShowLoadingState(3);
63
62
  var list = data.messageHistories;
64
63
  setPageCount(Math.ceil(data.total / maxPageSize));
65
- // setTotalData(totalData.concat(list));
66
64
  setTotalData(function(list1) {
67
65
  var new_list = list1;
68
66
  new_list = new_list.concat(list);
@@ -367,13 +365,7 @@ var HistoryFun = function(props) {
367
365
  return "<span class=".concat(styles.sign, ">").concat(i, "</span>");
368
366
  });
369
367
  }
370
- var currentTime = getDataTime(-1, 1); //当前时间
371
- var createdAt = getDataTime(item.createdAt, 1);
372
- if (currentTime == createdAt) {
373
- time = getDataTime(item.createdAt, 2);
374
- } else {
375
- time = getDataTime(item.createdAt);
376
- }
368
+ time = formatDate(item.createdAt);
377
369
  }
378
370
  return /*#__PURE__*/ _jsxs(_Fragment, {
379
371
  children: [
@@ -440,14 +432,7 @@ var HistoryFun = function(props) {
440
432
  } else {
441
433
  name = userData.real_name;
442
434
  }
443
- var time = "";
444
- var currentTime = getDataTime(-1, 1); //当前时间
445
- var updatedAt = getDataTime(list.updatedAt, 1);
446
- if (currentTime == updatedAt) {
447
- time = getDataTime(list.updatedAt, 2);
448
- } else {
449
- time = getDataTime(list.updatedAt);
450
- }
435
+ var time = formatDate(list.updatedAt);
451
436
  var reg = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
452
437
  var span = "";
453
438
  //搜索内容是否有特殊字符