import { StackScreenProps } from '@react-navigation/stack'; import * as React from 'react'; import { Div, Button, Image, Text, Avatar, Icon } from 'react-native-magnus'; import { Menu } from 'teaset'; import { ScrollView } from 'react-native-gesture-handler'; import { useRequest, useCreation, useMount } from 'ahooks'; import { RefreshControl, Dimensions } from 'react-native'; import { toastInfo, toastSuccess, alert } from '../utils/SystemUtils'; import { RiderStatusMap } from '../utils/RiderInfoUtils'; import ImagePicker from '../components/ImagePicker'; import { useTranslation } from 'react-i18next'; import useModel from 'flooks'; import OrderModel from './model'; import { useSafeArea } from 'react-native-safe-area-context'; import { changeCord, goMap } from '../utils/MapUtils'; import { connect } from '../utils/SystemUtils'; import Request from '../utils/RequestUtils'; function RightMenuItem({ text = '' }) { return ( {text} ); } export default function OrderDetailScreen({ navigation, route, }: StackScreenProps) { const { t } = useTranslation(); const { params } = route; const { orderId } = params; const [pickImg, setpickImg] = React.useState(''); const { receiverOrder, changeStatus, changeStatusAll } = useModel( OrderModel, [] ); navigation.setOptions({ headerRight: (props) => ( ), }); const { data, loading, reload, run } = useRequest( `/orderInfo/get/${orderId}`, { manual: true, defaultLoading: false, debounceInterval: 1000, initialData: {}, } ); useMount(() => { run(); }); const orderGoodsSpecs = useCreation(() => { return data.orderGoodsSpecs || []; }, [data]); const statusInfo = useCreation(() => { if (data.riderStatus) { return RiderStatusMap.get(data.riderStatus); } else { return {}; } }, [data]); const totalNum = useCreation(() => { return orderGoodsSpecs.reduce((total, currentValue) => { return total + currentValue.num; }, 0); }, [orderGoodsSpecs]); const isRefund = useCreation(() => { if (data.status === 'REFUNDED_PENDING') { return true; } else { return false; } }, [data]); function orderChange() { alert(navigation, { msg: statusInfo.infoText, hasCancel: true, dangers: true, submitEvent: () => { changeStatus( data.id, statusInfo.nextStatus, (res) => { toastSuccess(statusInfo.successText); }, () => { alert(navigation, { msg: statusInfo.errorText, hasCancel: true, dangers: true, submitEvent: () => { changeStatusAll(data.id, statusInfo.nextStatus, (res) => { toastSuccess(statusInfo.successText); run(); }); }, }); }, pickImg ); }, }); } return (
{/* */} {statusInfo.type && statusInfo.type !== 'order' && (
{__DEV__ && !isRefund && statusInfo.type && statusInfo.type !== 'order' && ( )}
{data.deliveryAmount} {t('ben-dan-pai-song-shou-ru')}
{statusInfo.type === 'finish' ? (
{data.userReceivedTime} {t('yong-hu-shou-dao-shi-jian')}
) : (
{data.timeOfArrival} {t('yu-ji-song-da-shi-jian')}
)}
)} } > {statusInfo.type && ( <>
{statusInfo.type == 'user' && (
{statusInfo.name} {t('liu-shui-hao')}:{data.id}
)} {statusInfo.type === 'merchant' && ( <>
{t('wo-yi-dao-dian')} {t('liu-shui-hao')}:{data.id}
{statusInfo.status === 1 && ( <>
{t('wo-yi-qu-huo')} {t('ordertips')}
setpickImg(img)} /> )} )} {(statusInfo.type === 'user' || statusInfo.type === 'finish') && (
{t('yong-hu-xin-xi')}
{data.nickname} {data.userAddress}
)} {(statusInfo.type === 'merchant' || statusInfo.type === 'finish') && (
{t('shang-jia-xin-xi')}
{data.merShowName} {data.merAddress}
)} {statusInfo.type === 'order' && (
1.5Km
{data.merShowName} {data.merAddress}
1.5Km
{data.nickName && ( {data.nickName} )} {data.userAddress}
)}
{t('shang-pin-xin-xi')} {totalNum} {t('fen')} ¥{data.realAmount || 0}
{orderGoodsSpecs.map((item) => { const goods = item.goods; return (
{goods.name} {item.specification} X {item.num}
); })}
{statusInfo.type === 'order' && ( )}
{(statusInfo.type === 'merchant' || statusInfo.type === 'user') && !isRefund && (
)} {isRefund && (
)} )}
); }