panhui 5 tahun lalu
induk
melakukan
c1181e2917

+ 0 - 43
MapHtml/ChooseMap.html

@@ -1,43 +0,0 @@
-<html>
-
-<head lang="zh-CN">
-	<meta charset="UTF-8">
-	<meta name="viewport"
-		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
-	<meta name="mobile-web-app-capable" content="yes">
-	<meta name="apple-mobile-web-app-capable" content="yes">
-	<meta name="apple-mobile-web-app-status-bar-style" content="black">
-	<meta name="format-detection" content="address=no">
-	<script type="text/javascript"
-		src="https://3gimg.qq.com/lightmap/components/locationPicker2/js/main-62c2e3b971.js"></script>
-	<title>locationPicker Components Demo - iframe</title>
-	<style>
-		* {
-			margin: 0;
-			padding: 0;
-		}
-
-		body,
-		html {
-			overflow: hidden;
-		}
-	</style>
-
-</head>
-
-<body>
-	<!-- 通过 iframe 嵌入地图选点组件 -->
-	<iframe id="iframe" style="width:100vw;height:100vh" frameborder=0 scrolling="no"
-		src="https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K&referer=Dingdong">
-	</iframe>
-
-	<script>
-
-		window.addEventListener('message', function (event) {
-			var loc = event.data;
-			window.ReactNativeWebView.postMessage(JSON.stringify(loc))
-		}, false);
-
-
-	</script>
-</body>

+ 0 - 11
MapHtml/MapImage.html

@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-	<meta charset="UTF-8">
-	<meta name="viewport" content="width=device-width, initial-scale=1.0">
-	<title>Document</title>
-</head>
-<body>
-	<img src="https://apis.map.qq.com/ws/staticmap/v2/?center=39.8802147,116.415794&zoom=12&size=200*200&maptype=roadmap&key=GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K" alt="">
-</body>
-</html>

+ 0 - 31
MapHtml/MapMarkerDetail.html

@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-	<meta charset="UTF-8">
-	<meta name="viewport" content="width=device-width, initial-scale=1.0">
-	<meta http-equiv="X-UA-Compatible" content="ie=edge">
-	<title>DOMOverlay</title>
-</head>
-<script charset="utf-8"
-	src="https://map.qq.com/api/gljs?libraries=tools&v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
-<style type="text/css">
-	html,
-	body {
-		height: 100%;
-		margin: 0px;
-		padding: 0px;
-	}
-
-	#container {
-		width: 100%;
-		height: 100%;
-	}
-</style>
-
-<body>
-
-	<iframe src="http://dingdong.izouma.com/map/home" id='container' frameborder="0"></iframe>
-</body>
-
-</html>

+ 17 - 18
Utils/MapUtils.js

@@ -58,24 +58,23 @@ async function getLocation() {
       }
     })
     .catch((e) => {
-      return request.get(
-        `https://apis.map.qq.com/ws/location/v1/ip?key=${tengxunKey}`
-      );
-    })
-    .then((res) => {
-      return Promise.resolve({
-        addressName: '定位失败',
-        location: res.result.location,
-      });
-    })
-    .catch((e) => {
-      return Promise.resolve({
-        addressName: '定位失败',
-        location: {
-          lat,
-          lng,
-        },
-      });
+      return request
+        .get(`https://apis.map.qq.com/ws/location/v1/ip?key=${tengxunKey}`)
+        .then((res) => {
+          return Promise.resolve({
+            addressName: '定位失败',
+            location: res.result.location,
+          });
+        })
+        .catch((e) => {
+          return Promise.resolve({
+            addressName: '定位失败',
+            location: {
+              lat,
+              lng,
+            },
+          });
+        });
     });
 }
 

+ 22 - 4
chat/ChatScreen.tsx

@@ -4,7 +4,7 @@ import { Platform, View, KeyboardAvoidingView } from 'react-native';
 import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
 import { GiftedChat } from 'react-native-gifted-chat';
 import { ScrollView } from 'react-native-gesture-handler';
