/** * 输入信用卡信息页面 * @邠心vbe on 2021/06/09 */ import React, { Component } from 'react'; import { View, Text, StyleSheet, TextInput, KeyboardAvoidingView } from 'react-native'; import Button from '../../components/Button'; import apiWallet from '../../api/apiWallet'; import Dialog from '../../components/Dialog'; import { PageList } from '../Router'; export default class FormCard extends Component { constructor(props) { super(props); this.state = { amount: 0, payType: '', payUrl: 'http://www.taobao.com', validTill: '', isUrlPage: false }; this.form = {} } componentDidMount() { if (this.props.route.params.amount) { this.setState({ amount: this.props.route.params.amount, payType: this.props.route.params.payType }); } } validate() { if (!this.form.nameOnCard) { toastShort($t('payment.plsInputCardName')); return; } if (!this.form.cardNumber) { toastShort($t('payment.plsInputCardNo')); return; } if (!/^\d{9,}$/.test(this.form.cardNumber)) { toastShort($t('payment.errInputCardNo')); return; } if (!this.state.validTill) { toastShort($t('payment.plsInputTill')); return; } if (!/^(0[1-9]|1[0-2])\/(2[1-9]|[3-5][0-9])/.test(this.state.validTill)) { toastShort($t('payment.errInputTill')); return; } if (!this.form.cardCvv) { toastShort($t('payment.plsInputCvv')); return; } if (!/^\d{3}$/.test(this.form.cardCvv)) { toastShort($t('payment.errInputCvv')); return; } const params = this.form; params.validTill = this.state.validTill; this.topup(params); } topup(params) { const topup = { payAmount: this.state.amount, fomoPayType: this.state.payType, userCard: params } Dialog.showProgressDialog(); apiWallet.doPayment(topup).then(res => { Dialog.dismissLoading(); if (res.data.fomoId && res.data.url) { startPage(PageList.paycard, { url: res.data.url }) } }).catch(err => { Dialog.dismissLoading(); toastShort(err); }); } render() { return ( this.state.isUrlPage ? {currency+' '} {this.state.amount} {$t('wallet.topUp')}