64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
![]() |
import { RedEnvelopeFilled } from '@ant-design/icons';
|
|||
|
import { IChatItem } from '../ChatLogsType';
|
|||
|
import styles from './index.module.scss';
|
|||
|
|
|||
|
export const ChatRedpacket: React.FC<IChatItem> = (props) => {
|
|||
|
function content() {
|
|||
|
try {
|
|||
|
const msg = JSON.parse(props.chat?.content as string);
|
|||
|
return (
|
|||
|
<div>
|
|||
|
<div style={{ display: 'flex' }}>
|
|||
|
<RedEnvelopeFilled
|
|||
|
style={{ fontSize: 40, color: 'red', flexShrink: 0, paddingRight: 8 }}
|
|||
|
/>
|
|||
|
<div>
|
|||
|
<div style={{ wordBreak: 'break-all' }}>{msg.wish}</div>
|
|||
|
<div style={{ wordBreak: 'break-all' }}>
|
|||
|
{msg.totalcnt}个,{(msg.totalamount / 100).toFixed(2)}元
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div style={{ borderTop: '1px solid #ddd', marginTop: 12 }}>红包</div>
|
|||
|
</div>
|
|||
|
);
|
|||
|
} catch (_e) {
|
|||
|
return (
|
|||
|
<div>
|
|||
|
<div style={{ display: 'flex' }}>
|
|||
|
<RedEnvelopeFilled
|
|||
|
style={{ fontSize: 40, color: 'red', flexShrink: 0, paddingRight: 8 }}
|
|||
|
/>
|
|||
|
<div style={{ wordBreak: 'break-all' }}>{props.chat?.content}</div>
|
|||
|
</div>
|
|||
|
<div style={{ borderTop: '1px solid #ddd', marginTop: 12 }}>红包</div>
|
|||
|
</div>
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return (
|
|||
|
<>
|
|||
|
{props.from?.user_id == props.chat?.msg_from ? (
|
|||
|
<div className={styles.chatRight}>
|
|||
|
<div className={styles.chatContentBox}>
|
|||
|
<div className={styles.name}>{props.from?.name}</div>
|
|||
|
<div className={styles.content}>{content()}</div>
|
|||
|
</div>
|
|||
|
<div className={styles.chatAvatar}>{props.from?.name[0]}</div>
|
|||
|
</div>
|
|||
|
) : (
|
|||
|
<div className={styles.chatLeft}>
|
|||
|
<div className={styles.chatAvatar}>
|
|||
|
<img src={props.to?.cust_info.avatar} alt="" />
|
|||
|
</div>
|
|||
|
<div className={styles.chatContentBox}>
|
|||
|
<div className={styles.name}>{props.to?.cust_info.name}</div>
|
|||
|
<div className={styles.content}>{content()}</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
)}
|
|||
|
</>
|
|||
|
);
|
|||
|
};
|