董国庆
2026-01-04 4e8107c78b08fc05e5d1eacb2330c02a9193565b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import React, { useState, useEffect } from 'react';
import { Modal, Descriptions, Image, Typography, message, Table } from 'antd';
import { getPhysicalGoodsOrderDetail } from '../service';
 
const OrderDetailModal = ({ orderId, visible, onClose }) => {
  const [orderDetail, setOrderDetail] = useState(null);
  const [loading, setLoading] = useState(false);
 
  useEffect(() => {
    const fetchDetail = async () => {
      setLoading(true);
      try {
        const res = await getPhysicalGoodsOrderDetail(orderId);
        if (res.code === 200) {
          setOrderDetail(res.data);
        } else {
          message.error(res.message || '获取订单详情失败');
        }
      } catch (error) {
        message.error('获取订单详情失败');
      }
      setLoading(false);
    };
    if (visible && orderId) {
      fetchDetail();
    }
  }, [visible, orderId]);
 
  // 渲染商品信息表格
  const renderProductTable = () => {
    const columns = [
      {
        title: '商品名称',
        dataIndex: 'physicalGoodsName',
        width: 200,
      },
      {
        title: '封面图',
        dataIndex: 'physicalGoodsCover',
        width: 100,
        render: (text) => (
          <Image
            width={60}
            height={60}
            src={text ? IMAGE_URL + text : null}
            style={{ objectFit: 'cover' }}
            placeholder={<div style={{ width: 60, height: 60, background: '#f5f5f5' }} />}
            fallback="/images/default-image.png"
          />
        ),
      },
      {
        title: '商品价格',
        dataIndex: 'physicalGoodsPrice',
        width: 120,
        render: (text) => `¥${text || 0}`,
      },
      {
        title: '商品简介',
        dataIndex: 'physicalGoodsIntro',
        ellipsis: true,
      },
      {
        title: '销量',
        dataIndex: 'physicalGoodsSales',
        width: 80,
      },
    ];
 
    const dataSource = [{
      key: orderDetail?.id,
      ...orderDetail,
    }];
 
    return (
      <Table
        columns={columns}
        dataSource={dataSource}
        pagination={false}
        size="small"
      />
    );
  };
 
  if (!visible) return null;
 
  const statusMap = {
    1: { text: '待付款', color: '#faad14' },
    2: { text: '完成支付', color: '#52c41a' },
    3: { text: '确认收货', color: '#1890ff' },
    4: { text: '已退款', color: '#722ed1' },
  };
 
  const currentStatus = statusMap[orderDetail?.status] || { text: '未知', color: '#d9d9d9' };
 
  return (
    <Modal
      title="订单详情"
      width='60%'
      visible={visible}
      onCancel={onClose}
      footer={null}
      destroyOnHidden
    >
      {loading ? (
        <div style={{ textAlign: 'center', padding: '50px' }}>加载中...</div>
      ) : orderDetail ? (
        <>
          <Descriptions column={2} bordered>
            {orderDetail.status === 1 ? (
              <>
                <Descriptions.Item label="订单编号">{orderDetail.code}</Descriptions.Item>
                <Descriptions.Item label="下单时间">{orderDetail.createTime}</Descriptions.Item>
                {/* <Descriptions.Item label="订单价格">¥{orderDetail.orderPrice || 0}</Descriptions.Item> */}
                <Descriptions.Item label="用户昵称">{orderDetail.userName}</Descriptions.Item>
                <Descriptions.Item label="用户手机号">{orderDetail.phone}</Descriptions.Item>
              </>
            ) : (
              <>
                <Descriptions.Item label="订单编号">{orderDetail.code}</Descriptions.Item>
                <Descriptions.Item label="下单时间">{orderDetail.createTime}</Descriptions.Item>
                <Descriptions.Item label="用户昵称">{orderDetail.userName}</Descriptions.Item>
                <Descriptions.Item label="当前状态">
                  <span style={{ color: currentStatus.color }}>{currentStatus.text}</span>
                </Descriptions.Item>
                <Descriptions.Item label="用户手机号">{orderDetail.phone}</Descriptions.Item>
                <Descriptions.Item label="已支付">¥{orderDetail.paymentPrice || 0}</Descriptions.Item>
                <Descriptions.Item label="支付时间">{orderDetail.paymentTime}</Descriptions.Item>
                <Descriptions.Item label="支付方式">微信支付</Descriptions.Item>
              </>
            )}
          </Descriptions>
 
          {/* 商品信息 */}
          <div style={{ marginTop: 24 }}>
            <div style={{ marginTop: 8 }}>
              {renderProductTable()}
            </div>
          </div>
          <Descriptions column={2} bordered style={{ marginTop: 24 }}>
            <>
              <Descriptions.Item label="当前状态">
                <span style={{ color: currentStatus.color }}>{currentStatus.text}</span>
              </Descriptions.Item>
              <Descriptions.Item label="订单金额">¥{orderDetail.orderPrice || 0}</Descriptions.Item>
              {
                orderDetail.status === 2 && <>
                  <Descriptions.Item label="已支付">¥{orderDetail.paymentPrice || 0}</Descriptions.Item>
                  <Descriptions.Item label="支付时间">{orderDetail.paymentTime}</Descriptions.Item>
                  <Descriptions.Item label="支付方式">微信支付</Descriptions.Item>
                </>
              }
            </>
 
          </Descriptions>
        </>
      ) : (
        <div style={{ textAlign: 'center', padding: '50px' }}>暂无数据</div>
      )
      }
    </Modal >
  );
};
 
export default OrderDetailModal;