-import { useRequest } from '@umijs/hooks';
+import { useRequest, useMount } from '@umijs/hooks';
 import { useTranslation } from 'react-i18next';
 import * as Localization from 'expo-localization';
 import useModel from 'flooks';
@@ -14,7 +14,7 @@ import { parse } from '../Utils/TimeFnUtils.ts';
 
 export default function ChatScreen({ navigation, route }: StackScreenProps) {
   const { params } = route;
-  const { toUserId, toUserName } = params;
+  const { toUserId, toUserName, type } = params;
   const { t } = useTranslation();
 
   if (toUserName) {
@@ -35,6 +35,7 @@ export default function ChatScreen({ navigation, route }: StackScreenProps) {
   const { loading, run } = useRequest(
     `/chat/showChat?userOne=${id}&userTwo=${toUserId}`,
     {
+      manual: true,
       defaultLoading: false,
       initialData: [],
       onSuccess: (data) => {
@@ -61,6 +62,23 @@ export default function ChatScreen({ navigation, route }: StackScreenProps) {
     }
   }, [chatInfo]);
 
+  useMount(() => {
+    run().then(() => {
+      console.log(type);
+      if (type === 'Reminder') {
+        onSend([
+          {
+            text: `${userInfo.nickname}催单了`,
+            user: {
+              _id: userInfo.id,
+              avatar: userInfo.avatar,
+            },
+          },
+        ]);
+      }
+    });
+  });
+
   // eslint-disable-next-line no-shadow
   const onSend = useCallback((messages = []) => {
     console.log(messages);
@@ -71,7 +89,7 @@ export default function ChatScreen({ navigation, route }: StackScreenProps) {
   }, []);
 
   return (
-    <Div flex={1}>
+    <Div flex={1} bg="gray100">
       <GiftedChat
         placeholder={t('qing-shu-ru-liao-tian-nei-rong')}
         messages={messages}
@@ -83,7 +101,7 @@ export default function ChatScreen({ navigation, route }: StackScreenProps) {
           avatar: userInfo.avatar,
         }}
       />
-      {Platform.OS === 'android' && <KeyboardAvoidingView behavior="padding" />}
+      {/* {Platform.OS === 'android' && <KeyboardAvoidingView behavior="padding" />} */}
     </Div>
   );
 }

+ 2 - 1
locales/zh-CN.json

@@ -239,5 +239,6 @@
   "man-jian-you-hui": "满减优惠",
   "zhe-kou-shang-jia": "折扣商家",
   "xia-dan-fan-hong-bao": "下单返红包",
-  "ke-yong-hong-bao": "可用红包"
+  "ke-yong-hong-bao": "可用红包",
+  "qing-shu-ru-liao-tian-nei-rong": "请输入聊天内容"
 }

+ 2 - 2
screens/Main/Home/MerchantCom.js

@@ -171,7 +171,7 @@ export default function MerchantCom(props) {
                   </View>
                 )}
               </Flex>
-              <Flex style={styles.label2}>
+              {/* <Flex style={styles.label2}>
                 <Chip size="mini" color="#FFE3B9" fontColor="#FF0000">
                   {t(
                     'xi-huan-nin-lai-jin-gong-men-xi-huan-nin-lai-jin-gong-men'
@@ -180,7 +180,7 @@ export default function MerchantCom(props) {
                 <Chip size="mini" color="#FFE3B9" fontColor="#FF0000">
                   “喜欢您来金拱门喜欢您来金拱门”
                 </Chip>
-              </Flex>
+              </Flex> */}
               <Flex style={styles.label2} wrap="wrap">
                 <Chip size="mini" outline color="#FF0000">
                   12{t('jian')}5

+ 41 - 6
screens/Map/MapScreen.jsx

@@ -7,20 +7,55 @@ import { useCreation } from '@umijs/hooks';
 export default function MapScreen({ orderInfo }) {
   // console.log(orderInfo);
 
-  const { location, merchant, status, merchantStatus, riderStatus } = orderInfo;
+  const webRef = React.useRef();
+
+  const { location, merLocation, ridLocation } = orderInfo;
 
   const merchantLocation = useCreation(() => {
-    if (merchant) {
-      return `${merchant.longitude},${merchant.latitude}`;
+    if (merLocation) {
+      return {
+        lat: merLocation.split(',')[1],
+        lng: merLocation.split(',')[0],
+      };
+    } else {
+      return null;
+    }
+  }, [merLocation]);
+  const userLocation = useCreation(() => {
+    if (location) {
+      return {
+        lat: location.split(',')[1],
+        lng: location.split(',')[0],
+      };
     } else {
-      return '';
+      return null;
     }
-  }, [merchant]);
+  }, [location]);
+  const riderLocation = useCreation(() => {
+    if (ridLocation) {
+      return {
+        lat: ridLocation.split(',')[1],
+        lng: ridLocation.split(',')[0],
+      };
+    } else {
+      return null;
+    }
+  }, [ridLocation]);
 
   return (
     <WebView
+      ref={webRef}
       source={{
-        uri: `http://dingdong.izouma.com/map/home?location=${location}&merchantLocation=${merchantLocation}&status=${status}&merchantStatus=${merchantStatus}&riderStatus=${riderStatus}`,
+        uri: `http://dingdong.izouma.com/map/home`,
+      }}
+      onLoad={() => {
+        webRef.current.injectJavaScript(
+          `window.setLocation(${JSON.stringify(orderInfo)},${JSON.stringify(
+            userLocation
+          )},${JSON.stringify(merchantLocation)},${JSON.stringify(
+            ridLocation
+          )})`
+        );
       }}
     />
   );

+ 10 - 2
screens/Map/SearchMapScreen.jsx

@@ -17,7 +17,7 @@ export default function MapScreen({ navigation }) {
     'locationInfo',
   ]);
   const { location } = locationInfo;
