@fle-ui/plus-im-record 0.0.8-beta.0 → 0.0.8-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/es/@types/index.d.ts +620 -0
  2. package/es/CardTag/index.d.ts +3 -0
  3. package/es/CardTag/index.js +18 -0
  4. package/es/ChatMessageItem/index.d.ts +15 -0
  5. package/es/ChatMessageItem/index.js +130 -0
  6. package/es/ChatMessageItem/index.less +108 -0
  7. package/es/ChatMessageList/index.d.ts +29 -0
  8. package/es/ChatMessageList/index.js +66 -0
  9. package/es/ChatMessageList/index.less +34 -0
  10. package/es/GoodsCard/index.d.ts +15 -0
  11. package/es/GoodsCard/index.js +95 -0
  12. package/es/GoodsCard/index.less +49 -0
  13. package/es/GoodsOrderCard/index.d.ts +14 -0
  14. package/es/GoodsOrderCard/index.js +161 -0
  15. package/es/GoodsOrderCard/index.less +81 -0
  16. package/es/Icon/index.d.ts +8 -0
  17. package/es/Icon/index.js +11 -0
  18. package/es/ParseSession/AudioPlayer.d.ts +14 -0
  19. package/es/ParseSession/AudioPlayer.js +89 -0
  20. package/es/ParseSession/audioAndVideoTool.d.ts +3 -0
  21. package/es/ParseSession/audioAndVideoTool.js +21 -0
  22. package/es/ParseSession/index.d.ts +15 -0
  23. package/es/ParseSession/index.js +492 -0
  24. package/es/ParseSession/index.less +226 -0
  25. package/es/api/index.d.ts +30 -0
  26. package/es/api/index.js +48 -0
  27. package/es/audioAndVideoTool.d.ts +3 -0
  28. package/es/audioAndVideoTool.js +21 -0
  29. package/es/common/const/index.d.ts +46 -0
  30. package/es/common/const/index.js +82 -0
  31. package/es/common/utils/index.d.ts +33 -0
  32. package/es/common/utils/index.js +169 -0
  33. package/es/index.d.ts +38 -0
  34. package/es/index.js +111 -0
  35. package/es/styles/extends.less +50 -0
  36. package/es/styles/index.less +35 -0
  37. package/es/styles/vars.less +8 -0
  38. package/es/utils/index.d.ts +14 -0
  39. package/es/utils/index.js +50 -0
  40. package/lib/@types/index.d.ts +620 -0
  41. package/lib/CardTag/index.d.ts +3 -0
  42. package/lib/CardTag/index.js +25 -0
  43. package/lib/ChatMessageItem/index.d.ts +15 -0
  44. package/lib/ChatMessageItem/index.js +136 -0
  45. package/lib/ChatMessageItem/index.less +108 -0
  46. package/lib/ChatMessageList/index.d.ts +29 -0
  47. package/lib/ChatMessageList/index.js +76 -0
  48. package/lib/ChatMessageList/index.less +34 -0
  49. package/lib/GoodsCard/index.d.ts +15 -0
  50. package/lib/GoodsCard/index.js +105 -0
  51. package/lib/GoodsCard/index.less +49 -0
  52. package/lib/GoodsOrderCard/index.d.ts +14 -0
  53. package/lib/GoodsOrderCard/index.js +169 -0
  54. package/lib/GoodsOrderCard/index.less +81 -0
  55. package/lib/Icon/index.d.ts +8 -0
  56. package/lib/Icon/index.js +18 -0
  57. package/lib/ParseSession/AudioPlayer.d.ts +14 -0
  58. package/lib/ParseSession/AudioPlayer.js +98 -0
  59. package/lib/ParseSession/audioAndVideoTool.d.ts +3 -0
  60. package/lib/ParseSession/audioAndVideoTool.js +27 -0
  61. package/lib/ParseSession/index.d.ts +15 -0
  62. package/lib/ParseSession/index.js +494 -0
  63. package/lib/ParseSession/index.less +226 -0
  64. package/lib/api/index.d.ts +30 -0
  65. package/lib/api/index.js +55 -0
  66. package/lib/audioAndVideoTool.d.ts +3 -0
  67. package/lib/audioAndVideoTool.js +27 -0
  68. package/lib/common/const/index.d.ts +46 -0
  69. package/lib/common/const/index.js +88 -0
  70. package/lib/common/utils/index.d.ts +33 -0
  71. package/lib/common/utils/index.js +183 -0
  72. package/lib/index.d.ts +38 -0
  73. package/lib/index.js +119 -0
  74. package/lib/styles/extends.less +50 -0
  75. package/lib/styles/index.less +35 -0
  76. package/lib/styles/vars.less +8 -0
  77. package/lib/utils/index.d.ts +14 -0
  78. package/lib/utils/index.js +56 -0
  79. package/package.json +2 -2
