This commit is contained in:
@@ -4,6 +4,7 @@ import { Typography, Button, Spin, Empty, Descriptions, Tag, Row, Col, Modal, Fo
|
||||
import { ArrowLeftOutlined, ClockCircleOutlined, UserOutlined, BookOutlined, FormOutlined } from '@ant-design/icons';
|
||||
import { getVCCourseDetail, createOrder } from '../api';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
|
||||
const { Title, Paragraph } = Typography;
|
||||
|
||||
@@ -11,6 +12,7 @@ const VCCourseDetail = () => {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const { user } = useAuth();
|
||||
const [course, setCourse] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
@@ -34,6 +36,14 @@ const VCCourseDetail = () => {
|
||||
fetchDetail();
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isModalOpen && user && user.phone_number) {
|
||||
form.setFieldsValue({
|
||||
phone_number: user.phone_number
|
||||
});
|
||||
}
|
||||
}, [isModalOpen, user, form]);
|
||||
|
||||
const handleEnroll = async (values) => {
|
||||
setSubmitting(true);
|
||||
try {
|
||||
@@ -48,7 +58,11 @@ const VCCourseDetail = () => {
|
||||
};
|
||||
|
||||
await createOrder(orderData);
|
||||
message.success('报名咨询已提交,我们的课程顾问将尽快与您联系!');
|
||||
if (course.price === 0 || parseFloat(course.price) === 0) {
|
||||
message.success('报名成功!您已成功加入课程。');
|
||||
} else {
|
||||
message.success('报名咨询已提交,我们的课程顾问将尽快与您联系!');
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -88,7 +88,7 @@ const VCCourses = () => {
|
||||
</div>
|
||||
<p style={{ color: '#aaa', marginBottom: 20, flex: 1 }}>{item.description}</p>
|
||||
<Button type="primary" block ghost style={{ borderColor: '#00f0ff', color: '#00f0ff' }}>
|
||||
开始学习
|
||||
点击报名
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user