import React, { useEffect, useState } from 'react'; import { View, Text, ScrollView, StyleSheet, TouchableOpacity, } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import BackIcon from '../../components/BackIcon'; import fontSize from '../../utils/fontsizeUtils'; import useOrderStore from '../../store/order'; import { ordersApi } from '../../services/api/orders'; import { Order } from '../../services/api/orders'; export function ConfirmOrder() { const navigation = useNavigation>(); const orderInfo = useOrderStore(); const [order, setOrder] = useState(); const getOrder = async () => { const data = orderInfo.order try { const response = await ordersApi.createOrder(data); console.log(response); setOrder(response); } catch (error) { navigation.goBack(); console.error('创建订单失败:', error); alert('创建订单失败,请重试'); } } useEffect(() => { getOrder() },[]) return ( {/* Header */} navigation.goBack()}> 确认订单 {/* Order Number */} 📋 订单编号 {order?.order_no} {/* Payment Method */} 💳 支付方式 {order?.payment_method} {orderInfo?.payment_operator} {/* Shipping Info */} 🚢 物流信息 配送方式: {orderInfo?.shipping?.method === 'sea' ? '海运' : '空运'} 预计到达: {orderInfo?.shipping?.estimated_arrival} {/* Recipient Info */} 👤 收件人信息 {order?.receiver_name} {order?.receiver_phone} {order?.receiver_address} {/* Order Items */} 📦 商品清单 {order?.items?.map((item) => ( {item.product_name} {item.sku_attributes.map((attr) => ( {attr.attribute_name}: {attr.value} ))} x{item.quantity} ${item.total_price} ))} {/* Price Summary */} 商品总价 ${order?.total_amount} 国内运费 ${order?.discount_amount} 国际运费 ${order?.shipping_fee} 实付金额 ${order?.actual_amount} {/* Bottom Button */} navigation.navigate('Pay',{order_id:order?.order_id})}> 立即支付 ); } const styles = StyleSheet.create({ mainContainer: { flex: 1, backgroundColor: '#fff', }, container: { flex: 1, backgroundColor: '#fff', }, header: { flexDirection: 'row', alignItems: 'center', padding: 16, backgroundColor: '#fff', elevation: 3, }, title: { fontSize: fontSize(18), fontWeight: '500', flex: 1, textAlign: 'center', }, section: { backgroundColor: '#fff', padding: 16, }, sectionHeader: { flexDirection: 'row', alignItems: 'center', marginBottom: 12, }, sectionIcon: { fontSize: fontSize(18), marginRight: 8, }, sectionTitle: { fontSize: fontSize(16), fontWeight: '500', }, border: { height: 6, backgroundColor: '#f5f5f5', }, orderNumber: { fontSize: fontSize(16), color: '#666', }, paymentInfo: { backgroundColor: '#f8f8f8', padding: 12, borderRadius: 8, }, paymentMethod: { fontSize: fontSize(16), fontWeight: '500', marginBottom: 4, }, paymentOperator: { fontSize: fontSize(14), color: '#666', }, shippingInfo: { backgroundColor: '#f8f8f8', padding: 12, borderRadius: 8, }, shippingRow: { flexDirection: 'row', marginBottom: 8, }, shippingLabel: { fontSize: fontSize(14), color: '#666', width: 80, }, shippingValue: { fontSize: fontSize(14), flex: 1, }, recipientInfo: { backgroundColor: '#f8f8f8', padding: 12, borderRadius: 8, }, recipientName: { fontSize: fontSize(16), fontWeight: '500', marginBottom: 4, }, recipientPhone: { fontSize: fontSize(14), color: '#666', marginBottom: 4, }, recipientAddress: { fontSize: fontSize(14), color: '#666', }, orderItems: { gap: 12, }, orderItem: { flexDirection: 'row', padding: 12, backgroundColor: '#f8f8f8', borderRadius: 8, }, itemDetails: { flex: 1, }, itemName: { fontSize: fontSize(14), marginBottom: 4, }, itemAttribute: { fontSize: fontSize(12), color: '#666', marginBottom: 2, }, itemQuantity: { fontSize: fontSize(12), color: '#999', marginTop: 4, }, itemPrice: { justifyContent: 'center', }, priceText: { fontSize: fontSize(16), fontWeight: '500', color: '#ff6000', }, priceSummary: { backgroundColor: '#f8f8f8', padding: 16, borderRadius: 8, }, priceRow: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 12, }, priceLabel: { fontSize: fontSize(14), color: '#666', }, priceValue: { fontSize: fontSize(14), color: '#333', }, totalRow: { marginTop: 8, paddingTop: 12, borderTopWidth: 1, borderTopColor: '#eee', }, totalLabel: { fontSize: fontSize(16), fontWeight: '500', }, totalAmount: { fontSize: fontSize(18), fontWeight: '600', color: '#ff6000', }, bottomButton: { width: '100%', padding: 16, backgroundColor: '#fff', }, bottomButtonContent: { backgroundColor: '#ff6000', padding: 16, borderRadius: 25, alignItems: 'center', }, bottomButtonText: { color: '#fff', fontSize: fontSize(16), fontWeight: '500', }, });