-
+  const webRef = React.useRef();
   const [pageType, setpageType] = React.useState('homeSearch');
 
   const route = useRoute();
@@ -53,8 +53,9 @@ export default function MapScreen({ navigation }) {
         <Div w={56} h={56} />
       </Appbar.Header>
       <WebView
+        ref={webRef}
         source={{
-          uri: `http://dingdong.izouma.com/map/chooseLocation?location=${location.lat},${location.lng}`,
+          uri: `http://dingdong.izouma.com/map/chooseLocation`,
         }}
         style={{ flexGrow: 1, width: '100%' }}
         onMessage={({ nativeEvent }) => {
@@ -71,6 +72,13 @@ export default function MapScreen({ navigation }) {
             });
           }
         }}
+        onLoad={() => {
+          webRef.current.injectJavaScript(
+            `window.setLocation('${
+              location ? `${location.lat},${location.lng}` : ''
+            }')`
+          );
+        }}
       />
     </>
   );

+ 3 - 3
screens/Order/EvaluateScreen.jsx

@@ -79,7 +79,7 @@ export default function EvaluateScreen({ navigation }) {
     tagEvent.reset();
   }, [choose]);
 
-  const { merchant, merchantId, riderId } = orderInfo;
+  const { merShowName, merchantId, riderId, merLogo } = orderInfo;
 
   useRequest(() => `/orderInfo/get/${orderId}`, {
     refreshDeps: [orderId],
@@ -188,11 +188,11 @@ export default function EvaluateScreen({ navigation }) {
               w={40}
               rounded="sm"
               source={{
-                uri: merchant.logo,
+                uri: merLogo,
               }}
             />
             <Text fontSize="xl" fontWeight="bold" flex={1} mx={8}>
-              {merchant.showName || ' '}
+              {merShowName || ' '}
             </Text>
             <Text fontSize="xs" color="gray300" textAlign="left">
               {t('yi-dui-shang-jia-ni-ming')}

+ 25 - 18
screens/Order/OrderDetailScreen.jsx

@@ -115,6 +115,14 @@ export default function OrderScreen({ navigation }) {
     }
   }, [orderInfo]);
 
+  const hasRider = useCreation(() => {
+    if (orderInfo.riderStatus !== 'NOT_RECEIVED' && orderInfo.riderStatus) {
+      return true;
+    } else {
+      return false;
+    }
+  });
+
   const detailRef = React.useRef();
   const pan = React.useRef(new Animated.ValueXY()).current;
   const minMove = React.useRef(new Animated.Value(0)).current;
@@ -322,7 +330,7 @@ export default function OrderScreen({ navigation }) {
                   {t('lian-xi-ke-fu')}
                 </Button>
 
-                {!finish && orderInfo.riderStatus !== 'NOT_RECEIVED' && (
+                {!finish && hasRider && (
                   <Button
                     fontSize="xs"
                     flex={1}
@@ -333,12 +341,12 @@ export default function OrderScreen({ navigation }) {
                     borderWidth={1}
                     rounded={3}
                     onPress={(e) => {
-                      if (!orderInfo.mUserId) {
+                      if (!orderInfo.ruserId) {
                         warnning('骑手信息有误请联系客服');
                       } else {
                         navigation.navigate('Chat', {
-                          toUserId: orderInfo.mUserId,
-                          toUserName: orderInfo.merShowName,
+                          toUserId: orderInfo.ruserId,
+                          toUserName: orderInfo.riderName,
                         });
                       }
                       console.log(e);
@@ -358,11 +366,11 @@ export default function OrderScreen({ navigation }) {
                     borderWidth={1}
                     rounded={3}
                     onPress={() => {
-                      if (!orderInfo.mUserId) {
+                      if (!orderInfo.muserId) {
                         warnning('商家信息有误请联系客服帮你催单');
                       } else {
                         navigation.navigate('Chat', {
-                          toUserId: orderInfo.mUserId,
+                          toUserId: orderInfo.muserId,
                           toUserName: orderInfo.merShowName,
                           type: 'Reminder',
                         });
@@ -428,13 +436,12 @@ export default function OrderScreen({ navigation }) {
                   rounded={3}
                   ml={14}
                   onPress={() => {
-                    if (!orderInfo.mUserId) {
+                    if (!orderInfo.muserId) {
                       warnning('商家信息有误请联系客服帮你催单');
                     } else {
                       navigation.navigate('Chat', {
-                        toUserId: orderInfo.mUserId,
+                        toUserId: orderInfo.muserId,
                         toUserName: orderInfo.merShowName,
-                        type: 'Reminder',
                       });
                     }
                   }}
@@ -561,7 +568,7 @@ export default function OrderScreen({ navigation }) {
                     {orderInfo.userAddress}
                   </Text>
                 </Flex>
-                {orderInfo.riderStatus !== 'NOT_RECEIVED' && (
+                {hasRider && (
                   <Flex style={styles.info2}>
                     <Flex.Item>
                       <Text fontSize="xs" textAlign="left">
@@ -578,14 +585,14 @@ export default function OrderScreen({ navigation }) {
                         borderWidth={1}
                         rounded={3}
                         onPress={() => {
-                           if (!orderInfo.mUserId) {
-                             warnning('骑手信息有误请联系客服');
-                           } else {
-                             navigation.navigate('Chat', {
-                               toUserId: orderInfo.mUserId,
-                               toUserName: orderInfo.merShowName,
-                             });
-                           }
+                          if (!orderInfo.muserId) {
+                            warnning('骑手信息有误请联系客服');
+                          } else {
+                            navigation.navigate('Chat', {
+                              toUserId: orderInfo.muserId,
+                              toUserName: orderInfo.merShowName,
+                            });
+                          }
                         }}
                       >
                         {t('lian-xi-qi-shou')}

+ 8 - 1
screens/Order/OrderScreen.jsx

@@ -64,7 +64,14 @@ export default function OrderScreen({ navigation }) {
             index={index}
             connect={(type) => {
               if (type === 'merchant') {
-                warnning(t('connect1'));
+                if (!item.muserId) {
+                  warnning('商家信息有误请联系客服帮你催单');
+                } else {
+                  navigation.navigate('Chat', {
+                    toUserId: item.muserId,
+                    toUserName: item.merShowName,
+                  });
+                }
               }
             }}
           />