|
@@ -1,9 +1,10 @@
|
|
|
import { StackScreenProps } from '@react-navigation/stack';
|
|
import { StackScreenProps } from '@react-navigation/stack';
|
|
|
import * as React from 'react';
|
|
import * as React from 'react';
|
|
|
-import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
|
|
|
|
|
|
|
+import { Div, Button, Image, Text, Avatar, Icon } from 'react-native-magnus';
|
|
|
|
|
+import { Menu } from 'teaset';
|
|
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
|
-import { useRequest, useCreation } from 'ahooks';
|
|
|
|
|
-import { RefreshControl } from 'react-native';
|
|
|
|
|
|
|
+import { useRequest, useCreation, useMount } from 'ahooks';
|
|
|
|
|
+import { RefreshControl, Dimensions } from 'react-native';
|
|
|
import { toastInfo, toastSuccess, alert } from '../utils/SystemUtils';
|
|
import { toastInfo, toastSuccess, alert } from '../utils/SystemUtils';
|
|
|
|
|
|
|
|
import { RiderStatusMap } from '../utils/RiderInfoUtils';
|
|
import { RiderStatusMap } from '../utils/RiderInfoUtils';
|
|
@@ -16,6 +17,17 @@ import { useSafeArea } from 'react-native-safe-area-context';
|
|
|
|
|
|
|
|
import { changeCord, goMap } from '../utils/MapUtils';
|
|
import { changeCord, goMap } from '../utils/MapUtils';
|
|
|
|
|
|
|
|
|
|
+import { connect } from '../utils/SystemUtils';
|
|
|
|
|
+
|
|
|
|
|
+import Request from '../utils/RequestUtils';
|
|
|
|
|
+
|
|
|
|
|
+function RightMenuItem({ text = '' }) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Text fontSize="sm" color="black">
|
|
|
|
|
+ {text}
|
|
|
|
|
+ </Text>
|
|
|
|
|
+ );
|
|
|
|
|
+}
|
|
|
export default function OrderDetailScreen({
|
|
export default function OrderDetailScreen({
|
|
|
navigation,
|
|
navigation,
|
|
|
route,
|
|
route,
|
|
@@ -31,15 +43,69 @@ export default function OrderDetailScreen({
|
|
|
[]
|
|
[]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ navigation.setOptions({
|
|
|
|
|
+ headerRight: (props) => (
|
|
|
|
|
+ <Button
|
|
|
|
|
+ bg="none"
|
|
|
|
|
+ px={15}
|
|
|
|
|
+ py={0}
|
|
|
|
|
+ w={50}
|
|
|
|
|
+ h={50}
|
|
|
|
|
+ onPress={() => {
|
|
|
|
|
+ const x = Dimensions.get('window').width - 80,
|
|
|
|
|
+ y = 0,
|
|
|
|
|
+ width = 50,
|
|
|
|
|
+ height = 50;
|
|
|
|
|
+ let items = [
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '联系客服',
|
|
|
|
|
+ onPress: () => connect(navigation),
|
|
|
|
|
+ },
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (!isRefund && statusInfo.type && statusInfo.type !== 'order') {
|
|
|
|
|
+ items.splice(0, 0, {
|
|
|
|
|
+ title: '取消订单申请',
|
|
|
|
|
+ onPress: () => {
|
|
|
|
|
+ navigation.navigate('Modal', {
|
|
|
|
|
+ screen: 'Applay',
|
|
|
|
|
+ params: {
|
|
|
|
|
+ orderId,
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ Menu.show({ x, y, width, height }, items, {
|
|
|
|
|
+ popoverStyle: {
|
|
|
|
|
+ backgroundColor: '#fff',
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Icon
|
|
|
|
|
+ name="more-horizontal"
|
|
|
|
|
+ color="white"
|
|
|
|
|
+ fontFamily="Feather"
|
|
|
|
|
+ fontSize="lg"
|
|
|
|
|
+ ></Icon>
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ),
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
const { data, loading, reload, run } = useRequest(
|
|
const { data, loading, reload, run } = useRequest(
|
|
|
`/orderInfo/get/${orderId}`,
|
|
`/orderInfo/get/${orderId}`,
|
|
|
{
|
|
{
|
|
|
|
|
+ manual: true,
|
|
|
defaultLoading: false,
|
|
defaultLoading: false,
|
|
|
debounceInterval: 1000,
|
|
debounceInterval: 1000,
|
|
|
initialData: {},
|
|
initialData: {},
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ useMount(() => {
|
|
|
|
|
+ run();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
const orderGoodsSpecs = useCreation(() => {
|
|
const orderGoodsSpecs = useCreation(() => {
|
|
|
return data.orderGoodsSpecs || [];
|
|
return data.orderGoodsSpecs || [];
|
|
|
}, [data]);
|
|
}, [data]);
|
|
@@ -58,6 +124,14 @@ export default function OrderDetailScreen({
|
|
|
}, 0);
|
|
}, 0);
|
|
|
}, [orderGoodsSpecs]);
|
|
}, [orderGoodsSpecs]);
|
|
|
|
|
|
|
|
|
|
+ const isRefund = useCreation(() => {
|
|
|
|
|
+ if (data.status === 'REFUNDED_PENDING') {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [data]);
|
|
|
|
|
+
|
|
|
function orderChange() {
|
|
function orderChange() {
|
|
|
alert(navigation, {
|
|
alert(navigation, {
|
|
|
msg: statusInfo.infoText,
|
|
msg: statusInfo.infoText,
|
|
@@ -91,8 +165,26 @@ export default function OrderDetailScreen({
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<Div bg="gray100" flex={1}>
|
|
<Div bg="gray100" flex={1}>
|
|
|
|
|
+ {/* <ModalDropdown ref={menu} options={['option 1', 'option 2']} /> */}
|
|
|
{statusInfo.type && statusInfo.type !== 'order' && (
|
|
{statusInfo.type && statusInfo.type !== 'order' && (
|
|
|
<Div row bg="white" py={12}>
|
|
<Div row bg="white" py={12}>
|
|
|
|
|
+ {__DEV__ &&
|
|
|
|
|
+ !isRefund &&
|
|
|
|
|
+ statusInfo.type &&
|
|
|
|
|
+ statusInfo.type !== 'order' && (
|
|
|
|
|
+ <Button
|
|
|
|
|
+ onPress={() => {
|
|
|
|
|
+ navigation.navigate('Modal', {
|
|
|
|
|
+ screen: 'Applay',
|
|
|
|
|
+ params: {
|
|
|
|
|
+ orderId,
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 取消订单
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ )}
|
|
|
<Div flex={1} alignItems="center">
|
|
<Div flex={1} alignItems="center">
|
|
|
<Text fontSize="xl" color="red500">
|
|
<Text fontSize="xl" color="red500">
|
|
|
{data.deliveryAmount}
|
|
{data.deliveryAmount}
|
|
@@ -300,7 +392,7 @@ export default function OrderDetailScreen({
|
|
|
{t('fen')}
|
|
{t('fen')}
|
|
|
</Text>
|
|
</Text>
|
|
|
<Text fontSize="sm" flex={1} color="red500" textAlign="right">
|
|
<Text fontSize="sm" flex={1} color="red500" textAlign="right">
|
|
|
- ¥{data.totalAmount || 0}
|
|
|
|
|
|
|
+ ¥{data.realAmount || 0}
|
|
|
</Text>
|
|
</Text>
|
|
|
</Div>
|
|
</Div>
|
|
|
|
|
|
|
@@ -338,26 +430,71 @@ export default function OrderDetailScreen({
|
|
|
</Button>
|
|
</Button>
|
|
|
)}
|
|
)}
|
|
|
</Div>
|
|
</Div>
|
|
|
- {(statusInfo.type === 'merchant' || statusInfo.type === 'user') && (
|
|
|
|
|
- <Button
|
|
|
|
|
- block
|
|
|
|
|
- mx={15}
|
|
|
|
|
- my={10}
|
|
|
|
|
- bg="yellow500"
|
|
|
|
|
- onPress={() => {
|
|
|
|
|
- goMap(
|
|
|
|
|
- statusInfo.type === 'merchant'
|
|
|
|
|
- ? data.merShowName
|
|
|
|
|
- : data.userAddress,
|
|
|
|
|
- statusInfo.type === 'merchant'
|
|
|
|
|
- ? changeCord(data.merLocation)
|
|
|
|
|
- : changeCord(data.location),
|
|
|
|
|
- navigation
|
|
|
|
|
- );
|
|
|
|
|
- }}
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <Div h={35} w="100%" />
|
|
|
|
|
+
|
|
|
|
|
+ {(statusInfo.type === 'merchant' || statusInfo.type === 'user') &&
|
|
|
|
|
+ !isRefund && (
|
|
|
|
|
+ <Div position="absolute" bottom={0} left={0} right={0}>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ block
|
|
|
|
|
+ mx={15}
|
|
|
|
|
+ my={10}
|
|
|
|
|
+ bg="yellow500"
|
|
|
|
|
+ onPress={() => {
|
|
|
|
|
+ goMap(
|
|
|
|
|
+ statusInfo.type === 'merchant'
|
|
|
|
|
+ ? data.merShowName
|
|
|
|
|
+ : data.userAddress,
|
|
|
|
|
+ statusInfo.type === 'merchant'
|
|
|
|
|
+ ? changeCord(data.merLocation)
|
|
|
|
|
+ : changeCord(data.location),
|
|
|
|
|
+ navigation
|
|
|
|
|
+ );
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ {t('cha-kan-dao-hang')}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Div>
|
|
|
|
|
+ )}
|
|
|
|
|
+
|
|
|
|
|
+ {isRefund && (
|
|
|
|
|
+ <Div
|
|
|
|
|
+ row
|
|
|
|
|
+ position="absolute"
|
|
|
|
|
+ bottom={0}
|
|
|
|
|
+ left={0}
|
|
|
|
|
+ right={0}
|
|
|
|
|
+ px={15}
|
|
|
|
|
+ py={10}
|
|
|
>
|
|
>
|
|
|
- {t('cha-kan-dao-hang')}
|
|
|
|
|
- </Button>
|
|
|
|
|
|
|
+ <Button flex={1} bg="gray300" disabled>
|
|
|
|
|
+ 订单申请取消中
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ w={105}
|
|
|
|
|
+ ml={5}
|
|
|
|
|
+ bg="yellow500"
|
|
|
|
|
+ onPress={() => {
|
|
|
|
|
+ Request.get('/orderRefundApply/cancel', {
|
|
|
|
|
+ params: {
|
|
|
|
|
+ orderId,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ toastSuccess('取消成功');
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((e) => {
|
|
|
|
|
+ toastInfo(e.error);
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ run();
|
|
|
|
|
+ });
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 撤销申请
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Div>
|
|
|
)}
|
|
)}
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|