TopupPaythod.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /**
  2. * 钱包充值的支付方式列表
  3. * @邠心vbe on 2023/02/02
  4. */
  5. import React, { Component } from 'react';
  6. import { View, Text, StyleSheet, Image } from 'react-native';
  7. import Svg, { Path } from 'react-native-svg';
  8. import apiWallet from '../../api/apiWallet';
  9. import BadgeSelectItem from '../../components/BadgeSelectItem';
  10. import { ElevationObject } from '../../components/Button';
  11. export default class TopupPaythod extends Component {
  12. constructor(props) {
  13. super(props);
  14. this.state = {
  15. cIndex: 0,
  16. payTypeList: []
  17. };
  18. }
  19. componentDidMount() {
  20. this.getPayType();
  21. }
  22. getPayType() {
  23. apiWallet.getPayTypeList().then(res => {
  24. if (res.data) {
  25. this.setState({
  26. payTypeList: res.data
  27. });
  28. this.onChange(0);
  29. }
  30. }).catch(err => {
  31. });
  32. }
  33. changePayType(index) {
  34. this.setState({
  35. cIndex: index
  36. });
  37. this.onChange(index);
  38. }
  39. onChange(index) {
  40. if (this.props.onChange) {
  41. this.props.onChange(this.state.payTypeList[index]);
  42. }
  43. }
  44. getSecuryNumber(number, pk) {
  45. if (pk) {
  46. const last = number.substring(number.length - 8);
  47. var x = ''
  48. for (let i = 0; i < number.length - 8; i++) {
  49. x += 'X';
  50. }
  51. return x + last;
  52. } else {
  53. return " ";
  54. }
  55. }
  56. render() {
  57. return (
  58. <View style={styles.listView}>
  59. { this.state.payTypeList.map((item, index) => {
  60. return (
  61. <BadgeSelectItem
  62. key={index}
  63. style={[
  64. styles.paytypeView,
  65. index > 0 && styles.next
  66. ]}
  67. checked={index == this.state.cIndex}
  68. onPress={() => this.changePayType(index)}>
  69. <View style={$padding(12, 8, 8)}>
  70. <PaymentIcon method={item.fomoPayType} checked={index == this.state.cIndex}/>
  71. </View>
  72. <Text style={[styles.paytypeText, (index == this.state.cIndex && {color: colorAccent})]}>{item.payName}</Text>
  73. <Text style={styles.cardText}>{this.getSecuryNumber(item.payName, item.cardPk)}</Text>
  74. </BadgeSelectItem>
  75. );
  76. })
  77. }
  78. </View>
  79. );
  80. }
  81. }
  82. export const PaymentIcon = ({method="CARD", size=40, checked=false}) => {
  83. switch (method) {
  84. case "CARD":
  85. return (
  86. /*<Svg width="40" height="40" viewBox="0 0 40 40">
  87. <Path
  88. fill={checked ? colorAccent : "#666666"}
  89. d="M22.0532 16.1052C21.3736 16.8184 21 17.7567 21 18.7535V20.2465C21 21.2433 21.3736 22.1817 22.0532 22.8948C22.7327 23.608 23.6269 24 24.5768 24H37V15H24.5768C23.6269 15 22.7288 15.392 22.0532 16.1052ZM26.0392 17.8318C26.9175 17.8318 27.6289 18.5783 27.6289 19.5C27.6289 20.4217 26.9175 21.1682 26.0392 21.1682C25.161 21.1682 24.4496 20.4217 24.4496 19.5C24.4496 18.5783 25.161 17.8318 26.0392 17.8318Z"/>
  90. <Path
  91. fill={checked ? colorAccent : "#666666"}
  92. d="M32.2342 4H6.7697C4.1403 4 2 6.16334 2 8.82988V30.1701C2 32.8327 4.13639 35 6.7697 35H32.2303C34.8597 35 37 32.8367 37 30.1701V25.7563H24.7686C21.7557 25.7563 19.2907 23.2601 19.2907 20.2092V18.7908C19.2907 15.7399 21.7557 13.2437 24.7686 13.2437H37V8.82988C37 6.16731 34.8597 4 32.2342 4Z" />
  93. </Svg>*/
  94. <MaterialCommunityIcons
  95. name="credit-card-multiple"
  96. color={checked ? colorAccent : "#666666"}
  97. size={size}/>
  98. );
  99. case "PAYNOW":
  100. return (
  101. <Svg width={size} height={size} viewBox="0 0 40 40">
  102. <Path
  103. fill={checked ? colorAccent : "#666666"}
  104. d="M4 18.2222H7.55556V21.7778H4V18.2222ZM18.2222 7.55556H21.7778V14.6667H18.2222V7.55556ZM14.6667 18.2222H21.7778V25.3333H18.2222V21.7778H14.6667V18.2222ZM25.3333 18.2222H28.8889V21.7778H32.4444V18.2222H36V21.7778H32.4444V25.3333H36V32.4444H32.4444V36H28.8889V32.4444H21.7778V36H18.2222V28.8889H25.3333V25.3333H28.8889V21.7778H25.3333V18.2222ZM32.4444 32.4444V25.3333H28.8889V32.4444H32.4444ZM25.3333 4H36V14.6667H25.3333V4ZM28.8889 7.55556V11.1111H32.4444V7.55556H28.8889ZM4 4H14.6667V14.6667H4V4ZM7.55556 7.55556V11.1111H11.1111V7.55556H7.55556ZM4 25.3333H14.6667V36H4V25.3333ZM7.55556 28.8889V32.4444H11.1111V28.8889H7.55556Z"/>
  105. </Svg>
  106. )
  107. case "GRABPAY":
  108. return (
  109. <Image
  110. style={{width: size, height: size}}
  111. source={checked ? require('../../images/wallet/payment-grab-active.png') : require('../../images/wallet/payment-grab.png')}
  112. />
  113. );
  114. case "WALLET":
  115. return (
  116. <Svg width={size} height={size} viewBox="0 0 40 40">
  117. <Path
  118. fill={checked ? colorAccent : "#666666"}
  119. d="M22.0532 16.1052C21.3736 16.8184 21 17.7567 21 18.7535V20.2465C21 21.2433 21.3736 22.1817 22.0532 22.8948C22.7327 23.608 23.6269 24 24.5768 24H37V15H24.5768C23.6269 15 22.7288 15.392 22.0532 16.1052ZM26.0392 17.8318C26.9175 17.8318 27.6289 18.5783 27.6289 19.5C27.6289 20.4217 26.9175 21.1682 26.0392 21.1682C25.161 21.1682 24.4496 20.4217 24.4496 19.5C24.4496 18.5783 25.161 17.8318 26.0392 17.8318Z"/>
  120. <Path
  121. fill={checked ? colorAccent : "#666666"}
  122. d="M32.2342 4H6.7697C4.1403 4 2 6.16334 2 8.82988V30.1701C2 32.8327 4.13639 35 6.7697 35H32.2303C34.8597 35 37 32.8367 37 30.1701V25.7563H24.7686C21.7557 25.7563 19.2907 23.2601 19.2907 20.2092V18.7908C19.2907 15.7399 21.7557 13.2437 24.7686 13.2437H37V8.82988C37 6.16731 34.8597 4 32.2342 4Z"/>
  123. </Svg>
  124. )
  125. }
  126. }
  127. const styles = StyleSheet.create({
  128. listView: {
  129. flexWrap: 'wrap',
  130. flexDirection: 'row'
  131. },
  132. paytypeView: {
  133. flex: 1,
  134. alignItems: 'center',
  135. backgroundColor: colorLight,
  136. ...ElevationObject(5)
  137. },
  138. selected: {
  139. borderColor: colorPrimary
  140. },
  141. next: {
  142. marginLeft: 16,
  143. },
  144. paytypeText: {
  145. color: textPrimary,
  146. fontSize: 14,
  147. fontWeight: 'bold',
  148. paddingBottom: 14
  149. },
  150. cardText: {
  151. color: "#666",
  152. fontSize: 8,
  153. marginTop: -18,
  154. paddingBottom: 4
  155. },
  156. selectIcon: {
  157. width: 18,
  158. height: 18,
  159. },
  160. accountLogo: {
  161. width: 36,
  162. height: 18,
  163. marginRight: 32
  164. },
  165. });