video curcse
All checks were successful
Deploy to Server / deploy (push) Successful in 36s

This commit is contained in:
jeremygan2021
2026-02-27 14:26:54 +08:00
parent 4f632defde
commit 9123b929fd
2 changed files with 39 additions and 5 deletions

View File

@@ -1,8 +1,9 @@
import React, { useEffect, useState } from 'react';
import { useParams, useNavigate, useSearchParams } from 'react-router-dom';
import { useParams, useNavigate, useSearchParams, useLocation } from 'react-router-dom';
import { Typography, Button, Spin, Empty, Descriptions, Tag, Row, Col, Modal, Form, Input, message, Statistic } from 'antd';
import { ArrowLeftOutlined, ClockCircleOutlined, GiftOutlined, ShoppingCartOutlined } from '@ant-design/icons';
import { getServiceDetail, createServiceOrder } from '../api';
import { useAuth } from '../context/AuthContext';
import { motion } from 'framer-motion';
const { Title, Paragraph } = Typography;
@@ -10,7 +11,9 @@ const { Title, Paragraph } = Typography;
const ServiceDetail = () => {
const { id } = useParams();
const navigate = useNavigate();
const location = useLocation();
const [searchParams] = useSearchParams();
const { user } = useAuth();
const [service, setService] = useState(null);
const [loading, setLoading] = useState(true);
const [isModalOpen, setIsModalOpen] = useState(false);
@@ -38,6 +41,14 @@ const ServiceDetail = () => {
fetchDetail();
}, [id]);
useEffect(() => {
if (isModalOpen && user && user.phone_number) {
form.setFieldsValue({
phone_number: user.phone_number
});
}
}, [isModalOpen, user, form]);
const handlePurchase = async (values) => {
setSubmitting(true);
try {
@@ -209,7 +220,14 @@ const ServiceDetail = () => {
color: '#000',
fontWeight: 'bold'
}}
onClick={() => setIsModalOpen(true)}
onClick={() => {
if (!user) {
message.info('请先登录后再进行咨询');
navigate('/login', { state: { from: location.pathname } });
return;
}
setIsModalOpen(true);
}}
>
立即咨询 / 购买
</Button>

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { useParams, useNavigate, useSearchParams } from 'react-router-dom';
import { useParams, useNavigate, useSearchParams, useLocation } from 'react-router-dom';
import { Typography, Button, Spin, Empty, Descriptions, Tag, Row, Col, Modal, Form, Input, message } from 'antd';
import { ArrowLeftOutlined, ClockCircleOutlined, UserOutlined, BookOutlined, FormOutlined, CalendarOutlined, PlayCircleOutlined, LockOutlined } from '@ant-design/icons';
import { getVCCourseDetail, createOrder, nativePay, queryOrderStatus } from '../api';
@@ -19,6 +19,7 @@ const { Title, Paragraph } = Typography;
const VCCourseDetail = () => {
const { id } = useParams();
const navigate = useNavigate();
const location = useLocation();
const [searchParams] = useSearchParams();
const { user } = useAuth();
const [course, setCourse] = useState(null);
@@ -272,7 +273,14 @@ const VCCourseDetail = () => {
color: '#000',
fontWeight: 'bold'
}}
onClick={() => setIsModalOpen(true)}
onClick={() => {
if (!user) {
message.info('请先登录后再进行报名或购买');
navigate('/login', { state: { from: location.pathname } });
return;
}
setIsModalOpen(true);
}}
>
立即解锁观看
</Button>
@@ -436,7 +444,15 @@ const VCCourseDetail = () => {
fontSize: '16px',
cursor: course.is_purchased ? 'not-allowed' : 'pointer'
}}
onClick={() => !course.is_purchased && setIsModalOpen(true)}
onClick={() => {
if (course.is_purchased) return;
if (!user) {
message.info('请先登录后再进行报名或购买');
navigate('/login', { state: { from: location.pathname } });
return;
}
setIsModalOpen(true);
}}
>
{course.is_purchased ? '已购买' : (course.is_video_course ? '购买视频课程' : '立即报名 / 咨询')}
</Button>