You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

1 month ago
import { View, StyleSheet } from 'react-native';
import { useRoute, RouteProp } from '@react-navigation/native';
import { useEffect, useState } from 'react';
import { payApi, PaymentInfoResponse } from '../../services/api/payApi';
import { WebView } from "react-native-webview";
type PayScreenRouteProp = RouteProp<{
3 weeks ago
Pay: { payUrl: string };
1 month ago
}, 'Pay'>;
export const Pay = () => {
const [loading, setLoading] = useState(true);
const route = useRoute<PayScreenRouteProp>();
3 weeks ago
const {payUrl} = route.params;
1 month ago
const [payInfo, setPayInfo] = useState<PaymentInfoResponse>();
3 weeks ago
1 month ago
useEffect(() => {
3 weeks ago
console.log(route.params);
console.log(payUrl);
1 month ago
},[])
const handleNavigationStateChange = (navState: any) => {
console.log(navState);
}
return <View style={{ flex: 1 }}>
3 weeks ago
{payUrl ? (
1 month ago
<WebView
3 weeks ago
source={{ uri: payUrl }}
1 month ago
style={styles.webview}
onNavigationStateChange={handleNavigationStateChange}
onLoadStart={() => setLoading(true)}
onLoadEnd={() => setLoading(false)}
javaScriptEnabled={true}
domStorageEnabled={true}
startInLoadingState={true}
scalesPageToFit={true}
originWhitelist={['*']}
userAgent="Mozilla/5.0 (Linux; Android 10; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Mobile Safari/537.36"
onShouldStartLoadWithRequest={(request) => {
console.log(request);
// 允许所有请求
return true;
}}
/>
) : (
<View>
{/* Add fallback content here */}
</View>
)}
</View>
}
const styles = StyleSheet.create({
webview: {
flex: 1,
},
});