Authored by chenl

增加银行卡图片处理和卡号*号处理。review by caomei。

@@ -31,8 +31,8 @@ export default class BankCardList extends React.Component { @@ -31,8 +31,8 @@ export default class BankCardList extends React.Component {
31 renderRow(rowData, sectionID, rowID, highlightRow) { 31 renderRow(rowData, sectionID, rowID, highlightRow) {
32 return ( 32 return (
33 <BankCardListCell 33 <BankCardListCell
34 - cardNo={"656132156465465"}  
35 - cardBank={"icbc"} 34 + cardNo={"6222024301058186063"}
  35 + cardBank={"ICBC"}
36 /> 36 />
37 ); 37 );
38 } 38 }
@@ -40,7 +40,7 @@ export default class BankCardList extends React.Component { @@ -40,7 +40,7 @@ export default class BankCardList extends React.Component {
40 render() { 40 render() {
41 41
42 42
43 - let cardList = ['65325165465321654','99999999999999']; 43 + let cardList = [{'cardNo':'6222024301058186063','cardBank':"ICBC"},{'cardNo':'6222024301058186063','cardBank':"BOC"}];
44 44
45 45
46 return ( 46 return (
@@ -20,13 +20,14 @@ export default class BankCardListCell extends React.Component { @@ -20,13 +20,14 @@ export default class BankCardListCell extends React.Component {
20 let{cardNo, cardBank} = this.props; 20 let{cardNo, cardBank} = this.props;
21 21
22 let bankImg = this.getBankImage(cardBank); 22 let bankImg = this.getBankImage(cardBank);
  23 + let newCardNo = this.processBankCardNo(cardNo);
23 24
24 return( 25 return(
25 <TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressCard && this.props.onPressCard()}> 26 <TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressCard && this.props.onPressCard()}>
26 <View style={styles.container} > 27 <View style={styles.container} >
27 <Image style={styles.cardBg} source={bankImg} /> 28 <Image style={styles.cardBg} source={bankImg} />
28 <Text style={styles.cardNo} numberOfLines={1}> 29 <Text style={styles.cardNo} numberOfLines={1}>
29 - {cardNo} 30 + {newCardNo}
30 </Text> 31 </Text>
31 </View> 32 </View>
32 </TouchableOpacity> 33 </TouchableOpacity>
@@ -34,17 +35,55 @@ export default class BankCardListCell extends React.Component { @@ -34,17 +35,55 @@ export default class BankCardListCell extends React.Component {
34 } 35 }
35 36
36 37
  38 + //正则替换卡号,保留后4位
  39 + processBankCardNo(cardNo){
  40 +
  41 + let newCardNo = cardNo.replace(/(\d+)(\d{4})$/, (a, b, c)=> {
  42 + return b.replace(/\d/g, '*') + c;
  43 + });
  44 +
  45 + return newCardNo;
  46 + }
  47 +
  48 +
37 getBankImage(bank){ 49 getBankImage(bank){
38 let bankImg; 50 let bankImg;
39 switch(bank){ 51 switch(bank){
  52 + case "ABC":
  53 + bankImg = require('../../image/bank/bank-ABC.png');
  54 + break;
  55 + case "BOC":
  56 + bankImg = require('../../image/bank/bank-BOC.png');
  57 + break;
  58 + case "CCB":
  59 + bankImg = require('../../image/bank/bank-CCB.png');
  60 + break;
  61 + case "CEB":
  62 + bankImg = require('../../image/bank/bank-CEB.png');
  63 + break;
  64 + case "CGB":
  65 + bankImg = require('../../image/bank/bank-CGB.png');
  66 + break;
  67 + case "CIB":
  68 + bankImg = require('../../image/bank/bank-CIB.png');
  69 + break;
40 case "CITIC": 70 case "CITIC":
41 bankImg = require('../../image/bank/bank-CITIC.png'); 71 bankImg = require('../../image/bank/bank-CITIC.png');
42 break; 72 break;
  73 + case "CMBC":
  74 + bankImg = require('../../image/bank/bank-CMBC.png');
  75 + break;
43 case "ICBC": 76 case "ICBC":
44 bankImg = require('../../image/bank/bank-ICBC.png'); 77 bankImg = require('../../image/bank/bank-ICBC.png');
45 break; 78 break;
  79 + case "PAYH":
  80 + bankImg = require('../../image/bank/bank-PAYH.png');
  81 + break;
  82 + case "PSBC":
  83 + bankImg = require('../../image/bank/bank-PSBC.png');
  84 + break;
46 default: 85 default:
47 - bankImg = require('../../image/bank/bank-ICBC.png'); 86 + bankImg = require('../../image/bank/bank-EMPTY.png');
48 break; 87 break;
49 } 88 }
50 return bankImg; 89 return bankImg;