@fle-ui/plus-im-record 0.0.8-beta.1 → 0.0.8-beta.4
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/es/ChatMessageItem/index.less +4 -1
- package/es/ChatMessageList/index.d.ts +1 -0
- package/es/ChatMessageList/index.js +12 -4
- package/es/GoodsCard/index.less +1 -0
- package/es/GoodsOrderCard/index.less +1 -0
- package/es/OrderGoodsCard/index.d.ts +8 -0
- package/es/OrderGoodsCard/index.js +85 -0
- package/es/OrderGoodsCard/index.less +61 -0
- package/es/ParseSession/index.js +23 -9
- package/es/ParseSession/index.less +2 -2
- package/es/api/index.d.ts +4 -0
- package/es/api/index.js +4 -0
- package/es/index.d.ts +14 -1
- package/es/index.js +36 -2
- package/lib/ChatMessageItem/index.less +4 -1
- package/lib/ChatMessageList/index.d.ts +1 -0
- package/lib/ChatMessageList/index.js +15 -4
- package/lib/GoodsCard/index.less +1 -0
- package/lib/GoodsOrderCard/index.less +1 -0
- package/lib/OrderGoodsCard/index.d.ts +8 -0
- package/lib/OrderGoodsCard/index.js +95 -0
- package/lib/OrderGoodsCard/index.less +61 -0
- package/lib/ParseSession/index.js +23 -9
- package/lib/ParseSession/index.less +2 -2
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.js +4 -0
- package/lib/index.d.ts +14 -1
- package/lib/index.js +35 -2
- package/package.json +2 -2
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
white-space: break-spaces;
|
|
65
65
|
overflow: hidden;
|
|
66
66
|
max-width: 375px;
|
|
67
|
-
min-width:
|
|
67
|
+
min-width: 24px;
|
|
68
68
|
border-radius: 2px 6px 6px 6px;
|
|
69
69
|
background: #fff;
|
|
70
70
|
}
|
|
@@ -98,6 +98,9 @@
|
|
|
98
98
|
border-radius: 6px 2px 6px 6px;
|
|
99
99
|
background: #dbe6ff;
|
|
100
100
|
}
|
|
101
|
+
.@{prefix}-ref-body {
|
|
102
|
+
border-left: 3px solid #c2d4ff;
|
|
103
|
+
}
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
// 对话-H5
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import ChatMessageItem from '../ChatMessageItem';
|
|
3
3
|
import { debounce } from '../utils';
|
|
4
4
|
import './index.less';
|
|
@@ -8,7 +8,8 @@ var LOADING_STATUS = {
|
|
|
8
8
|
};
|
|
9
9
|
var LOAD_LIMIT = 15;
|
|
10
10
|
var ChatMessageList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
11
|
-
var
|
|
11
|
+
var searchValue = _ref.searchValue,
|
|
12
|
+
h5 = _ref.h5,
|
|
12
13
|
msgs = _ref.msgs,
|
|
13
14
|
onScrollTop = _ref.onScrollTop,
|
|
14
15
|
onScrollBottom = _ref.onScrollBottom,
|
|
@@ -30,6 +31,13 @@ var ChatMessageList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
30
31
|
isTop && (onScrollTop === null || onScrollTop === void 0 ? void 0 : onScrollTop(e));
|
|
31
32
|
isBottom && (onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom(e));
|
|
32
33
|
}, 200);
|
|
34
|
+
var filteredMsgs = useMemo(function () {
|
|
35
|
+
return msgs.filter(function (msg) {
|
|
36
|
+
var _msg$attach, _msg$attach2;
|
|
37
|
+
return ((_msg$attach = msg.attach) === null || _msg$attach === void 0 ? void 0 : _msg$attach.type) === 'text' && (((_msg$attach2 = msg.attach) === null || _msg$attach2 === void 0 ? void 0 : _msg$attach2.content) || '').indexOf(searchValue) > -1;
|
|
38
|
+
});
|
|
39
|
+
}, [msgs, searchValue]);
|
|
40
|
+
var messagesToRender = searchValue ? filteredMsgs : msgs;
|
|
33
41
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
42
|
className: prefixCls,
|
|
35
43
|
style: style || {}
|
|
@@ -39,13 +47,13 @@ var ChatMessageList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
39
47
|
onScroll: onScrollHandler
|
|
40
48
|
}, /*#__PURE__*/React.createElement("div", {
|
|
41
49
|
className: "".concat(prefixCls, "-status")
|
|
42
|
-
}, msgs.length < LOAD_LIMIT || !LOADING_STATUS[loadingStarus] ? null : LOADING_STATUS[loadingStarus]),
|
|
50
|
+
}, msgs.length < LOAD_LIMIT || !LOADING_STATUS[loadingStarus] ? null : LOADING_STATUS[loadingStarus]), messagesToRender.map(function (msg) {
|
|
43
51
|
return /*#__PURE__*/React.createElement("div", {
|
|
44
52
|
id: msg.idServer,
|
|
45
53
|
key: msg.idServer
|
|
46
54
|
}, /*#__PURE__*/React.createElement(ChatMessageItem, {
|
|
47
55
|
h5: h5,
|
|
48
|
-
keyword: '',
|
|
56
|
+
keyword: searchValue || '',
|
|
49
57
|
myAccount: myAccount,
|
|
50
58
|
prefix: "".concat(prefixCls, "-item"),
|
|
51
59
|
msg: msg,
|
package/es/GoodsCard/index.less
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { fallbackImg } from '../common/const';
|
|
10
|
+
import './index.less';
|
|
11
|
+
import { ImContext } from '..';
|
|
12
|
+
var OrderGoodsCard = function OrderGoodsCard(props) {
|
|
13
|
+
var _props$prefix = props.prefix,
|
|
14
|
+
prefix = _props$prefix === void 0 ? 'fx-chart-messages-item' : _props$prefix,
|
|
15
|
+
_props$orderSn = props.orderSn,
|
|
16
|
+
orderSn = _props$orderSn === void 0 ? '' : _props$orderSn,
|
|
17
|
+
messageId = props.messageId;
|
|
18
|
+
var _useState = useState([]),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
data = _useState2[0],
|
|
21
|
+
setData = _useState2[1];
|
|
22
|
+
var _useState3 = useState(false),
|
|
23
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
24
|
+
isExpand = _useState4[0],
|
|
25
|
+
setIsExpand = _useState4[1];
|
|
26
|
+
var _useContext = useContext(ImContext),
|
|
27
|
+
api = _useContext.api;
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (orderSn && messageId) {
|
|
30
|
+
api.getOrderGoods({
|
|
31
|
+
orderSn: orderSn,
|
|
32
|
+
messageId: messageId
|
|
33
|
+
}).then(function (_ref) {
|
|
34
|
+
var data = _ref.data;
|
|
35
|
+
setData(data || []);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, [orderSn, messageId]);
|
|
39
|
+
function formatOrderPrice(item) {
|
|
40
|
+
var currencyStr = item.currencyStr || '积分';
|
|
41
|
+
if (Number(item.price || 0) > 0 && Number(item.score || 0) > 0) {
|
|
42
|
+
return "".concat(item.score).concat(currencyStr, " + ").concat(item.price, "\u5143");
|
|
43
|
+
}
|
|
44
|
+
if (Number(item.price || 0) > 0) {
|
|
45
|
+
return "".concat(item.price, "\u5143");
|
|
46
|
+
}
|
|
47
|
+
if (Number(item.score || 0) > 0) {
|
|
48
|
+
return "".concat(item.score).concat(currencyStr);
|
|
49
|
+
}
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: classNames("".concat(prefix, "-order-goods"))
|
|
54
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "".concat(prefix, "-order-goods-summary")
|
|
56
|
+
}, "\u60A8\u597D\uFF0C\u8BF7\u9009\u62E9\u60A8\u8981\u54A8\u8BE2\u7684\u5546\u54C1\uFF1A"), data === null || data === void 0 ? void 0 : data.slice(0, isExpand ? data === null || data === void 0 ? void 0 : data.length : 5).map(function (item, index) {
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
key: +index,
|
|
59
|
+
className: "".concat(prefix, "-order-goods-item")
|
|
60
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "".concat(prefix, "-order-goods-item-img"),
|
|
62
|
+
style: {
|
|
63
|
+
background: "url(".concat(item.pic || fallbackImg, ") 0 0 / cover no-repeat")
|
|
64
|
+
}
|
|
65
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: "".concat(prefix, "-order-goods-item-right")
|
|
67
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "".concat(prefix, "-order-goods-item-title two-line-text")
|
|
69
|
+
}, item.title), /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
style: {
|
|
71
|
+
display: 'flex',
|
|
72
|
+
justifyContent: 'space-between',
|
|
73
|
+
gap: 8
|
|
74
|
+
}
|
|
75
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: "".concat(prefix, "-order-goods-item-price")
|
|
77
|
+
}, item.applicationId === 7 ? null : formatOrderPrice(item)))));
|
|
78
|
+
}), (data === null || data === void 0 ? void 0 : data.length) > 5 && /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: "".concat(prefix, "-order-goods-expand"),
|
|
80
|
+
onClick: function onClick() {
|
|
81
|
+
return setIsExpand(!isExpand);
|
|
82
|
+
}
|
|
83
|
+
}, isExpand ? '收起' : '展开全部', " ", "(".concat(data === null || data === void 0 ? void 0 : data.length, ")")));
|
|
84
|
+
};
|
|
85
|
+
export default OrderGoodsCard;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@prefix: chart-messages-item;
|
|
2
|
+
|
|
3
|
+
.@{prefix}-order-goods {
|
|
4
|
+
max-width: 272px;
|
|
5
|
+
min-width: 200px;
|
|
6
|
+
padding: 12px;
|
|
7
|
+
padding-bottom: 6px;
|
|
8
|
+
&-summary {
|
|
9
|
+
margin-bottom: 8px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&-item {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-flow: row;
|
|
15
|
+
padding: 8px 0;
|
|
16
|
+
&:not(:last-child) {
|
|
17
|
+
border-bottom: 1px solid #eee;
|
|
18
|
+
}
|
|
19
|
+
&-img {
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
border-radius: 4px;
|
|
22
|
+
width: 60px;
|
|
23
|
+
height: 60px;
|
|
24
|
+
margin-right: 6px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
object-fit: fill;
|
|
27
|
+
}
|
|
28
|
+
img {
|
|
29
|
+
width: 100%;
|
|
30
|
+
object-fit: contain;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-right {
|
|
34
|
+
flex: 1;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
}
|
|
37
|
+
&-title {
|
|
38
|
+
line-height: 1.2;
|
|
39
|
+
margin-top: 2px;
|
|
40
|
+
margin-bottom: 4px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-price {
|
|
44
|
+
min-height: 14px;
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
color: #6e7789;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&-btn {
|
|
50
|
+
font-size: 12px !important;
|
|
51
|
+
padding: 0 !important;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&-expand {
|
|
56
|
+
color: var(--prc);
|
|
57
|
+
text-align: center;
|
|
58
|
+
padding-top: 8px;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
}
|
package/es/ParseSession/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import { downloadByUrl, getSimplifyMsg } from '../common/utils';
|
|
|
26
26
|
import Icon from '../Icon';
|
|
27
27
|
import GoodsCard from '../GoodsCard';
|
|
28
28
|
import GoodsOrderCard from '../GoodsOrderCard';
|
|
29
|
+
import OrderGoodsCard from '../OrderGoodsCard';
|
|
29
30
|
import { ImContext } from '..';
|
|
30
31
|
import { pauseAllAudio, pauseOtherVideo } from '../audioAndVideoTool';
|
|
31
32
|
import AudioPlayer from './AudioPlayer';
|
|
@@ -113,7 +114,7 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
113
114
|
className: "".concat(prefix, "-ref-audio-body")
|
|
114
115
|
}, /*#__PURE__*/React.createElement(AudioPlayer, {
|
|
115
116
|
style: {
|
|
116
|
-
backgroundColor: '#
|
|
117
|
+
backgroundColor: msg.flow === 'in' ? '#f7f7f7' : 'rgba(255, 255, 255, 0.5)',
|
|
117
118
|
borderRadius: 4,
|
|
118
119
|
width: 80
|
|
119
120
|
},
|
|
@@ -331,7 +332,6 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
331
332
|
return null;
|
|
332
333
|
};
|
|
333
334
|
var renderAudio = function renderAudio() {
|
|
334
|
-
var flow = msg.flow;
|
|
335
335
|
var duration = Math.floor(attach.content.dur) || 0;
|
|
336
336
|
return /*#__PURE__*/React.createElement(AudioPlayer, {
|
|
337
337
|
prefix: prefix || '',
|
|
@@ -389,7 +389,11 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
389
389
|
href: addUrlSearch(attach.content.url, "download=".concat(attach.content.fileName)),
|
|
390
390
|
target: "_blank",
|
|
391
391
|
rel: "noreferrer"
|
|
392
|
-
}, attach.content.fileName), /*#__PURE__*/React.createElement("span",
|
|
392
|
+
}, attach.content.fileName), /*#__PURE__*/React.createElement("span", {
|
|
393
|
+
style: {
|
|
394
|
+
fontSize: 12
|
|
395
|
+
}
|
|
396
|
+
}, parseFileSize(attach.content.size))));
|
|
393
397
|
};
|
|
394
398
|
var renderOrderCard = function renderOrderCard() {
|
|
395
399
|
var _attach$content8, _attach$content9;
|
|
@@ -406,11 +410,19 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
406
410
|
content: attach.content || {}
|
|
407
411
|
});
|
|
408
412
|
};
|
|
413
|
+
var renderOrderGoods = function renderOrderGoods() {
|
|
414
|
+
var _attach$content10;
|
|
415
|
+
return /*#__PURE__*/React.createElement(OrderGoodsCard, {
|
|
416
|
+
prefix: prefix,
|
|
417
|
+
orderSn: (_attach$content10 = attach.content) === null || _attach$content10 === void 0 ? void 0 : _attach$content10.orderSn,
|
|
418
|
+
messageId: msg.idClient
|
|
419
|
+
});
|
|
420
|
+
};
|
|
409
421
|
var renderChartRecord = function renderChartRecord() {
|
|
410
|
-
var _attach$
|
|
411
|
-
var records = ((_attach$
|
|
412
|
-
var msgIds = ((_attach$
|
|
413
|
-
var title = (_attach$
|
|
422
|
+
var _attach$content11, _attach$content12, _attach$content13;
|
|
423
|
+
var records = ((_attach$content11 = attach.content) === null || _attach$content11 === void 0 ? void 0 : _attach$content11.items) || [];
|
|
424
|
+
var msgIds = ((_attach$content12 = attach.content) === null || _attach$content12 === void 0 ? void 0 : _attach$content12.msgIds) || [];
|
|
425
|
+
var title = (_attach$content13 = attach.content) === null || _attach$content13 === void 0 ? void 0 : _attach$content13.title;
|
|
414
426
|
var list = records.filter(function (v) {
|
|
415
427
|
var _v$attach;
|
|
416
428
|
return ![imMsgTypes.event].includes((_v$attach = v.attach) === null || _v$attach === void 0 ? void 0 : _v$attach.type);
|
|
@@ -441,10 +453,10 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
441
453
|
})), "\u7CFB\u7EDF\u8F6C\u53D1"));
|
|
442
454
|
};
|
|
443
455
|
var renderOfflineSupport = function renderOfflineSupport() {
|
|
444
|
-
var _attach$
|
|
456
|
+
var _attach$content14, _attach$content15;
|
|
445
457
|
return /*#__PURE__*/React.createElement("div", {
|
|
446
458
|
className: "".concat(prefix, "-text")
|
|
447
|
-
}, (_attach$
|
|
459
|
+
}, (_attach$content14 = attach.content) === null || _attach$content14 === void 0 ? void 0 : _attach$content14.supportDesc, ((_attach$content15 = attach.content) === null || _attach$content15 === void 0 ? void 0 : _attach$content15.contact) && /*#__PURE__*/React.createElement("a", {
|
|
448
460
|
href: "tel:".concat(attach.content.contact),
|
|
449
461
|
rel: "noreferrer"
|
|
450
462
|
}, attach.content.contact));
|
|
@@ -480,6 +492,8 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
480
492
|
return renderChartRecord();
|
|
481
493
|
case imMsgTypes.offlineSupport:
|
|
482
494
|
return renderOfflineSupport();
|
|
495
|
+
case imMsgTypes.orderGoods:
|
|
496
|
+
return renderOrderGoods();
|
|
483
497
|
default:
|
|
484
498
|
return '';
|
|
485
499
|
}
|
package/es/api/index.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ interface ApiMethods {
|
|
|
25
25
|
getContact: (params: {
|
|
26
26
|
msgId?: string;
|
|
27
27
|
}) => Promise<any>;
|
|
28
|
+
getOrderGoods: (data: {
|
|
29
|
+
orderSn?: any;
|
|
30
|
+
messageId?: string;
|
|
31
|
+
}) => Promise<any>;
|
|
28
32
|
}
|
|
29
33
|
export declare const apiCreate: (_env?: Env, token?: string) => ApiMethods;
|
|
30
34
|
export {};
|
package/es/api/index.js
CHANGED
|
@@ -38,6 +38,10 @@ export var apiCreate = function apiCreate(_env, token) {
|
|
|
38
38
|
getCSOrder: function getCSOrder(data) {
|
|
39
39
|
return service.post('/ll/provider/message/order/get', data);
|
|
40
40
|
},
|
|
41
|
+
// 获取订单商品信息
|
|
42
|
+
getOrderGoods: function getOrderGoods(data) {
|
|
43
|
+
return service.post('/ll/provider/message/after-sales-agent/goods/list', data);
|
|
44
|
+
},
|
|
41
45
|
// 获取联系人信息(表单)
|
|
42
46
|
getContact: function getContact(params) {
|
|
43
47
|
return service.get('/ll/provider/message/contact/get', {
|
package/es/index.d.ts
CHANGED
|
@@ -8,7 +8,10 @@ import './styles/index.less';
|
|
|
8
8
|
* @description 代码由小鲤客服平台搬运简来.
|
|
9
9
|
*/
|
|
10
10
|
export interface IMRecordProps {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 数据对应的环境
|
|
13
|
+
*/
|
|
14
|
+
env: Env;
|
|
12
15
|
token?: string;
|
|
13
16
|
h5?: boolean;
|
|
14
17
|
msgs: IMMessage[];
|
|
@@ -19,6 +22,16 @@ export interface IMRecordProps {
|
|
|
19
22
|
style?: React.CSSProperties;
|
|
20
23
|
isSessionEnd?: boolean;
|
|
21
24
|
recordSession?: RecordSession;
|
|
25
|
+
/**是否显示搜索输入框 默认为false*/
|
|
26
|
+
showSearchInput?: boolean;
|
|
27
|
+
/**搜索事件,对外抛出搜索关键字*/
|
|
28
|
+
onSearch?: (keyword: string) => void;
|
|
29
|
+
/**搜索模式
|
|
30
|
+
* internal: 内部搜索 只对输入到组件内部的msgs进行搜索
|
|
31
|
+
* external: 外部搜索 只对外抛出搜索关键字,在外部搜索,从而改变输入到组件的msgs
|
|
32
|
+
* 默认为internal
|
|
33
|
+
*/
|
|
34
|
+
searchMode?: 'internal' | 'external';
|
|
22
35
|
}
|
|
23
36
|
export interface ImContextProps {
|
|
24
37
|
api: ReturnType<typeof apiCreate>;
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
|
|
2
|
+
import "antd/es/input/style";
|
|
3
|
+
import _Input from "antd/es/input";
|
|
4
|
+
var _excluded = ["env", "token", "msgs", "recordSession", "showSearchInput", "searchMode", "onSearch"];
|
|
3
5
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -28,12 +30,21 @@ var IMRecord = function IMRecord(_ref) {
|
|
|
28
30
|
token = _ref.token,
|
|
29
31
|
msgs = _ref.msgs,
|
|
30
32
|
recordSession = _ref.recordSession,
|
|
33
|
+
_ref$showSearchInput = _ref.showSearchInput,
|
|
34
|
+
showSearchInput = _ref$showSearchInput === void 0 ? false : _ref$showSearchInput,
|
|
35
|
+
_ref$searchMode = _ref.searchMode,
|
|
36
|
+
searchMode = _ref$searchMode === void 0 ? 'internal' : _ref$searchMode,
|
|
37
|
+
onSearch = _ref.onSearch,
|
|
31
38
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
39
|
var api = apiCreate(env, token);
|
|
33
40
|
var _useState = useState({}),
|
|
34
41
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
42
|
accountsMap = _useState2[0],
|
|
36
43
|
setAccountsMap = _useState2[1];
|
|
44
|
+
var _useState3 = useState(),
|
|
45
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
+
searchValue = _useState4[0],
|
|
47
|
+
setSearchValue = _useState4[1];
|
|
37
48
|
var messageListDomRef = useRef(null);
|
|
38
49
|
useEffect(function () {
|
|
39
50
|
var accids = _toConsumableArray(new Set(msgs.map(function (x) {
|
|
@@ -43,6 +54,16 @@ var IMRecord = function IMRecord(_ref) {
|
|
|
43
54
|
getAccountByAccids(accids);
|
|
44
55
|
}
|
|
45
56
|
}, [msgs]);
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
var handler = setTimeout(function () {
|
|
59
|
+
if (onSearch && searchValue !== undefined) {
|
|
60
|
+
onSearch(searchValue); // 仅在external模式下触发onSearch
|
|
61
|
+
}
|
|
62
|
+
}, 300); // 300ms的防抖时间,可以根据需要调整
|
|
63
|
+
return function () {
|
|
64
|
+
clearTimeout(handler); // 清除上一次的定时器
|
|
65
|
+
};
|
|
66
|
+
}, [searchValue, searchMode, onSearch]);
|
|
46
67
|
function getAccountByAccids(accids) {
|
|
47
68
|
api.getAccountInfoByAccid({
|
|
48
69
|
accids: accids
|
|
@@ -65,7 +86,20 @@ var IMRecord = function IMRecord(_ref) {
|
|
|
65
86
|
value: {
|
|
66
87
|
api: api
|
|
67
88
|
}
|
|
68
|
-
}, /*#__PURE__*/React.createElement(
|
|
89
|
+
}, showSearchInput && /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
style: {
|
|
91
|
+
padding: 8,
|
|
92
|
+
backgroundColor: '#f7f7f7'
|
|
93
|
+
}
|
|
94
|
+
}, /*#__PURE__*/React.createElement(_Input, {
|
|
95
|
+
value: searchValue,
|
|
96
|
+
onChange: function onChange(e) {
|
|
97
|
+
return setSearchValue(e.target.value);
|
|
98
|
+
},
|
|
99
|
+
allowClear: true,
|
|
100
|
+
placeholder: "\u8F93\u5165\u5BF9\u8BDD\u5173\u952E\u8BCD\u641C\u7D22"
|
|
101
|
+
})), /*#__PURE__*/React.createElement(ChatMessageList, _extends({
|
|
102
|
+
searchValue: searchMode === 'internal' ? searchValue : undefined,
|
|
69
103
|
ref: messageListDomRef,
|
|
70
104
|
msgs: msgs,
|
|
71
105
|
h5: true,
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
white-space: break-spaces;
|
|
65
65
|
overflow: hidden;
|
|
66
66
|
max-width: 375px;
|
|
67
|
-
min-width:
|
|
67
|
+
min-width: 24px;
|
|
68
68
|
border-radius: 2px 6px 6px 6px;
|
|
69
69
|
background: #fff;
|
|
70
70
|
}
|
|
@@ -98,6 +98,9 @@
|
|
|
98
98
|
border-radius: 6px 2px 6px 6px;
|
|
99
99
|
background: #dbe6ff;
|
|
100
100
|
}
|
|
101
|
+
.@{prefix}-ref-body {
|
|
102
|
+
border-left: 3px solid #c2d4ff;
|
|
103
|
+
}
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
// 对话-H5
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _ChatMessageItem = _interopRequireDefault(require("../ChatMessageItem"));
|
|
9
10
|
var _utils = require("../utils");
|
|
10
11
|
require("./index.less");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
15
|
var LOADING_STATUS = {
|
|
13
16
|
loading: '加载中...',
|
|
14
17
|
nomore: '没有更多了~'
|
|
15
18
|
};
|
|
16
19
|
var LOAD_LIMIT = 15;
|
|
17
20
|
var ChatMessageList = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
18
|
-
var
|
|
21
|
+
var searchValue = _ref.searchValue,
|
|
22
|
+
h5 = _ref.h5,
|
|
19
23
|
msgs = _ref.msgs,
|
|
20
24
|
onScrollTop = _ref.onScrollTop,
|
|
21
25
|
onScrollBottom = _ref.onScrollBottom,
|
|
@@ -37,6 +41,13 @@ var ChatMessageList = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
37
41
|
isTop && (onScrollTop === null || onScrollTop === void 0 ? void 0 : onScrollTop(e));
|
|
38
42
|
isBottom && (onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom(e));
|
|
39
43
|
}, 200);
|
|
44
|
+
var filteredMsgs = (0, _react.useMemo)(function () {
|
|
45
|
+
return msgs.filter(function (msg) {
|
|
46
|
+
var _msg$attach, _msg$attach2;
|
|
47
|
+
return ((_msg$attach = msg.attach) === null || _msg$attach === void 0 ? void 0 : _msg$attach.type) === 'text' && (((_msg$attach2 = msg.attach) === null || _msg$attach2 === void 0 ? void 0 : _msg$attach2.content) || '').indexOf(searchValue) > -1;
|
|
48
|
+
});
|
|
49
|
+
}, [msgs, searchValue]);
|
|
50
|
+
var messagesToRender = searchValue ? filteredMsgs : msgs;
|
|
40
51
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
41
52
|
className: prefixCls,
|
|
42
53
|
style: style || {}
|
|
@@ -46,13 +57,13 @@ var ChatMessageList = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
46
57
|
onScroll: onScrollHandler
|
|
47
58
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
48
59
|
className: "".concat(prefixCls, "-status")
|
|
49
|
-
}, msgs.length < LOAD_LIMIT || !LOADING_STATUS[loadingStarus] ? null : LOADING_STATUS[loadingStarus]),
|
|
60
|
+
}, msgs.length < LOAD_LIMIT || !LOADING_STATUS[loadingStarus] ? null : LOADING_STATUS[loadingStarus]), messagesToRender.map(function (msg) {
|
|
50
61
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
51
62
|
id: msg.idServer,
|
|
52
63
|
key: msg.idServer
|
|
53
64
|
}, /*#__PURE__*/_react.default.createElement(_ChatMessageItem.default, {
|
|
54
65
|
h5: h5,
|
|
55
|
-
keyword: '',
|
|
66
|
+
keyword: searchValue || '',
|
|
56
67
|
myAccount: myAccount,
|
|
57
68
|
prefix: "".concat(prefixCls, "-item"),
|
|
58
69
|
msg: msg,
|
package/lib/GoodsCard/index.less
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _const = require("../common/const");
|
|
11
|
+
require("./index.less");
|
|
12
|
+
var _ = require("..");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
20
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
21
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
|
+
var OrderGoodsCard = function OrderGoodsCard(props) {
|
|
23
|
+
var _props$prefix = props.prefix,
|
|
24
|
+
prefix = _props$prefix === void 0 ? 'fx-chart-messages-item' : _props$prefix,
|
|
25
|
+
_props$orderSn = props.orderSn,
|
|
26
|
+
orderSn = _props$orderSn === void 0 ? '' : _props$orderSn,
|
|
27
|
+
messageId = props.messageId;
|
|
28
|
+
var _useState = (0, _react.useState)([]),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
data = _useState2[0],
|
|
31
|
+
setData = _useState2[1];
|
|
32
|
+
var _useState3 = (0, _react.useState)(false),
|
|
33
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
+
isExpand = _useState4[0],
|
|
35
|
+
setIsExpand = _useState4[1];
|
|
36
|
+
var _useContext = (0, _react.useContext)(_.ImContext),
|
|
37
|
+
api = _useContext.api;
|
|
38
|
+
(0, _react.useEffect)(function () {
|
|
39
|
+
if (orderSn && messageId) {
|
|
40
|
+
api.getOrderGoods({
|
|
41
|
+
orderSn: orderSn,
|
|
42
|
+
messageId: messageId
|
|
43
|
+
}).then(function (_ref) {
|
|
44
|
+
var data = _ref.data;
|
|
45
|
+
setData(data || []);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, [orderSn, messageId]);
|
|
49
|
+
function formatOrderPrice(item) {
|
|
50
|
+
var currencyStr = item.currencyStr || '积分';
|
|
51
|
+
if (Number(item.price || 0) > 0 && Number(item.score || 0) > 0) {
|
|
52
|
+
return "".concat(item.score).concat(currencyStr, " + ").concat(item.price, "\u5143");
|
|
53
|
+
}
|
|
54
|
+
if (Number(item.price || 0) > 0) {
|
|
55
|
+
return "".concat(item.price, "\u5143");
|
|
56
|
+
}
|
|
57
|
+
if (Number(item.score || 0) > 0) {
|
|
58
|
+
return "".concat(item.score).concat(currencyStr);
|
|
59
|
+
}
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
63
|
+
className: (0, _classnames.default)("".concat(prefix, "-order-goods"))
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
+
className: "".concat(prefix, "-order-goods-summary")
|
|
66
|
+
}, "\u60A8\u597D\uFF0C\u8BF7\u9009\u62E9\u60A8\u8981\u54A8\u8BE2\u7684\u5546\u54C1\uFF1A"), data === null || data === void 0 ? void 0 : data.slice(0, isExpand ? data === null || data === void 0 ? void 0 : data.length : 5).map(function (item, index) {
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
68
|
+
key: +index,
|
|
69
|
+
className: "".concat(prefix, "-order-goods-item")
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
+
className: "".concat(prefix, "-order-goods-item-img"),
|
|
72
|
+
style: {
|
|
73
|
+
background: "url(".concat(item.pic || _const.fallbackImg, ") 0 0 / cover no-repeat")
|
|
74
|
+
}
|
|
75
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
76
|
+
className: "".concat(prefix, "-order-goods-item-right")
|
|
77
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
78
|
+
className: "".concat(prefix, "-order-goods-item-title two-line-text")
|
|
79
|
+
}, item.title), /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
+
style: {
|
|
81
|
+
display: 'flex',
|
|
82
|
+
justifyContent: 'space-between',
|
|
83
|
+
gap: 8
|
|
84
|
+
}
|
|
85
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
86
|
+
className: "".concat(prefix, "-order-goods-item-price")
|
|
87
|
+
}, item.applicationId === 7 ? null : formatOrderPrice(item)))));
|
|
88
|
+
}), (data === null || data === void 0 ? void 0 : data.length) > 5 && /*#__PURE__*/_react.default.createElement("div", {
|
|
89
|
+
className: "".concat(prefix, "-order-goods-expand"),
|
|
90
|
+
onClick: function onClick() {
|
|
91
|
+
return setIsExpand(!isExpand);
|
|
92
|
+
}
|
|
93
|
+
}, isExpand ? '收起' : '展开全部', " ", "(".concat(data === null || data === void 0 ? void 0 : data.length, ")")));
|
|
94
|
+
};
|
|
95
|
+
var _default = exports.default = OrderGoodsCard;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@prefix: chart-messages-item;
|
|
2
|
+
|
|
3
|
+
.@{prefix}-order-goods {
|
|
4
|
+
max-width: 272px;
|
|
5
|
+
min-width: 200px;
|
|
6
|
+
padding: 12px;
|
|
7
|
+
padding-bottom: 6px;
|
|
8
|
+
&-summary {
|
|
9
|
+
margin-bottom: 8px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&-item {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-flow: row;
|
|
15
|
+
padding: 8px 0;
|
|
16
|
+
&:not(:last-child) {
|
|
17
|
+
border-bottom: 1px solid #eee;
|
|
18
|
+
}
|
|
19
|
+
&-img {
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
border-radius: 4px;
|
|
22
|
+
width: 60px;
|
|
23
|
+
height: 60px;
|
|
24
|
+
margin-right: 6px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
object-fit: fill;
|
|
27
|
+
}
|
|
28
|
+
img {
|
|
29
|
+
width: 100%;
|
|
30
|
+
object-fit: contain;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-right {
|
|
34
|
+
flex: 1;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
}
|
|
37
|
+
&-title {
|
|
38
|
+
line-height: 1.2;
|
|
39
|
+
margin-top: 2px;
|
|
40
|
+
margin-bottom: 4px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-price {
|
|
44
|
+
min-height: 14px;
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
color: #6e7789;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&-btn {
|
|
50
|
+
font-size: 12px !important;
|
|
51
|
+
padding: 0 !important;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&-expand {
|
|
56
|
+
color: var(--prc);
|
|
57
|
+
text-align: center;
|
|
58
|
+
padding-top: 8px;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -16,6 +16,7 @@ var _utils2 = require("../common/utils");
|
|
|
16
16
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
17
17
|
var _GoodsCard = _interopRequireDefault(require("../GoodsCard"));
|
|
18
18
|
var _GoodsOrderCard = _interopRequireDefault(require("../GoodsOrderCard"));
|
|
19
|
+
var _OrderGoodsCard = _interopRequireDefault(require("../OrderGoodsCard"));
|
|
19
20
|
var _2 = require("..");
|
|
20
21
|
var _audioAndVideoTool = require("../audioAndVideoTool");
|
|
21
22
|
var _AudioPlayer = _interopRequireDefault(require("./AudioPlayer"));
|
|
@@ -115,7 +116,7 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
115
116
|
className: "".concat(prefix, "-ref-audio-body")
|
|
116
117
|
}, /*#__PURE__*/_react.default.createElement(_AudioPlayer.default, {
|
|
117
118
|
style: {
|
|
118
|
-
backgroundColor: '#
|
|
119
|
+
backgroundColor: msg.flow === 'in' ? '#f7f7f7' : 'rgba(255, 255, 255, 0.5)',
|
|
119
120
|
borderRadius: 4,
|
|
120
121
|
width: 80
|
|
121
122
|
},
|
|
@@ -333,7 +334,6 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
333
334
|
return null;
|
|
334
335
|
};
|
|
335
336
|
var renderAudio = function renderAudio() {
|
|
336
|
-
var flow = msg.flow;
|
|
337
337
|
var duration = Math.floor(attach.content.dur) || 0;
|
|
338
338
|
return /*#__PURE__*/_react.default.createElement(_AudioPlayer.default, {
|
|
339
339
|
prefix: prefix || '',
|
|
@@ -391,7 +391,11 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
391
391
|
href: (0, _utils.addUrlSearch)(attach.content.url, "download=".concat(attach.content.fileName)),
|
|
392
392
|
target: "_blank",
|
|
393
393
|
rel: "noreferrer"
|
|
394
|
-
}, attach.content.fileName), /*#__PURE__*/_react.default.createElement("span",
|
|
394
|
+
}, attach.content.fileName), /*#__PURE__*/_react.default.createElement("span", {
|
|
395
|
+
style: {
|
|
396
|
+
fontSize: 12
|
|
397
|
+
}
|
|
398
|
+
}, (0, _utils.parseFileSize)(attach.content.size))));
|
|
395
399
|
};
|
|
396
400
|
var renderOrderCard = function renderOrderCard() {
|
|
397
401
|
var _attach$content8, _attach$content9;
|
|
@@ -408,11 +412,19 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
408
412
|
content: attach.content || {}
|
|
409
413
|
});
|
|
410
414
|
};
|
|
415
|
+
var renderOrderGoods = function renderOrderGoods() {
|
|
416
|
+
var _attach$content10;
|
|
417
|
+
return /*#__PURE__*/_react.default.createElement(_OrderGoodsCard.default, {
|
|
418
|
+
prefix: prefix,
|
|
419
|
+
orderSn: (_attach$content10 = attach.content) === null || _attach$content10 === void 0 ? void 0 : _attach$content10.orderSn,
|
|
420
|
+
messageId: msg.idClient
|
|
421
|
+
});
|
|
422
|
+
};
|
|
411
423
|
var renderChartRecord = function renderChartRecord() {
|
|
412
|
-
var _attach$
|
|
413
|
-
var records = ((_attach$
|
|
414
|
-
var msgIds = ((_attach$
|
|
415
|
-
var title = (_attach$
|
|
424
|
+
var _attach$content11, _attach$content12, _attach$content13;
|
|
425
|
+
var records = ((_attach$content11 = attach.content) === null || _attach$content11 === void 0 ? void 0 : _attach$content11.items) || [];
|
|
426
|
+
var msgIds = ((_attach$content12 = attach.content) === null || _attach$content12 === void 0 ? void 0 : _attach$content12.msgIds) || [];
|
|
427
|
+
var title = (_attach$content13 = attach.content) === null || _attach$content13 === void 0 ? void 0 : _attach$content13.title;
|
|
416
428
|
var list = records.filter(function (v) {
|
|
417
429
|
var _v$attach;
|
|
418
430
|
return ![_const.imMsgTypes.event].includes((_v$attach = v.attach) === null || _v$attach === void 0 ? void 0 : _v$attach.type);
|
|
@@ -443,10 +455,10 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
443
455
|
})), "\u7CFB\u7EDF\u8F6C\u53D1"));
|
|
444
456
|
};
|
|
445
457
|
var renderOfflineSupport = function renderOfflineSupport() {
|
|
446
|
-
var _attach$
|
|
458
|
+
var _attach$content14, _attach$content15;
|
|
447
459
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
448
460
|
className: "".concat(prefix, "-text")
|
|
449
|
-
}, (_attach$
|
|
461
|
+
}, (_attach$content14 = attach.content) === null || _attach$content14 === void 0 ? void 0 : _attach$content14.supportDesc, ((_attach$content15 = attach.content) === null || _attach$content15 === void 0 ? void 0 : _attach$content15.contact) && /*#__PURE__*/_react.default.createElement("a", {
|
|
450
462
|
href: "tel:".concat(attach.content.contact),
|
|
451
463
|
rel: "noreferrer"
|
|
452
464
|
}, attach.content.contact));
|
|
@@ -482,6 +494,8 @@ var ParseSession = function ParseSession(_ref) {
|
|
|
482
494
|
return renderChartRecord();
|
|
483
495
|
case _const.imMsgTypes.offlineSupport:
|
|
484
496
|
return renderOfflineSupport();
|
|
497
|
+
case _const.imMsgTypes.orderGoods:
|
|
498
|
+
return renderOrderGoods();
|
|
485
499
|
default:
|
|
486
500
|
return '';
|
|
487
501
|
}
|
package/lib/api/index.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ interface ApiMethods {
|
|
|
25
25
|
getContact: (params: {
|
|
26
26
|
msgId?: string;
|
|
27
27
|
}) => Promise<any>;
|
|
28
|
+
getOrderGoods: (data: {
|
|
29
|
+
orderSn?: any;
|
|
30
|
+
messageId?: string;
|
|
31
|
+
}) => Promise<any>;
|
|
28
32
|
}
|
|
29
33
|
export declare const apiCreate: (_env?: Env, token?: string) => ApiMethods;
|
|
30
34
|
export {};
|
package/lib/api/index.js
CHANGED
|
@@ -45,6 +45,10 @@ var apiCreate = exports.apiCreate = function apiCreate(_env, token) {
|
|
|
45
45
|
getCSOrder: function getCSOrder(data) {
|
|
46
46
|
return service.post('/ll/provider/message/order/get', data);
|
|
47
47
|
},
|
|
48
|
+
// 获取订单商品信息
|
|
49
|
+
getOrderGoods: function getOrderGoods(data) {
|
|
50
|
+
return service.post('/ll/provider/message/after-sales-agent/goods/list', data);
|
|
51
|
+
},
|
|
48
52
|
// 获取联系人信息(表单)
|
|
49
53
|
getContact: function getContact(params) {
|
|
50
54
|
return service.get('/ll/provider/message/contact/get', {
|
package/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,10 @@ import './styles/index.less';
|
|
|
8
8
|
* @description 代码由小鲤客服平台搬运简来.
|
|
9
9
|
*/
|
|
10
10
|
export interface IMRecordProps {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 数据对应的环境
|
|
13
|
+
*/
|
|
14
|
+
env: Env;
|
|
12
15
|
token?: string;
|
|
13
16
|
h5?: boolean;
|
|
14
17
|
msgs: IMMessage[];
|
|
@@ -19,6 +22,16 @@ export interface IMRecordProps {
|
|
|
19
22
|
style?: React.CSSProperties;
|
|
20
23
|
isSessionEnd?: boolean;
|
|
21
24
|
recordSession?: RecordSession;
|
|
25
|
+
/**是否显示搜索输入框 默认为false*/
|
|
26
|
+
showSearchInput?: boolean;
|
|
27
|
+
/**搜索事件,对外抛出搜索关键字*/
|
|
28
|
+
onSearch?: (keyword: string) => void;
|
|
29
|
+
/**搜索模式
|
|
30
|
+
* internal: 内部搜索 只对输入到组件内部的msgs进行搜索
|
|
31
|
+
* external: 外部搜索 只对外抛出搜索关键字,在外部搜索,从而改变输入到组件的msgs
|
|
32
|
+
* 默认为internal
|
|
33
|
+
*/
|
|
34
|
+
searchMode?: 'internal' | 'external';
|
|
22
35
|
}
|
|
23
36
|
export interface ImContextProps {
|
|
24
37
|
api: ReturnType<typeof apiCreate>;
|
package/lib/index.js
CHANGED
|
@@ -8,8 +8,9 @@ exports.default = exports.ImContext = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _ChatMessageList = _interopRequireDefault(require("./ChatMessageList"));
|
|
10
10
|
var _api = require("./api");
|
|
11
|
+
var _antd = require("antd");
|
|
11
12
|
require("./styles/index.less");
|
|
12
|
-
var _excluded = ["env", "token", "msgs", "recordSession"];
|
|
13
|
+
var _excluded = ["env", "token", "msgs", "recordSession", "showSearchInput", "searchMode", "onSearch"];
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -37,12 +38,21 @@ var IMRecord = function IMRecord(_ref) {
|
|
|
37
38
|
token = _ref.token,
|
|
38
39
|
msgs = _ref.msgs,
|
|
39
40
|
recordSession = _ref.recordSession,
|
|
41
|
+
_ref$showSearchInput = _ref.showSearchInput,
|
|
42
|
+
showSearchInput = _ref$showSearchInput === void 0 ? false : _ref$showSearchInput,
|
|
43
|
+
_ref$searchMode = _ref.searchMode,
|
|
44
|
+
searchMode = _ref$searchMode === void 0 ? 'internal' : _ref$searchMode,
|
|
45
|
+
onSearch = _ref.onSearch,
|
|
40
46
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
41
47
|
var api = (0, _api.apiCreate)(env, token);
|
|
42
48
|
var _useState = (0, _react.useState)({}),
|
|
43
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
50
|
accountsMap = _useState2[0],
|
|
45
51
|
setAccountsMap = _useState2[1];
|
|
52
|
+
var _useState3 = (0, _react.useState)(),
|
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
54
|
+
searchValue = _useState4[0],
|
|
55
|
+
setSearchValue = _useState4[1];
|
|
46
56
|
var messageListDomRef = (0, _react.useRef)(null);
|
|
47
57
|
(0, _react.useEffect)(function () {
|
|
48
58
|
var accids = _toConsumableArray(new Set(msgs.map(function (x) {
|
|
@@ -52,6 +62,16 @@ var IMRecord = function IMRecord(_ref) {
|
|
|
52
62
|
getAccountByAccids(accids);
|
|
53
63
|
}
|
|
54
64
|
}, [msgs]);
|
|
65
|
+
(0, _react.useEffect)(function () {
|
|
66
|
+
var handler = setTimeout(function () {
|
|
67
|
+
if (onSearch && searchValue !== undefined) {
|
|
68
|
+
onSearch(searchValue); // 仅在external模式下触发onSearch
|
|
69
|
+
}
|
|
70
|
+
}, 300); // 300ms的防抖时间,可以根据需要调整
|
|
71
|
+
return function () {
|
|
72
|
+
clearTimeout(handler); // 清除上一次的定时器
|
|
73
|
+
};
|
|
74
|
+
}, [searchValue, searchMode, onSearch]);
|
|
55
75
|
function getAccountByAccids(accids) {
|
|
56
76
|
api.getAccountInfoByAccid({
|
|
57
77
|
accids: accids
|
|
@@ -74,7 +94,20 @@ var IMRecord = function IMRecord(_ref) {
|
|
|
74
94
|
value: {
|
|
75
95
|
api: api
|
|
76
96
|
}
|
|
77
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
97
|
+
}, showSearchInput && /*#__PURE__*/_react.default.createElement("div", {
|
|
98
|
+
style: {
|
|
99
|
+
padding: 8,
|
|
100
|
+
backgroundColor: '#f7f7f7'
|
|
101
|
+
}
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Input, {
|
|
103
|
+
value: searchValue,
|
|
104
|
+
onChange: function onChange(e) {
|
|
105
|
+
return setSearchValue(e.target.value);
|
|
106
|
+
},
|
|
107
|
+
allowClear: true,
|
|
108
|
+
placeholder: "\u8F93\u5165\u5BF9\u8BDD\u5173\u952E\u8BCD\u641C\u7D22"
|
|
109
|
+
})), /*#__PURE__*/_react.default.createElement(_ChatMessageList.default, _extends({
|
|
110
|
+
searchValue: searchMode === 'internal' ? searchValue : undefined,
|
|
78
111
|
ref: messageListDomRef,
|
|
79
112
|
msgs: msgs,
|
|
80
113
|
h5: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fle-ui/plus-im-record",
|
|
3
|
-
"version": "0.0.8-beta.
|
|
3
|
+
"version": "0.0.8-beta.4",
|
|
4
4
|
"description": "@fle-ui/plus-im-record",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fle-ui",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=17.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "78d824169602d37feb9b5a79180d91f31a381814"
|
|
49
49
|
}
|