import * as WebBrowser from 'expo-web-browser'; import * as React from 'react'; import { StyleSheet, View, Clipboard, RefreshControl } from 'react-native'; import { Div, Button, Image, Text } from 'react-native-magnus'; import { Flex } from '@ant-design/react-native'; import { ScrollView } from 'react-native-gesture-handler'; import { useRequest, useCreation } from '@umijs/hooks'; import { useRoute } from '@react-navigation/native'; import useModel from 'flooks'; import Toast from '../../flooks/Toast'; import Header from './Header'; // 头部 import { connectKefu } from '../../Utils/TotastUtils'; import { merchantStatusMap, orderStatusMap, RiderStatusMap, payMap, } from '../../Utils/OrderUtils'; import Time from '../../Utils/TimeUtils'; export default function OrderScreen({ navigation }) { const [orderInfo, setorderInfo] = React.useState({ merchant: {}, orderGoodsSpecs: [], }); const { success, warnning } = useModel(Toast, []); const route = useRoute(); const { params } = route; const { orderId } = params || 0; const orderRequest = useRequest(`/orderInfo/get/${orderId}`, { refreshDeps: [orderId], onSuccess: (result) => { setorderInfo(result); }, }); const { merchant, orderGoodsSpecs } = orderInfo; const statusInfo = useCreation(() => { const statusList = []; if (orderInfo.status) { statusList.push(orderStatusMap.get(orderInfo.status)); } if (orderInfo.merchantStatus) { statusList.push(merchantStatusMap.get(orderInfo.merchantStatus)); } if (orderInfo.riderStatus) { statusList.push(RiderStatusMap.get(orderInfo.riderStatus)); } if (statusList.length > 0) { return statusList.sort((a, b) => { return b.sort - a.sort; })[0]; } else { return { name: '订单详情', }; } }, [orderInfo]); const finish = useCreation(() => { if (orderInfo.riderStatus === 'CARRY_OUT') { return true; } else { return false; } }, [orderInfo]); const Allfinish = useCreation(() => { if (orderInfo.status === 'COMPLETED') { return true; } else { return false; } }, [orderInfo]); return ( <>
} > {finish ? ( {statusInfo.name} {new Time( orderInfo.userReceivedTime, 'yyyy-MM-DD HH:mm:ss' ).getFormat('HH:mm')} 送达 ) : ( {statusInfo.name} 预计 {new Time( orderInfo.timeOfArrival, 'yyyy-MM-DD HH:mm:ss' ).getFormat('HH:mm')} 送达 )}
{!finish && ( )} {!finish && ( )} {finish && !Allfinish && ( )} {finish && ( )}
{merchant.showName}
{orderGoodsSpecs.map((item) => { return ; })}
包装费 餐盒 ¥{orderInfo.packingPrice} 配送费(叮咚专送) ¥{orderInfo.deliveryAmount} 满减 -¥{orderInfo.fullReduction} {!!orderInfo.firstBuy && ( 首单 ¥{orderInfo.firstBuy} )} 红包 -¥{orderInfo.redBag || 0} 小计 ¥{orderInfo.realAmount}
订单信息 下单时间 {orderInfo.orderTime} {orderInfo.userReceivedTime ? ( 送达时间 {orderInfo.userReceivedTime} ) : ( 预计送达时间 {orderInfo.timeOfArrival} )} 收货地址 {orderInfo.userAddress} 配送骑手 周猩猩 订 单 号 {orderInfo.id} {payMap.has(orderInfo.payMethod) && ( 支付方式 {payMap.get(orderInfo.payMethod).name} )}
); } const GoodsItem = ({ info, goods }) => { return (
{goods.name} X {info.num} ¥{info.goodsRealPrice}
{info.specification}
); }; const styles = StyleSheet.create({ scroll: { flexGrow: 1, paddingHorizontal: 15, paddingVertical: 10, backgroundColor: '#eee', }, card: { borderRadius: 3, backgroundColor: '#fff', marginBottom: 5, padding: 15, }, item: { paddingVertical: 5, }, icon: { width: 33, height: 33, borderRadius: 3, }, goodsMain: { marginLeft: 10, }, type: { // marginTop:3, }, main: { marginTop: 10, paddingVertical: 5, borderColor: '#E5E5E5', borderTopWidth: 1, }, info: { marginTop: 10, }, total: { paddingTop: 10, marginTop: 10, borderColor: '#E5E5E5', borderTopWidth: 1, }, address: { minWidth: 50, marginRight: 30, }, info2: { marginTop: 10, }, });