TopupPaythod.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * 钱包充值的支付方式列表
  3. * @邠心vbe on 2023/02/02
  4. */
  5. import React, { Component } from 'react';
  6. import { View, Text, StyleSheet } from 'react-native';
  7. import apiWallet from '../../api/apiWallet';
  8. import BadgeSelectItem from '../../components/BadgeSelectItem';
  9. import { ElevationObject } from '../../components/Button';
  10. import TextView from '../../components/TextView';
  11. import { PaymentIcon } from '../payment/PaymentConfig';
  12. export default class TopupPaythod extends Component {
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. cIndex: 0,
  17. payTypeList: []
  18. };
  19. }
  20. componentDidMount() {
  21. this.getPayType();
  22. }
  23. getPayType() {
  24. apiWallet.getPayTypeList().then(res => {
  25. if (res.data) {
  26. this.setState({
  27. payTypeList: res.data
  28. });
  29. this.onChange(0);
  30. }
  31. }).catch(err => {
  32. });
  33. }
  34. changePayType(index) {
  35. this.setState({
  36. cIndex: index
  37. });
  38. this.onChange(index);
  39. }
  40. onChange(index) {
  41. if (this.props.onChange) {
  42. this.props.onChange(this.state.payTypeList[index]);
  43. }
  44. }
  45. getSecuryNumber(number, pk) {
  46. if (pk) {
  47. const last = number.substring(number.length - 8);
  48. var x = ''
  49. for (let i = 0; i < number.length - 8; i++) {
  50. x += 'X';
  51. }
  52. return x + last;
  53. } else {
  54. return " ";
  55. }
  56. }
  57. render() {
  58. return (
  59. <View style={styles.listView}>
  60. { this.state.payTypeList.map((item, index) => {
  61. return (
  62. <BadgeSelectItem
  63. key={index}
  64. style={[
  65. styles.paytypeView,
  66. index > 0 && styles.next
  67. ]}
  68. checked={index == this.state.cIndex}
  69. onPress={() => this.changePayType(index)}>
  70. { this.props.showIcon &&
  71. <View style={$padding(12, 8, 8)}>
  72. <PaymentIcon method={item.fomoPayType} checked={index == this.state.cIndex}/>
  73. </View>
  74. }
  75. <TextView style={[styles.paytypeText, (index == this.state.cIndex && {color: colorAccent})]}>{item.payName}</TextView>
  76. {/* <TextView style={styles.cardText}>{this.getSecuryNumber(item.payName, item.cardPk)}</TextView> */}
  77. </BadgeSelectItem>
  78. );
  79. })
  80. }
  81. </View>
  82. );
  83. }
  84. }
  85. const styles = StyleSheet.create({
  86. listView: {
  87. /*flexWrap: 'wrap',
  88. flexDirection: 'row'*/
  89. },
  90. paytypeView: {
  91. //flex: 1,
  92. alignItems: 'center',
  93. backgroundColor: colorLight,
  94. ...ElevationObject(5)
  95. },
  96. selected: {
  97. borderColor: colorPrimary
  98. },
  99. next: {
  100. marginTop: 16,
  101. },
  102. paytypeText: {
  103. color: textPrimary,
  104. fontSize: 16,
  105. fontWeight: 'bold',
  106. padding: 18
  107. },
  108. cardText: {
  109. color: "#666",
  110. fontSize: 8,
  111. marginTop: -18,
  112. paddingBottom: 4
  113. },
  114. selectIcon: {
  115. width: 18,
  116. height: 18,
  117. },
  118. accountLogo: {
  119. width: 36,
  120. height: 18,
  121. marginRight: 32
  122. },
  123. });