import React, { useEffect, useState } from 'react'; import { Modal, Button, Descriptions, Image, Space, Tooltip, message, Typography } from 'antd'; import { CopyOutlined, PlayCircleOutlined, DownloadOutlined } from '@ant-design/icons'; import { WeComPlan, WeComPlanType } from '@src/views/publishContent/weCom/type'; import copy from 'copy-to-clipboard'; import VideoPlayModal from '../videoPlayModal'; import { getShareQrPic } from '@src/http/api'; import http from '@src/http'; const { Text } = Typography; interface PlanDetailModalProps { visible: boolean; onClose: () => void; planData: WeComPlan | null | undefined; } const PlanDetailModal: React.FC = ({ visible, onClose, planData }) => { const [isVideoPlayModalVisible, setIsVideoPlayModalVisible] = useState(false); const [qrCode, setQrCode] = useState(''); useEffect(() => { if (planData?.pageUrl) { getShareQr(planData?.pageUrl || ''); } }, [planData]); if (!planData) { return null; // Don't render if no data } const getShareQr = (pageUrl: string) => { http.get(getShareQrPic, { params: { pageUrl, } }).then(res => { setQrCode(res.data); }).catch(err => { message.error(err.msg || '获取二维码失败'); }); }; const handleCopy = (text: string | undefined, successMessage: string) => { if (text && copy(text)) { message.success(successMessage); } else if (!text) { message.warning('没有内容可复制'); } else { message.error('复制失败'); } }; const downloadFile = (url: string | undefined, filename: string) => { if (!url) { message.warning('无可用文件下载'); return; } const link = document.createElement('a'); link.href = url; link.download = filename || url.substring(url.lastIndexOf('/') + 1); link.target = '_blank'; link.rel = 'noopener noreferrer'; document.body.appendChild(link); link.click(); document.body.removeChild(link); message.success('开始下载...'); }; const playVideo = () => { setIsVideoPlayModalVisible(true); } // Determine scene text based on plan type (adjust logic if needed) const getSceneText = (plan: WeComPlan) => { if (plan.type === +WeComPlanType.社群) { return plan.scene === 0 ? '群发' : '单发'; } // Add logic for other plan types if necessary return '自动回复'; // Example placeholder for other types } // Determine publish type text (adjust based on your data model) const getPublishTypeText = (plan: WeComPlan) => { // This field isn't directly in WeComPlan, you might need to fetch/derive it // Returning a placeholder for now. return plan.type === +WeComPlanType.社群 ? '社群' : '自动回复'; // Example } // Determine account type text (adjust based on your data model) const getAccountTypeText = () => { // This field isn't in WeComPlan, returning placeholder. return '小慧爱厨房'; // Placeholder based on image } // Determine account name text (adjust based on your data model) const getAccountNameText = () => { // This field isn't in WeComPlan, returning placeholder. return '企微号'; // Placeholder based on image } return ( 关闭 , ]} width={650} // Adjust width as needed destroyOnClose > {planData.id} {/* Placeholder fields based on image - replace with actual data source if available */} {getAccountTypeText()} {getAccountNameText()} {getPublishTypeText(planData)} {getSceneText(planData)} {planData.pageUrl} {qrCode ? ( 二维码 {/* You might want to add a logo overlay if needed */} ) : ( 无可用链接生成二维码 )} setIsVideoPlayModalVisible(false)} videoUrl={planData.video || ''} title={planData.title || ''} /> ); }; export default PlanDetailModal;