|
|
@@ -4,9 +4,13 @@ import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
|
|
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
|
import { useRequest, useCreation } from 'ahooks';
|
|
|
import { RefreshControl } from 'react-native';
|
|
|
-import { toastInfo } from '../utils/SystemUtils';
|
|
|
+import { toastInfo, toastSuccess, alert } from '../utils/SystemUtils';
|
|
|
|
|
|
import { RiderStatusMap } from '../utils/RiderInfoUtils';
|
|
|
+import ImagePicker from '../components/ImagePicker';
|
|
|
+
|
|
|
+import useModel from 'flooks';
|
|
|
+import OrderModel from './model';
|
|
|
|
|
|
export default function OrderDetailScreen({
|
|
|
navigation,
|
|
|
@@ -15,11 +19,21 @@ export default function OrderDetailScreen({
|
|
|
const { params } = route;
|
|
|
const { orderId } = params;
|
|
|
|
|
|
- const { data, loading, reload } = useRequest(`/orderInfo/get/${orderId}`, {
|
|
|
- defaultLoading: false,
|
|
|
- debounceInterval: 1000,
|
|
|
- initialData: {},
|
|
|
- });
|
|
|
+ const [pickImg, setpickImg] = React.useState<string>('');
|
|
|
+
|
|
|
+ const { receiverOrder, changeStatus, changeStatusAll } = useModel(
|
|
|
+ OrderModel,
|
|
|
+ []
|
|
|
+ );
|
|
|
+
|
|
|
+ const { data, loading, reload, run } = useRequest(
|
|
|
+ `/orderInfo/get/${orderId}`,
|
|
|
+ {
|
|
|
+ defaultLoading: false,
|
|
|
+ debounceInterval: 1000,
|
|
|
+ initialData: {},
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
const orderGoodsSpecs = useCreation(() => {
|
|
|
return data.orderGoodsSpecs || [];
|
|
|
@@ -39,6 +53,37 @@ export default function OrderDetailScreen({
|
|
|
}, 0);
|
|
|
}, [orderGoodsSpecs]);
|
|
|
|
|
|
+ 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 (
|
|
|
<Div bg="gray100" flex={1}>
|
|
|
{statusInfo.type && statusInfo.type !== 'order' && (
|
|
|
@@ -88,6 +133,21 @@ export default function OrderDetailScreen({
|
|
|
{statusInfo.type && (
|
|
|
<>
|
|
|
<Div bg="white" rounded="xs" px={15} py={10}>
|
|
|
+ {statusInfo.type == 'user' && (
|
|
|
+ <Div row py={10}>
|
|
|
+ <Div flex={1}>
|
|
|
+ <Text fontSize="xl" fontWeight="bold" color="yellow500">
|
|
|
+ {statusInfo.name}
|
|
|
+ </Text>
|
|
|
+ <Text fontSize="sm" color="gray600" mt={2}>
|
|
|
+ 流水号:{data.id}
|
|
|
+ </Text>
|
|
|
+ </Div>
|
|
|
+ <Button bg="yellow500" w={112} onPress={orderChange}>
|
|
|
+ 确认送达
|
|
|
+ </Button>
|
|
|
+ </Div>
|
|
|
+ )}
|
|
|
{statusInfo.type === 'merchant' && (
|
|
|
<>
|
|
|
<Div row py={10}>
|
|
|
@@ -101,23 +161,30 @@ export default function OrderDetailScreen({
|
|
|
bg="yellow500"
|
|
|
w={112}
|
|
|
disabled={statusInfo.status != 0}
|
|
|
+ onPress={orderChange}
|
|
|
>
|
|
|
我已到店
|
|
|
</Button>
|
|
|
</Div>
|
|
|
|
|
|
{statusInfo.status === 1 && (
|
|
|
- <Div row py={10}>
|
|
|
- <Div flex={1}>
|
|
|
- <Text>我已取货</Text>
|
|
|
- <Text fontSize="sm" color="gray600" mt={2} pr={48}>
|
|
|
- 为避免货物纠纷,请在取货时 检查并拍照存证
|
|
|
- </Text>
|
|
|
+ <>
|
|
|
+ <Div row py={10}>
|
|
|
+ <Div flex={1}>
|
|
|
+ <Text>我已取货</Text>
|
|
|
+ <Text fontSize="sm" color="gray600" mt={2} pr={48}>
|
|
|
+ 为避免货物纠纷,请在取货时 检查并拍照存证
|
|
|
+ </Text>
|
|
|
+ </Div>
|
|
|
+ <Button bg="yellow500" w={112} onPress={orderChange}>
|
|
|
+ 拍照取货
|
|
|
+ </Button>
|
|
|
</Div>
|
|
|
- <Button bg="yellow500" w={112}>
|
|
|
- 拍照取货
|
|
|
- </Button>
|
|
|
- </Div>
|
|
|
+ <ImagePicker
|
|
|
+ img={pickImg}
|
|
|
+ setImg={(img) => setpickImg(img)}
|
|
|
+ />
|
|
|
+ </>
|
|
|
)}
|
|
|
</>
|
|
|
)}
|
|
|
@@ -248,6 +315,22 @@ export default function OrderDetailScreen({
|
|
|
})}
|
|
|
</Div>
|
|
|
</Div>
|
|
|
+
|
|
|
+ {statusInfo.type === 'order' && (
|
|
|
+ <Button
|
|
|
+ bg="yellow500"
|
|
|
+ w={112}
|
|
|
+ alignSelf="flex-end"
|
|
|
+ my={10}
|
|
|
+ onPress={() => {
|
|
|
+ receiverOrder(data.id, (res) => {
|
|
|
+ toastSuccess('接单成功');
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 接单
|
|
|
+ </Button>
|
|
|
+ )}
|
|
|
</Div>
|
|
|
{(statusInfo.type === 'merchant' || statusInfo.type === 'user') && (
|
|
|
<Button block mx={15} my={10} bg="yellow500">
|