panhui пре 5 година
родитељ
комит
8d4d70c25c

+ 2 - 1
locales/zh-CN.json

@@ -168,5 +168,6 @@
   "yu-ji-song-da-shi-jian": "预计送达时间",
   "yong-hu-shou-dao-shi-jian": "用户收到时间",
   "ben-dan-pai-song-shou-ru": "本单派送收入",
-  "shu-ru-zhen-shi-xing-ming": "输入真实姓名"
+  "shu-ru-zhen-shi-xing-ming": "输入真实姓名",
+  "lu-xian-gui-hua": "路线规划"
 }

+ 52 - 0
map/RoutePlanScreen.tsx

@@ -0,0 +1,52 @@
+import { StackScreenProps } from '@react-navigation/stack';
+import * as React from 'react';
+import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
+import { ScrollView } from 'react-native-gesture-handler';
+import { WebView } from 'react-native-webview';
+import { useTranslation } from 'react-i18next';
+import { useMount } from 'ahooks';
+import * as Linking from 'expo-linking';
+import {
+  toastShow,
+  toastHide,
+  toastInfo,
+  toastSuccess,
+} from '../utils/SystemUtils';
+import useModel from 'flooks';
+import MapModel from './model';
+import { tengxunKey } from '../utils/MapUtils';
+
+export default function RoutePlanScreen({ navigation, route }) {
+  const { t } = useTranslation();
+  const { getNowLocation } = useModel(MapModel, []);
+  const [mapUrl, setmapUrl] = React.useState<string>('');
+  const { params } = route;
+  const { toName, tocoord } = params;
+  useMount(() => {
+    toastShow();
+    console.log(params);
+    getNowLocation().then((res) => {
+      let location = '';
+      if (res.addressName !== '定位失败') {
+        location = `${res.location.lat},${res.location.lng}`;
+      }
+      // setmapUrl(
+      //   `https://apis.map.qq.com/uri/v1/routeplan?type=drive&fromcoord=${location}&to=${toName}&tocoord=${tocoord}&policy=1&referer=${tengxunKey}`
+      // );
+      toastHide();
+      
+    });
+  });
+  return (
+    <>
+      {/* {!!mapUrl && (
+        <WebView
+          source={{
+            uri: mapUrl,
+          }}
+          style={{ flexGrow: 1, width: '100%' }}
+        />
+      )} */}
+    </>
+  );
+}

+ 15 - 13
modals/AlertModalScreen.tsx

