import { Button, Input } from 'antd' import { useState, useEffect, FC } from 'react' import { useSelector } from 'react-redux' import { commentSave, getCommentList } from '../../service' import './index.less' import { CommentOutlined, FileImageOutlined, SmileOutlined } from '@ant-design/icons' const CommentList: FC = props => { const { userInfo } = useSelector(store => store.userInfo) const { momentId } = props const [replyList, setReplyList] = useState([]) const [comment, setComment] = useState('') const getList = async () => { const res = await getCommentList({ id: momentId }) if (res.success && res.data) { setReplyList(res.data) } else { setReplyList([]) } } useEffect(() => { getList() }, []) const changeComment = e => { setComment(e.target.value) } const saveComment = () => { const params = { momentId, replyType: 2, content: comment, targetId: 12 } commentSave(params).then(() => { getList() }) } return (
评论 {replyList.length}
1/1000
{replyList.map((item: Record) => { return (
{item.userName}
{item.content}
12小时前
 评论
{item.children?.length && item.children.map(child => { return (
{child.userName}
{child.content}
12小时前
 评论
) })}
) })}
) } export default CommentList