This commit is contained in:
@@ -211,11 +211,13 @@ class VCCourseSerializer(serializers.ModelSerializer):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# 检查是否已购买/报名 (通过已支付的订单)
|
# 检查是否已购买/报名 (通过已支付的订单)
|
||||||
return Order.objects.filter(
|
has_order = Order.objects.filter(
|
||||||
wechat_user=user,
|
wechat_user=user,
|
||||||
course=obj,
|
course=obj,
|
||||||
status__in=['paid', 'shipped', 'completed']
|
status__in=['paid', 'shipped', 'completed']
|
||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
|
return has_order
|
||||||
|
|
||||||
def get_is_purchased(self, obj):
|
def get_is_purchased(self, obj):
|
||||||
return self._check_purchased(obj)
|
return self._check_purchased(obj)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const getServices = () => api.get('/services/');
|
|||||||
export const getServiceDetail = (id) => api.get(`/services/${id}/`);
|
export const getServiceDetail = (id) => api.get(`/services/${id}/`);
|
||||||
export const createServiceOrder = (data) => api.post('/service-orders/', data);
|
export const createServiceOrder = (data) => api.post('/service-orders/', data);
|
||||||
export const getVCCourses = () => api.get('/courses/');
|
export const getVCCourses = () => api.get('/courses/');
|
||||||
export const getVCCourseDetail = (id) => api.get(`/courses/${id}/`);
|
export const getVCCourseDetail = (id) => api.get(`/courses/${id}/`, { params: { _t: Date.now() } });
|
||||||
export const enrollCourse = (data) => api.post('/course-enrollments/', data);
|
export const enrollCourse = (data) => api.post('/course-enrollments/', data);
|
||||||
|
|
||||||
export const sendSms = (data) => api.post('/auth/send-sms/', data);
|
export const sendSms = (data) => api.post('/auth/send-sms/', data);
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ const VCCourseDetail = () => {
|
|||||||
const fetchDetail = async () => {
|
const fetchDetail = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await getVCCourseDetail(id);
|
const response = await getVCCourseDetail(id);
|
||||||
|
console.log('Course detail:', response.data);
|
||||||
setCourse(response.data);
|
setCourse(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch course detail:", error);
|
console.error("Failed to fetch course detail:", error);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const createServiceOrder = (data: any) => {
|
|||||||
|
|
||||||
// VB Courses
|
// VB Courses
|
||||||
export const getVBCourses = () => request({ url: '/courses/' })
|
export const getVBCourses = () => request({ url: '/courses/' })
|
||||||
export const getVBCourseDetail = (id: number) => request({ url: `/courses/${id}/` })
|
export const getVBCourseDetail = (id: number) => request({ url: `/courses/${id}/?_t=${Date.now()}` })
|
||||||
|
|
||||||
// Distributor
|
// Distributor
|
||||||
export const distributorRegister = (data: any) => {
|
export const distributorRegister = (data: any) => {
|
||||||
|
|||||||
@@ -118,6 +118,7 @@
|
|||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-unlock {
|
.btn-unlock {
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ export default function CourseDetail() {
|
|||||||
|
|
||||||
const fetchDetail = async (id: string) => {
|
const fetchDetail = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
|
// Add timestamp to prevent caching
|
||||||
const res: any = await getVBCourseDetail(Number(id))
|
const res: any = await getVBCourseDetail(Number(id))
|
||||||
|
console.log('Course detail:', res)
|
||||||
setDetail(res)
|
setDetail(res)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user