|
|
|
@ -10,11 +10,12 @@ import {
|
|
|
|
|
ActivityIndicator, |
|
|
|
|
Platform, |
|
|
|
|
StatusBar, |
|
|
|
|
SafeAreaView |
|
|
|
|
SafeAreaView, |
|
|
|
|
BackHandler |
|
|
|
|
} from "react-native"; |
|
|
|
|
import useCreateOrderStore from "../../store/createOrder"; |
|
|
|
|
import BackIcon from "../../components/BackIcon"; |
|
|
|
|
import { useNavigation, useRoute, RouteProp } from "@react-navigation/native"; |
|
|
|
|
import { useNavigation, useRoute, RouteProp, useFocusEffect } from "@react-navigation/native"; |
|
|
|
|
import { NativeStackNavigationProp } from "@react-navigation/native-stack"; |
|
|
|
|
import { useState, useEffect } from "react"; |
|
|
|
|
import useUserStore from "../../store/user"; |
|
|
|
@ -32,6 +33,7 @@ type RootStackParamList = {
|
|
|
|
|
amount: number; |
|
|
|
|
}; |
|
|
|
|
Pay: { payUrl: string }; |
|
|
|
|
OrderDetails: { orderId?: number }; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export const PreviewOrder = () => { |
|
|
|
@ -56,6 +58,22 @@ export const PreviewOrder = () => {
|
|
|
|
|
} |
|
|
|
|
}, [route.params.payMethod, user.user_id, t]); |
|
|
|
|
|
|
|
|
|
// 处理系统返回键
|
|
|
|
|
useFocusEffect( |
|
|
|
|
React.useCallback(() => { |
|
|
|
|
const onBackPress = () => { |
|
|
|
|
// 拦截系统返回键事件,导航到OrderDetails页面
|
|
|
|
|
navigation.navigate("OrderDetails", { orderId: 1 }); |
|
|
|
|
return true; // 返回true表示已处理返回事件
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 添加返回键监听(Android)
|
|
|
|
|
BackHandler.addEventListener('hardwareBackPress', onBackPress); |
|
|
|
|
|
|
|
|
|
return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress); |
|
|
|
|
}, [navigation]) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const handleSubmit = () => { |
|
|
|
|
if (showPhoneInput && !phoneNumber) { |
|
|
|
|
// Show error or alert if needed
|
|
|
|
@ -107,8 +125,8 @@ export const PreviewOrder = () => {
|
|
|
|
|
<View style={styles.container}> |
|
|
|
|
<View style={styles.titleContainer}> |
|
|
|
|
<View style={styles.backIconContainer}> |
|
|
|
|
<TouchableOpacity onPress={() => navigation.goBack()}> |
|
|
|
|
<BackIcon size={20} /> |
|
|
|
|
<TouchableOpacity onPress={() => navigation.navigate("OrderDetails", { orderId :1})}> |
|
|
|
|
<BackIcon size={fontSize(20)} /> |
|
|
|
|
</TouchableOpacity> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|