|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import React from 'react'; |
|
|
|
|
import React from "react"; |
|
|
|
|
import { |
|
|
|
|
View, |
|
|
|
|
Text, |
|
|
|
@ -11,11 +11,16 @@ import {
|
|
|
|
|
Platform, |
|
|
|
|
StatusBar, |
|
|
|
|
SafeAreaView, |
|
|
|
|
BackHandler |
|
|
|
|
BackHandler, |
|
|
|
|
} from "react-native"; |
|
|
|
|
import useCreateOrderStore from "../../store/createOrder"; |
|
|
|
|
import BackIcon from "../../components/BackIcon"; |
|
|
|
|
import { useNavigation, useRoute, RouteProp, useFocusEffect } 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"; |
|
|
|
@ -34,7 +39,7 @@ type RootStackParamList = {
|
|
|
|
|
currency: string; |
|
|
|
|
amount: number; |
|
|
|
|
}; |
|
|
|
|
Pay: { payUrl: string }; |
|
|
|
|
Pay: { payUrl: string; method: string; order_id: string }; |
|
|
|
|
OrderDetails: { orderId?: number }; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -70,9 +75,10 @@ export const PreviewOrder = () => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 添加返回键监听(Android)
|
|
|
|
|
BackHandler.addEventListener('hardwareBackPress', onBackPress); |
|
|
|
|
BackHandler.addEventListener("hardwareBackPress", onBackPress); |
|
|
|
|
|
|
|
|
|
return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress); |
|
|
|
|
return () => |
|
|
|
|
BackHandler.removeEventListener("hardwareBackPress", onBackPress); |
|
|
|
|
}, [navigation]) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
@ -99,11 +105,16 @@ export const PreviewOrder = () => {
|
|
|
|
|
.getPayInfo(data) |
|
|
|
|
.then((res) => { |
|
|
|
|
if (res.success) { |
|
|
|
|
logPreviewOrder(navigation.getState().routes[navigation.getState().index - 1]?.name as string); |
|
|
|
|
logPreviewOrder( |
|
|
|
|
navigation.getState().routes[navigation.getState().index - 1] |
|
|
|
|
?.name as string |
|
|
|
|
); |
|
|
|
|
console.log(getBurialPointData()); |
|
|
|
|
|
|
|
|
|
navigation.replace("Pay", { |
|
|
|
|
payUrl: res.payment_url, |
|
|
|
|
method: route.params.payMethod, |
|
|
|
|
order_id: route.params.data.order_id.toString(), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -134,14 +145,18 @@ export const PreviewOrder = () => {
|
|
|
|
|
</TouchableOpacity> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<Text style={styles.titleHeading}>{t("order.preview.pay_now")}</Text> |
|
|
|
|
<Text style={styles.titleHeading}> |
|
|
|
|
{t("order.preview.pay_now")} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<ScrollView style={styles.scrollContainer}> |
|
|
|
|
<View style={styles.mainContent}> |
|
|
|
|
{/* Payment Method Section */} |
|
|
|
|
<View style={styles.section}> |
|
|
|
|
<Text style={styles.sectionTitle}>{t("order.preview.payment_method")}</Text> |
|
|
|
|
<Text style={styles.sectionTitle}> |
|
|
|
|
{t("order.preview.payment_method")} |
|
|
|
|
</Text> |
|
|
|
|
<View style={styles.paymentMethodContainer}> |
|
|
|
|
<Text style={styles.paymentMethodText}> |
|
|
|
|
{route.params.payMethod} |
|
|
|
@ -150,7 +165,9 @@ export const PreviewOrder = () => {
|
|
|
|
|
|
|
|
|
|
{showPhoneInput && ( |
|
|
|
|
<View style={styles.phoneInputContainer}> |
|
|
|
|
<Text style={styles.phoneInputLabel}>{t("order.preview.enter_phone")}</Text> |
|
|
|
|
<Text style={styles.phoneInputLabel}> |
|
|
|
|
{t("order.preview.enter_phone")} |
|
|
|
|
</Text> |
|
|
|
|
<TextInput |
|
|
|
|
style={styles.phoneInput} |
|
|
|
|
value={phoneNumber} |
|
|
|
@ -164,17 +181,23 @@ export const PreviewOrder = () => {
|
|
|
|
|
|
|
|
|
|
{/* Order Info Section */} |
|
|
|
|
<View style={styles.section}> |
|
|
|
|
<Text style={styles.sectionTitle}>{t("order.preview.payment_info")}</Text> |
|
|
|
|
<Text style={styles.sectionTitle}> |
|
|
|
|
{t("order.preview.payment_info")} |
|
|
|
|
</Text> |
|
|
|
|
|
|
|
|
|
<View style={styles.infoRow}> |
|
|
|
|
<Text style={styles.infoLabel}>{t("order.preview.name")}</Text> |
|
|
|
|
<Text style={styles.infoLabel}> |
|
|
|
|
{t("order.preview.name")} |
|
|
|
|
</Text> |
|
|
|
|
<Text style={styles.infoValue}> |
|
|
|
|
{route.params?.data.receiver_name || "N/A"} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<View style={styles.infoRow}> |
|
|
|
|
<Text style={styles.infoLabel}>{t("order.preview.phone")}</Text> |
|
|
|
|
<Text style={styles.infoLabel}> |
|
|
|
|
{t("order.preview.phone")} |
|
|
|
|
</Text> |
|
|
|
|
<Text style={styles.infoValue}> |
|
|
|
|
{route.params?.data.receiver_phone || "N/A"} |
|
|
|
|
</Text> |
|
|
|
@ -190,14 +213,18 @@ export const PreviewOrder = () => {
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
<View style={styles.infoRow}> |
|
|
|
|
<Text style={styles.infoLabel}>{t("order.preview.country")}</Text> |
|
|
|
|
<Text style={styles.infoLabel}> |
|
|
|
|
{t("order.preview.country")} |
|
|
|
|
</Text> |
|
|
|
|
<Text style={styles.infoValue}> |
|
|
|
|
{route.params?.data.receiver_country || "N/A"} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<View style={styles.infoRow}> |
|
|
|
|
<Text style={styles.infoLabel}>{t("order.preview.shipping_address")}</Text> |
|
|
|
|
<Text style={styles.infoLabel}> |
|
|
|
|
{t("order.preview.shipping_address")} |
|
|
|
|
</Text> |
|
|
|
|
<Text style={styles.infoValue}> |
|
|
|
|
{route.params?.data.receiver_address || "N/A"} |
|
|
|
|
</Text> |
|
|
|
@ -224,11 +251,16 @@ export const PreviewOrder = () => {
|
|
|
|
|
|
|
|
|
|
{/* Order Summary Section */} |
|
|
|
|
<View style={styles.section}> |
|
|
|
|
<Text style={styles.sectionTitle}>{t("order.preview.order_total")}</Text> |
|
|
|
|
<Text style={styles.sectionTitle}> |
|
|
|
|
{t("order.preview.order_total")} |
|
|
|
|
</Text> |
|
|
|
|
<View style={styles.totalRow}> |
|
|
|
|
<Text style={styles.totalLabel}>{t("order.preview.total_amount")}</Text> |
|
|
|
|
<Text style={styles.totalLabel}> |
|
|
|
|
{t("order.preview.total_amount")} |
|
|
|
|
</Text> |
|
|
|
|
<Text style={styles.totalValue}> |
|
|
|
|
{route.params.data.actual_amount} {route.params.data.currency} |
|
|
|
|
{route.params.data.actual_amount}{" "} |
|
|
|
|
{route.params.data.currency} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
@ -249,7 +281,9 @@ export const PreviewOrder = () => {
|
|
|
|
|
{loading ? ( |
|
|
|
|
<ActivityIndicator size="small" color="#ffffff" /> |
|
|
|
|
) : ( |
|
|
|
|
<Text style={styles.buttonText}>{t("order.preview.confirm_payment")}</Text> |
|
|
|
|
<Text style={styles.buttonText}> |
|
|
|
|
{t("order.preview.confirm_payment")} |
|
|
|
|
</Text> |
|
|
|
|
)} |
|
|
|
|
</TouchableOpacity> |
|
|
|
|
</View> |
|
|
|
@ -262,15 +296,15 @@ export const PreviewOrder = () => {
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
|
safeArea: { |
|
|
|
|
flex: 1, |
|
|
|
|
backgroundColor: '#fff', |
|
|
|
|
backgroundColor: "#fff", |
|
|
|
|
}, |
|
|
|
|
safeAreaContent: { |
|
|
|
|
flex: 1, |
|
|
|
|
paddingTop: Platform.OS === 'android' ? 0 : 0, |
|
|
|
|
paddingTop: Platform.OS === "android" ? 0 : 0, |
|
|
|
|
}, |
|
|
|
|
container: { |
|
|
|
|
flex: 1, |
|
|
|
|
backgroundColor: '#fff', |
|
|
|
|
backgroundColor: "#fff", |
|
|
|
|
}, |
|
|
|
|
scrollContainer: { |
|
|
|
|
flex: 1, |
|
|
|
|