@@ -33,19 +33,21 @@ export default function AlertModalScreen({
           </Text>
 
           <Div row py={10} mt={10}>
-            <Button
-              flex={1}
-              mx={3}
-              rounded="xs"
-              bg="white"
-              color="black"
-              borderWidth={1}
-              borderColor="yellow500"
-              fontSize="sm"
-              onPress={() => navigation.goBack()}
-            >
-              {hasCancel ? t('qu-xiao') : submitText || t('que-ren')}
-            </Button>
+            {hasCancel && (
+              <Button
+                flex={1}
+                mx={3}
+                rounded="xs"
+                bg="white"
+                color="black"
+                borderWidth={1}
+                borderColor="yellow500"
+                fontSize="sm"
+                onPress={() => navigation.goBack()}
+              >
+                {hasCancel ? t('qu-xiao') : submitText || t('que-ren')}
+              </Button>
+            )}
             <Button
               flex={1}
               mx={3}

+ 6 - 0
navigation/OrderStackNavigator.tsx

@@ -16,6 +16,7 @@ import { OrderStackParamList } from '../types';
 
 import OrderDetailScreen from '../order/OrderDetailScreen';
 import OrderMapScreen from '../map/OrderMapScreen';
+import RoutePlanScreen from '../map/RoutePlanScreen';
 
 const OrderStack = createStackNavigator<OrderStackParamList>();
 export default function Navigation({
@@ -55,6 +56,11 @@ export default function Navigation({
         component={OrderMapScreen}
         options={{ title: t('di-tu') }}
       />
+      <OrderStack.Screen
+        name="RoutePlan"
+        component={RoutePlanScreen}
+        options={{ title: t('lu-xian-gui-hua') }}
+      />
     </OrderStack.Navigator>
   );
 }

+ 20 - 1
order/OrderDetailScreen.tsx

@@ -12,6 +12,9 @@ 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';
 
 export default function OrderDetailScreen({
   navigation,
@@ -336,7 +339,23 @@ export default function OrderDetailScreen({
               )}
             </Div>
             {(statusInfo.type === 'merchant' || statusInfo.type === 'user') && (
-              <Button block mx={15} my={10} bg="yellow500">
+              <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>
             )}

+ 13 - 8
order/OrderScreen.tsx

@@ -20,6 +20,7 @@ import { promot } from '../utils/SystemUtils';
 import { orderRiderStatus, RiderStatusMap } from '../utils/RiderInfoUtils';
 import request from '../utils/RequestUtils';
 import { toastSuccess, alert } from '../utils/SystemUtils';
+import { goMap, changeCord } from '../utils/MapUtils';
 
 import OrderCom from './OrderCom';
 
@@ -163,14 +164,18 @@ export default function OrderScreen({ navigation }: StackScreenProps) {
                   toastSuccess(t('jie-dan-cheng-gong'));
                 });
               }}
-              goMap={() =>
-                navigation.navigate('OrderStack', {
-                  screen: 'OrderMap',
-                  params: {
-                    orderId: item.id,
-                  },
-                })
-              }
+              goMap={() => {
+                const orderStatusInfo = RiderStatusMap.get(item.riderStatus);
+                goMap(
+                  orderStatusInfo.type === 'merchant'
+                    ? item.merShowName
+                    : item.userAddress,
+                  orderStatusInfo.type === 'merchant'
+                    ? changeCord(item.merLocation)
+                    : changeCord(item.location),
+                  navigation
+                );
+              }}
               changeStatus={() => {
                 const orderStatusInfo = RiderStatusMap.get(item.riderStatus);
 

+ 2 - 2
order/model.ts

@@ -47,7 +47,7 @@ const OrderMap = (now) => ({
         }
       })
       .catch((e) => {
-        if (e.error === '未到店' && errorEvent) {
+        if (e.error && errorEvent) {
           errorEvent();
         } else {
           toastInfo(e.error);
@@ -75,7 +75,7 @@ const OrderMap = (now) => ({
   changeStatusAll(orderId, status, successEvent) {
     toastShow();
     request
-      .get('/orderInfo/', {
+      .get('/orderInfo/mandatory', {
         params: {
           orderId,
           status,

+ 26 - 2
utils/MapUtils.ts

@@ -2,7 +2,8 @@ import * as Location from 'expo-location';
 import * as Permissions from 'expo-permissions';
 import * as TaskManager from 'expo-task-manager';
 import request from './RequestUtils';
-import { alert } from './TotastUtils';
+import { alert } from './SystemUtils';
+import * as Linking from 'expo-linking';
 
 const key = 'c4faf80125b298f93bbc1477db10e69c';
 const tengxunKey = 'GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K';
@@ -107,4 +108,27 @@ function mapMarks(params) {
   return `https://restapi.amap.com/v3/staticmap?zoom=15&size=500*500&paths=10,0x0000ff,1,,:116.31604,39.96491;116.320816,39.966606;116.321785,39.966827;116.32361,39.966957&key=${key}`;
 }
 
-export { getLocation, getSearch };
+function changeCord(lnglat) {
+  if (lnglat) {
+    const strs = lnglat.split(',');
+    return strs[1] + ',' + strs[0];
+  } else {
+    return ',';
+  }
+}
+
+function goMap(toName, tocoord, navigation) {
+  var url = `qqmap://map/routeplan?type=drive&to=${toName}&tocoord=${tocoord}&referer=${tengxunKey}`;
+  Linking.canOpenURL(url).then((res) => {
+    if (res) {
+      Linking.openURL(url);
+    } else {
+      alert(navigation, {
+        msg: '请下载腾讯地图app进行精准导航',
+        hasCancel: false,
+      });
+    }
+  });
+}
+
+export { getLocation, getSearch, tengxunKey, changeCord, goMap };

+ 2 - 2
utils/SystemUtils.ts

@@ -1,7 +1,7 @@
 import i18n from '../i18n';
 import * as Linking from 'expo-linking';
 
-import { Toast, ModalIndicator, PopoverPicker } from 'teaset';
+// import { Toast, ModalIndicator, PopoverPicker } from 'teaset';
 import { Platform } from 'react-native';
 
 function connect(navigation) {
@@ -84,5 +84,5 @@ export {
   toastSuccess,
   getMoney,
   alert,
-  PopoverPicker,
+  // PopoverPicker,
 };