微信会话增加 link 类型处理

增加日期格式化显示
feature/2.0-sales-trade
LiaoYijun 3 years ago
parent b947a26881
commit e700162307

@ -31,12 +31,14 @@ class Wechat_session extends Component {
} }
renderMsgItem(chatMsg) { renderMsgItem(chatMsg) {
const msgDate = new Date(chatMsg.msgtime);
const msgDateText = msgDate.toLocaleDateString() + ' ' + msgDate.toLocaleTimeString();
return ( return (
<List.Item className='ant-list-item-no-flex'> <List.Item className='ant-list-item-no-flex'>
<List.Item.Meta <List.Item.Meta
avatar={<Avatar src={chatMsg.from_avatar} />} avatar={<Avatar src={chatMsg.from_avatar} />}
title={chatMsg.from_name} title={chatMsg.from_name}
description={chatMsg.msgtime} description={msgDateText}
/> />
{this.renderMsgContent(chatMsg)} {this.renderMsgContent(chatMsg)}
</List.Item> </List.Item>
@ -46,7 +48,7 @@ class Wechat_session extends Component {
renderMsgContent(chatMsg) { renderMsgContent(chatMsg) {
if (chatMsg.msgtype === 'file') { if (chatMsg.msgtype === 'file') {
return ( return (
<a href={chatMsg.content.fileurl}>{chatMsg.content.filename}</a> <a href={chatMsg.content.fileurl}>{chatMsg.content.filename}</a>
) )
} else if (chatMsg.msgtype === 'image') { } else if (chatMsg.msgtype === 'image') {
return ( return (
@ -56,6 +58,10 @@ class Wechat_session extends Component {
return ( return (
<>{chatMsg.content.text}</> <>{chatMsg.content.text}</>
) )
} else if (chatMsg.msgtype === 'link') {
return (
<a href={chatMsg.content.link_url}>{chatMsg.content.title}</a>
)
} else { } else {
return ( return (
<>未知消息[{chatMsg.msgtype}]</> <>未知消息[{chatMsg.msgtype}]</>

Loading…
Cancel
Save