| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /**
- * 网页支付页面
- * @邠心vbe on 2022/01/10
- */
- import React, { Component } from 'react';
- import { View, AppState, Linking } from 'react-native';
- export default class PaymentWeb extends Component {
- constructor(props) {
- super(props);
- this.state = {
- isCallback: false,
- paymentInfo: {
- url: '',
- amount: 0,
- type: ''
- }
- };
- this.canBack = false;
- this.stateListener;
- }
- componentDidMount() {
- const param = this.props.route.params
- console.log('PaymentWeb', param);
- if (param.url) {
- this.setState({
- isCallback: true,
- paymentInfo: param
- }, () => Linking.openURL(param.url));
- }
- this.stateListener = AppState.addEventListener("change", state => {
- if (state == 'active' && this.state.isCallback) {
- console.log(state);
- this.setState({
- isCallback: false
- }, () => {
- setTimeout(() => {
- goBack();
- }, 500);
- });
- }
- });
- /*this.props.navigation.addListener('beforeRemove', e => {
- if (!this.canBack) {
- if (this.state.isRepay) {
- this.onReset();
- e.preventDefault();
- } else if (this.state.isReturn) {
- this.canBack = true;
- goBack();
- setTimeout(() => {
- goBack();
- }, 100);
- } else {
- this.onClose();
- e.preventDefault();
- }
- }
- })*/
- }
- componentWillUnmount() {
- if (this.stateListener) {
- this.stateListener.remove();
- }
- }
- render() {
- return (
- <View>
-
- </View>
- );
- }
- }
|