import { FileImageOutlined, MessageOutlined, PlusOutlined, ShareAltOutlined, SmileOutlined, MessageTwoTone } from '@ant-design/icons' import { Avatar, Button, Card, Input, Popover, Tabs, message, Upload, Image } from 'antd' import { useEffect, useState } from 'react' import { fetchCircleList, saveMoment, getMoments } from './service' import CommentList from './comps/comment-list' import './index.less' const { Meta } = Card const { TextArea } = Input const Circle = () => { const userInfoStorage = localStorage.getItem('userInfo') const { tokenValue = '' } = userInfoStorage ? JSON.parse(userInfoStorage) : {} const [hasFocus, setHasFocus] = useState(false) const [comment, setComment] = useState('') const [circleList, setCircleList] = useState([]) const [currentSelectCircle, setCurrentSelectCircle] = useState(null) const [openFlag, setOpenFlag] = useState(false) const [imgList, setImgList] = useState([]) const [momentList, setMomentList] = useState([]) const [currentReplyCommentId, setCurrentReplyCommentId] = useState(undefined) const [previewList, setPreviewList] = useState({ list: [], index: 0 }) const toggleFocus = (flag: boolean) => { setHasFocus(!flag) } const onChange = e => { setComment(e.target.value) } const getCircleList = async () => { const res = await fetchCircleList() if (res.success && res.data?.length > 0) { setCircleList(res.data) } } useEffect(() => { getCircleList() getMomentList() }, []) const changeCircle = selectItem => { setCurrentSelectCircle(selectItem) setOpenFlag(false) } const renderTab = () => { return circleList.map(item => { return { label: item.circleName, key: item.id, children: (
{item.children.map(child => { return (
changeCircle(child)} > {child.circleName}
) })}
) } }) } const renderPopContent = () => { return } const getMomentList = async () => { const res = await getMoments({ pageInfo: { pageNo: 1, pageSize: 10 } }) setMomentList(res.data.result) } const publishMoment = async () => { const params: any = { circleId: currentSelectCircle?.id, content: comment } if (imgList.length) { params.picUrlList = imgList.map(item => item.response.data) } const res = await saveMoment(params) if (res.success) { setComment('') setImgList([]) getMomentList() return message.success('发布成功') } return message.error('有点繁忙呢,要不再试试~~~') } const uploadButton = ( ) const handleChange = ({ fileList }) => { setImgList(fileList) } const showReply = (item: any) => { if (item.id !== currentReplyCommentId) { setCurrentReplyCommentId(item.id) } else { setCurrentReplyCommentId(undefined) } } const handlePreview = (picList, index) => { setPreviewList({ list: picList, index }) } return (