This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Form, Input, Button, Card, List, Tag, Typography, message, Space, Statistic, Divider, Modal, Descriptions, Tabs } from 'antd';
|
||||
import { MobileOutlined, LockOutlined, SearchOutlined, CarOutlined, InboxOutlined, SafetyCertificateOutlined, CheckCircleOutlined, ClockCircleOutlined, CloseCircleOutlined, UserOutlined, EnvironmentOutlined, PhoneOutlined, CalendarOutlined } from '@ant-design/icons';
|
||||
import { queryMyOrders, getMySignups } from '../api';
|
||||
import { motion } from 'framer-motion';
|
||||
import { getMySignups } from '../api';
|
||||
import LoginModal from '../components/LoginModal';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
@@ -75,6 +74,24 @@ const MyOrders = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const getOrderTypeTag = (order) => {
|
||||
if (order.config) return <Tag color="blue">硬件</Tag>;
|
||||
if (order.course) return <Tag color="purple">VC课程</Tag>;
|
||||
if (order.activity) return <Tag color="orange">活动</Tag>;
|
||||
return <Tag>其他</Tag>;
|
||||
};
|
||||
|
||||
const getOrderTitle = (order) => {
|
||||
if (order.config_name) return order.config_name;
|
||||
if (order.course_title) return order.course_title;
|
||||
if (order.activity_title) return order.activity_title;
|
||||
// Fallback to ID if no name/title
|
||||
if (order.config) return `硬件 ID: ${order.config}`;
|
||||
if (order.course) return `课程 ID: ${order.course}`;
|
||||
if (order.activity) return `活动 ID: ${order.activity}`;
|
||||
return '未知商品';
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
minHeight: '80vh',
|
||||
@@ -96,7 +113,7 @@ const MyOrders = () => {
|
||||
<Button type="primary" size="large" onClick={() => setLoginVisible(true)}>立即登录</Button>
|
||||
</div>
|
||||
) : (
|
||||
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
|
||||
<div>
|
||||
<div style={{ marginBottom: 20, textAlign: 'right', color: '#fff' }}>
|
||||
当前登录用户: <span style={{ color: '#00b96b', fontWeight: 'bold', marginRight: 10 }}>{user.nickname}</span>
|
||||
<Button
|
||||
@@ -122,7 +139,7 @@ const MyOrders = () => {
|
||||
<Card
|
||||
hoverable
|
||||
onClick={() => showDetail(order)}
|
||||
title={<Space><span style={{ color: '#fff' }}>订单号: {order.id}</span> {getStatusTag(order.status)}</Space>}
|
||||
title={<Space>{getOrderTypeTag(order)}<span style={{ color: '#fff' }}>订单号: {order.id}</span> {getStatusTag(order.status)}</Space>}
|
||||
style={{
|
||||
background: 'rgba(0,0,0,0.6)',
|
||||
border: '1px solid rgba(255,255,255,0.1)',
|
||||
@@ -143,7 +160,7 @@ const MyOrders = () => {
|
||||
{order.config_image ? (
|
||||
<img
|
||||
src={order.config_image}
|
||||
alt={order.config_name}
|
||||
alt={getOrderTitle(order)}
|
||||
style={{ width: 60, height: 60, objectFit: 'cover', borderRadius: 8, border: '1px solid rgba(255,255,255,0.1)' }}
|
||||
/>
|
||||
) : (
|
||||
@@ -161,7 +178,7 @@ const MyOrders = () => {
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<div style={{ color: '#fff', fontSize: 16, fontWeight: '500', marginBottom: 4 }}>{order.config_name || `商品 ID: ${order.config}`}</div>
|
||||
<div style={{ color: '#fff', fontSize: 16, fontWeight: '500', marginBottom: 4 }}>{getOrderTitle(order)}</div>
|
||||
<div style={{ color: '#888' }}>数量: <span style={{ color: '#00b96b' }}>x{order.quantity}</span></div>
|
||||
</div>
|
||||
</Space>
|
||||
@@ -277,7 +294,7 @@ const MyOrders = () => {
|
||||
)
|
||||
}
|
||||
]} />
|
||||
</motion.div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Modal
|
||||
@@ -297,7 +314,8 @@ const MyOrders = () => {
|
||||
<Descriptions.Item label="订单号">
|
||||
<Paragraph copyable={{ text: currentOrder.id }} style={{ marginBottom: 0 }}>{currentOrder.id}</Paragraph>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="商品名称">{currentOrder.config_name}</Descriptions.Item>
|
||||
<Descriptions.Item label="订单类型">{getOrderTypeTag(currentOrder)}</Descriptions.Item>
|
||||
<Descriptions.Item label="商品名称">{getOrderTitle(currentOrder)}</Descriptions.Item>
|
||||
<Descriptions.Item label="下单时间">{new Date(currentOrder.created_at).toLocaleString()}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态更新时间">{new Date(currentOrder.updated_at).toLocaleString()}</Descriptions.Item>
|
||||
<Descriptions.Item label="当前状态">{getStatusTag(currentOrder.status)}</Descriptions.Item>
|
||||
@@ -344,7 +362,7 @@ const MyOrders = () => {
|
||||
onLoginSuccess={(userData) => {
|
||||
login(userData);
|
||||
if (userData.phone_number) {
|
||||
handleQueryOrders(userData.phone_number);
|
||||
handleQueryData();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user