@@ -0,0 +1,130 @@
1
+ import "antd/es/avatar/style";
2
+ import _Avatar from "antd/es/avatar";
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
+ 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
+ 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; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ import React from 'react';
10
+ import dayjs from 'dayjs';
11
+ import classNames from 'classnames';
12
+ import ParseSession from '../ParseSession';
13
+ import Icon from '../Icon';
14
+ import { defaultAvatar, imMsgTypes, msgEventTypes } from '../common/const';
15
+ import { paserAttach } from '../common/utils';
16
+ import './index.less';
17
+ var ChatMessageItem = function ChatMessageItem(_ref) {
18
+ var h5 = _ref.h5,
19
+ msg = _ref.msg,
20
+ prefix = _ref.prefix,
21
+ _ref$myAccount = _ref.myAccount,
22
+ myAccount = _ref$myAccount === void 0 ? '' : _ref$myAccount,
23
+ keyword = _ref.keyword,
24
+ _ref$accountInfo = _ref.accountInfo,
25
+ accountInfo = _ref$accountInfo === void 0 ? {} : _ref$accountInfo,
26
+ isSessionEnd = _ref.isSessionEnd,
27
+ recordSession = _ref.recordSession;
28
+ var paserMsg = _objectSpread(_objectSpread({}, msg), {}, {
29
+ attach: paserAttach(msg.attach || {})
30
+ });
31
+ var from = paserMsg.from,
32
+ _paserMsg$attach = paserMsg.attach,
33
+ attach = _paserMsg$attach === void 0 ? {} : _paserMsg$attach,
34
+ idClient = paserMsg.idClient,
35
+ time = paserMsg.time,
36
+ type = paserMsg.type,
37
+ flow = paserMsg.flow;
38
+ var isRecall = ['recall'].includes(type);
39
+ var isEvent = [imMsgTypes.event].includes(attach === null || attach === void 0 ? void 0 : attach.type);
40
+ var isTip = [imMsgTypes.tip].includes(attach === null || attach === void 0 ? void 0 : attach.type);
41
+ var isNotification = type === 'notification';
42
+ var isSelf = myAccount ? from === myAccount : flow === 'out';
43
+ var renderMsgDate = function renderMsgDate() {
44
+ var date = dayjs(time);
45
+ var isCurrentDay = date.isSame(dayjs(), 'day');
46
+ var isCurrentYear = date.isSame(dayjs(), 'year');
47
+ // eslint-disable-next-line no-nested-ternary
48
+ return isCurrentDay ? date.format('HH:mm:ss') : isCurrentYear ? date.format('MM-DD HH:mm:ss') : date.format('YYYY-MM-DD HH:mm:ss');
49
+ };
50
+ var renderRecallMsg = function renderRecallMsg() {
51
+ return /*#__PURE__*/React.createElement("div", {
52
+ key: idClient,
53
+ className: "".concat(prefix, "-tip")
54
+ }, "".concat(isSelf ? '您' : '用户', "\u64A4\u56DE\u4E86\u4E00\u6761\u4FE1\u606F"));
55
+ };
56
+ var renderEventMsg = function renderEventMsg() {
57
+ var _attach$content;
58
+ var isCloseEvent = [msgEventTypes.csClose, msgEventTypes.sysClose, msgEventTypes.userClose].includes((_attach$content = attach.content) === null || _attach$content === void 0 ? void 0 : _attach$content.eventType);
59
+ return attach.content.tips ? /*#__PURE__*/React.createElement("div", {
60
+ key: idClient,
61
+ className: classNames("".concat(prefix, "-tip"), {
62
+ 'is-close': isCloseEvent
63
+ })
64
+ }, /*#__PURE__*/React.createElement("span", null, attach.content.tips)) : /*#__PURE__*/React.createElement(React.Fragment, null);
65
+ };
66
+ var renderTipMsg = function renderTipMsg() {
67
+ return /*#__PURE__*/React.createElement("div", {
68
+ key: idClient,
69
+ className: "".concat(prefix, "-tip")
70
+ }, /*#__PURE__*/React.createElement("span", null, attach.content));
71
+ };
72
+ function renderCenterMsg() {
73
+ if (isRecall) return renderRecallMsg();
74
+ if (isTip) return renderTipMsg();
75
+ if (isEvent) return renderEventMsg();
76
+ if (isNotification) {
77
+ /*#__PURE__*/React.createElement(ParseSession, {
78
+ msg: paserMsg,
79
+ prefix: "".concat(prefix)
80
+ });
81
+ }
82
+ return null;
83
+ }
84
+ function renderContent() {
85
+ return /*#__PURE__*/React.createElement("div", {
86
+ className: "".concat(prefix, "-box")
87
+ }, /*#__PURE__*/React.createElement("div", {
88
+ className: classNames("".concat(prefix, "-date"), _defineProperty({}, "".concat(prefix, "-date-self"), isSelf))
89
+ }, renderMsgDate()), /*#__PURE__*/React.createElement("div", {
90
+ className: "".concat(prefix, "-body"),
91
+ style: {
92
+ background: [imMsgTypes.video, imMsgTypes.order, imMsgTypes.product].includes(attach.type) ? 'transparent' : ''
93
+ }
94
+ }, /*#__PURE__*/React.createElement(ParseSession, {
95
+ h5: h5,
96
+ keyword: keyword,
97
+ msg: paserMsg,
98
+ prefix: "".concat(prefix),
99
+ recordSession: recordSession,
100
+ isSessionEnd: isSessionEnd
101
+ })), isSelf && myAccount && /*#__PURE__*/React.createElement("span", {
102
+ className: classNames("".concat(prefix, "-read"), {
103
+ isRead: msg.readByOtherUser
104
+ })
105
+ }, msg.readByOtherUser ? '已读' : '未读'));
106
+ }
107
+ return renderCenterMsg() || /*#__PURE__*/React.createElement("div", {
108
+ className: classNames(prefix, {
109
+ self: isSelf,
110
+ h5: h5
111
+ })
112
+ }, [imMsgTypes.chatrecord].includes(attach.type) ? /*#__PURE__*/React.createElement(_Avatar, {
113
+ size: 36,
114
+ style: {
115
+ backgroundColor: '#2c6bff',
116
+ verticalAlign: 'middle'
117
+ },
118
+ icon: /*#__PURE__*/React.createElement(Icon, {
119
+ type: 'icon-kefu',
120
+ style: {
121
+ fontSize: 24,
122
+ color: '#fff'
123
+ }
124
+ })
125
+ }) : /*#__PURE__*/React.createElement(_Avatar, {
126
+ size: 36,
127
+ src: accountInfo.avatar || defaultAvatar
128
+ }), renderContent());
129
+ };
130
+ export default ChatMessageItem;
@@ -0,0 +1,108 @@
1
+ @prefix: chart-messages-item;
2
+
3
+ .tipText() {
4
+ text-align: center;
5
+ font-size: 12px;
6
+ color: #999;
7
+ padding: 8px 56px;
8
+ span {
9
+ display: inline-block;
10
+ padding: 3px 8px;
11
+ border-radius: 4px;
12
+ background-color: #fff;
13
+ }
14
+ }
15
+
16
+ // 对话
17
+ .@{prefix} {
18
+ display: flex;
19
+ padding: 8px;
20
+ // margin-bottom: 16px;
21
+ .ant-avatar {
22
+ border-radius: 50%;
23
+ margin-top: 20px;
24
+ margin-right: 8px;
25
+ }
26
+
27
+ &-recall {
28
+ .tipText();
29
+ }
30
+
31
+ &-tip {
32
+ .tipText();
33
+ display: flex;
34
+ justify-content: center;
35
+ align-items: center;
36
+ &.is-close {
37
+ &::before,
38
+ &::after {
39
+ display: block;
40
+ flex: 1;
41
+ content: '';
42
+ height: 1px;
43
+ width: 100%;
44
+ background-color: #ddd;
45
+ }
46
+ }
47
+ span {
48
+ margin: 0 10px;
49
+ flex-shrink: 0;
50
+ }
51
+ }
52
+
53
+ &-box {
54
+ position: relative;
55
+ display: flex;
56
+ flex-direction: column;
57
+ align-items: flex-start;
58
+ }
59
+
60
+ &-body {
61
+ position: relative;
62
+ word-break: break-all;
63
+ word-wrap: break-word;
64
+ white-space: break-spaces;
65
+ overflow: hidden;
66
+ max-width: 375px;
67
+ min-width: 50px;
68
+ border-radius: 2px 6px 6px 6px;
69
+ background: #fff;
70
+ }
71
+ &-read {
72
+ display: block;
73
+ border-radius: 50%;
74
+ font-size: 12px;
75
+ color: #aaa;
76
+ transform: scale(0.85);
77
+ }
78
+ &-date {
79
+ font-size: 12px;
80
+ color: #aaa;
81
+ margin-bottom: 4px;
82
+ }
83
+ }
84
+ // 对话-自己
85
+ .@{prefix}.self {
86
+ flex-direction: row-reverse;
87
+
88
+ .ant-avatar {
89
+ margin-right: 0;
90
+ margin-left: 12px;
91
+ }
92
+
93
+ .@{prefix}-box {
94
+ align-items: flex-end;
95
+ }
96
+
97
+ .@{prefix}-body {
98
+ border-radius: 6px 2px 6px 6px;
99
+ background: #dbe6ff;
100
+ }
101
+ }
102
+
103
+ // 对话-H5
104
+ .@{prefix}.h5 {
105
+ .@{prefix}-body {
106
+ max-width: 276px;
107
+ }
108
+ }
@@ -0,0 +1,29 @@
1
+ import React, { UIEventHandler } from 'react';
2
+ import { IMMessage } from '../@types';
3
+ import './index.less';
4
+ declare const LOADING_STATUS: any;
5
+ export type LoadingStatus = keyof typeof LOADING_STATUS | undefined;
6
+ export interface RecordSession {
7
+ relationId?: string | number;
8
+ accid?: string;
9
+ relationType?: number;
10
+ }
11
+ export interface ChatMessageListProps {
12
+ searchValue?: string;
13
+ h5?: boolean;
14
+ msgs: IMMessage[];
15
+ myAccount?: string;
16
+ loadingStarus?: LoadingStatus;
17
+ onScrollTop?: UIEventHandler<HTMLDivElement>;
18
+ onScrollBottom?: UIEventHandler<HTMLDivElement>;
19
+ accountsMap?: Record<string, {
20
+ accid: string;
21
+ nickname: string;
22
+ avatar: string;
23
+ }>;
24
+ style?: React.CSSProperties;
25
+ isSessionEnd?: boolean;
26
+ recordSession?: RecordSession;
27
+ }
28
+ declare const ChatMessageList: React.ForwardRefExoticComponent<ChatMessageListProps & React.RefAttributes<HTMLDivElement>>;
29
+ export default ChatMessageList;
@@ -0,0 +1,66 @@
1
+ import React, { useMemo } from 'react';
2
+ import ChatMessageItem from '../ChatMessageItem';
3
+ import { debounce } from '../utils';
4
+ import './index.less';
5
+ var LOADING_STATUS = {
6
+ loading: '加载中...',
7
+ nomore: '没有更多了~'
8
+ };
9
+ var LOAD_LIMIT = 15;
10
+ var ChatMessageList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11
+ var searchValue = _ref.searchValue,
12
+ h5 = _ref.h5,
13
+ msgs = _ref.msgs,
14
+ onScrollTop = _ref.onScrollTop,
15
+ onScrollBottom = _ref.onScrollBottom,
16
+ _ref$loadingStarus = _ref.loadingStarus,
17
+ loadingStarus = _ref$loadingStarus === void 0 ? '' : _ref$loadingStarus,
18
+ myAccount = _ref.myAccount,
19
+ style = _ref.style,
20
+ recordSession = _ref.recordSession,
21
+ _ref$accountsMap = _ref.accountsMap,
22
+ accountsMap = _ref$accountsMap === void 0 ? {} : _ref$accountsMap,
23
+ _ref$isSessionEnd = _ref.isSessionEnd,
24
+ isSessionEnd = _ref$isSessionEnd === void 0 ? false : _ref$isSessionEnd;
25
+ var prefixCls = "chart-messages";
26
+ var onScrollHandler = debounce(function (e) {
27
+ var scrollElRef = ref;
28
+ if (!(scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current)) return;
29
+ var isBottom = scrollElRef.current.scrollTop >= scrollElRef.current.scrollHeight - scrollElRef.current.clientHeight - 20;
30
+ var isTop = scrollElRef.current.scrollTop < 20;
31
+ isTop && (onScrollTop === null || onScrollTop === void 0 ? void 0 : onScrollTop(e));
32
+ isBottom && (onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom(e));
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;
41
+ return /*#__PURE__*/React.createElement("div", {
42
+ className: prefixCls,
43
+ style: style || {}
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ ref: ref,
46
+ className: "".concat(prefixCls, "-content scrollmini"),
47
+ onScroll: onScrollHandler
48
+ }, /*#__PURE__*/React.createElement("div", {
49
+ className: "".concat(prefixCls, "-status")
50
+ }, msgs.length < LOAD_LIMIT || !LOADING_STATUS[loadingStarus] ? null : LOADING_STATUS[loadingStarus]), messagesToRender.map(function (msg) {
51
+ return /*#__PURE__*/React.createElement("div", {
52
+ id: msg.idServer,
53
+ key: msg.idServer
54
+ }, /*#__PURE__*/React.createElement(ChatMessageItem, {
55
+ h5: h5,
56
+ keyword: searchValue || '',
57
+ myAccount: myAccount,
58
+ prefix: "".concat(prefixCls, "-item"),
59
+ msg: msg,
60
+ isSessionEnd: isSessionEnd,
61
+ recordSession: recordSession,
62
+ accountInfo: accountsMap[msg.from] || {}
63
+ }));
64
+ })));
65
+ });
66
+ export default ChatMessageList;
@@ -0,0 +1,34 @@
1
+ @prefix: chart;
2
+
3
+ .@{prefix}-messages {
4
+ width: 100%;
5
+ height: 100%;
6
+ position: relative;
7
+ overflow: hidden;
8
+ display: flex;
9
+ flex-direction: column;
10
+ padding-bottom: constant(safe-area-inset-bottom);
11
+ padding-bottom: env(safe-area-inset-bottom);
12
+ line-height: 1.2;
13
+ background-color: #f7f7f7;
14
+
15
+ &-input {
16
+ padding: 16px;
17
+ border-bottom: 1px solid #fff;
18
+ }
19
+
20
+ &-status {
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ color: #ddd;
25
+ padding: 5px;
26
+ }
27
+
28
+ &-content {
29
+ flex: 1;
30
+ width: 100%;
31
+ overflow: auto;
32
+ position: relative;
33
+ }
34
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ declare const OrderCard: React.FC<{
4
+ prefix?: string;
5
+ suspend?: boolean;
6
+ onSend?: Function;
7
+ onClose?: Function;
8
+ content: {
9
+ productId: any;
10
+ relationId?: any;
11
+ relationType?: any;
12
+ orderProductId?: number;
13
+ };
14
+ }>;
15
+ export default OrderCard;
@@ -0,0 +1,95 @@
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, useMemo, useState } from 'react';
8
+ import { cardTagMap, fallbackImg } from '../common/const';
9
+ import CardTag from '../CardTag';
10
+ import { ImContext } from '..';
11
+ import { fitUrl } from '../GoodsOrderCard';
12
+ import './index.less';
13
+ var OrderCard = function OrderCard(props) {
14
+ var _props$prefix = props.prefix,
15
+ prefix = _props$prefix === void 0 ? 'chart-messages-item' : _props$prefix,
16
+ content = props.content;
17
+ var productId = content.productId,
18
+ relationId = content.relationId,
19
+ relationType = content.relationType,
20
+ orderProductId = content.orderProductId;
21
+ var _useState = useState({}),
22
+ _useState2 = _slicedToArray(_useState, 2),
23
+ data = _useState2[0],
24
+ setData = _useState2[1];
25
+ var _useContext = useContext(ImContext),
26
+ api = _useContext.api;
27
+ useEffect(function () {
28
+ if (productId) {
29
+ api.getProductById({
30
+ productId: productId,
31
+ relationId: relationId,
32
+ relationType: relationType,
33
+ orderProductId: orderProductId
34
+ }).then(function (_ref) {
35
+ var data = _ref.data;
36
+ setData(data || {});
37
+ });
38
+ }
39
+ }, [productId]);
40
+ function onCardClick() {
41
+ // 现金
42
+ // https://cash.koudaiqifu.cn/1002855/product/product_info/87764307
43
+ // 积分
44
+ // https://jifen.koudaiqifu.cn/1003406/product/product_info/87799942
45
+ // https://jifen.koudaiqifu.cn/pcweb/goodsDetail/87876999
46
+ // 卡券
47
+ // http://cardjs.ufuly.cn/index.html#/8JmeYWGzdyI=/productDetail/87752904
48
+ // 1 积分 6 现金 7 礼包卡券
49
+ if (data.applicationId === 7) {
50
+ var _data$siteUrl;
51
+ if ((_data$siteUrl = data.siteUrl) === null || _data$siteUrl === void 0 ? void 0 : _data$siteUrl.includes('/display')) {
52
+ var url = fitUrl(data.siteUrl).replace('/display', "/productDetail/".concat(productId));
53
+ window.open(url, '_blank');
54
+ }
55
+ } else if (data.siteUrl) {
56
+ window.open("".concat(fitUrl(data.siteUrl), "/product/product_info/").concat(productId), '_blank');
57
+ }
58
+ }
59
+ var formatPrice = useMemo(function () {
60
+ if (data.priceType === 2) {
61
+ if (data.priceRangeMin && data.priceRangeMax) {
62
+ return "".concat(data.priceRangeMin, "-").concat(data.priceRangeMax, "\u5143");
63
+ }
64
+ return "".concat(data.price, "\u5143");
65
+ }
66
+ if (data.priceType === 1) {
67
+ var currencyStr = data.currencyStr || '积分';
68
+ if (data.minIntegralPrice && data.maxIntegralPrice && data.minIntegralPrice !== data.maxIntegralPrice) {
69
+ return "".concat(data.minIntegralPrice, "-").concat(data.maxIntegralPrice).concat(currencyStr);
70
+ }
71
+ return "".concat(data.integralPrice).concat(currencyStr);
72
+ }
73
+ return '';
74
+ }, [data]);
75
+ return /*#__PURE__*/React.createElement("div", {
76
+ className: "".concat(prefix, "-goods"),
77
+ onClick: function onClick() {
78
+ return onCardClick();
79
+ }
80
+ }, /*#__PURE__*/React.createElement("div", {
81
+ className: "".concat(prefix, "-goods-info")
82
+ }, /*#__PURE__*/React.createElement("div", {
83
+ className: "".concat(prefix, "-goods-info-img"),
84
+ style: {
85
+ background: "url(".concat(data.pic || fallbackImg, ") 0 0 / cover no-repeat")
86
+ }
87
+ }), /*#__PURE__*/React.createElement("div", {
88
+ className: "".concat(prefix, "-goods-info-right")
89
+ }, /*#__PURE__*/React.createElement("div", {
90
+ className: "one-line-text"
91
+ }, data.title), data.applicationId === 7 ? null : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
92
+ className: "".concat(prefix, "-goods-info-price")
93
+ }, formatPrice)), /*#__PURE__*/React.createElement("div", null, data.supplierType && cardTagMap[data.supplierType] && /*#__PURE__*/React.createElement(CardTag, cardTagMap[data.supplierType])))));
94
+ };
95
+ export default OrderCard;
@@ -0,0 +1,49 @@
1
+ @prefix: chart-messages-item;
2
+
3
+ .@{prefix}-goods {
4
+ max-width: 272px;
5
+ padding-bottom: 2px;
6
+ &-info {
7
+ display: flex;
8
+ flex-flow: row;
9
+ padding: 12px;
10
+ cursor: pointer;
11
+ border-radius: 4px;
12
+ background-color: #fff;
13
+ &-img {
14
+ flex-shrink: 0;
15
+ border-radius: 3px;
16
+ width: 72px;
17
+ height: 72px;
18
+ margin-right: 6px;
19
+ overflow: hidden;
20
+ object-fit: fill;
21
+ }
22
+ img {
23
+ width: 100%;
24
+ object-fit: contain;
25
+ }
26
+
27
+ &-right {
28
+ flex: 1;
29
+ overflow: hidden;
30
+ }
31
+
32
+ &-price {
33
+ font-size: 12px;
34
+ font-weight: 600;
35
+ color: #e10b19;
36
+ }
37
+ }
38
+
39
+ &-tip {
40
+ margin-top: 5px;
41
+ height: 24px;
42
+ padding-left: 5px;
43
+ line-height: 24px;
44
+ background: rgba(225, 11, 25, 0.06);
45
+ border-radius: 4px;
46
+ color: #e10b19;
47
+ font-size: 12px;
48
+ }
49
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { RecordSession } from '../ChatMessageList';
3
+ import './index.less';
4
+ export declare function fitUrl(url: string): string;
5
+ declare const GoodsOrderCard: React.FC<{
6
+ prefix?: string;
7
+ suspend?: boolean;
8
+ onSend?: Function;
9
+ onClose?: Function;
10
+ orderSn?: any;
11
+ orderId?: any;
12
+ recordSession?: RecordSession;
13
+ }>;
14
+ export default GoodsOrderCard;