Authored by chenl

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

... ... @@ -31,8 +31,8 @@ export default class BankCardList extends React.Component {
renderRow(rowData, sectionID, rowID, highlightRow) {
return (
<BankCardListCell
cardNo={"656132156465465"}
cardBank={"icbc"}
cardNo={"6222024301058186063"}
cardBank={"ICBC"}
/>
);
}
... ... @@ -40,7 +40,7 @@ export default class BankCardList extends React.Component {
render() {
let cardList = ['65325165465321654','99999999999999'];
let cardList = [{'cardNo':'6222024301058186063','cardBank':"ICBC"},{'cardNo':'6222024301058186063','cardBank':"BOC"}];
return (
... ...
... ... @@ -20,13 +20,14 @@ export default class BankCardListCell extends React.Component {
let{cardNo, cardBank} = this.props;
let bankImg = this.getBankImage(cardBank);
let newCardNo = this.processBankCardNo(cardNo);
return(
<TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressCard && this.props.onPressCard()}>
<View style={styles.container} >
<Image style={styles.cardBg} source={bankImg} />
<Text style={styles.cardNo} numberOfLines={1}>
{cardNo}
{newCardNo}
</Text>
</View>
</TouchableOpacity>
... ... @@ -34,17 +35,55 @@ export default class BankCardListCell extends React.Component {
}
//正则替换卡号,保留后4位
processBankCardNo(cardNo){
let newCardNo = cardNo.replace(/(\d+)(\d{4})$/, (a, b, c)=> {
return b.replace(/\d/g, '*') + c;
});
return newCardNo;
}
getBankImage(bank){
let bankImg;
switch(bank){
case "ABC":
bankImg = require('../../image/bank/bank-ABC.png');
break;
case "BOC":
bankImg = require('../../image/bank/bank-BOC.png');
break;
case "CCB":
bankImg = require('../../image/bank/bank-CCB.png');
break;
case "CEB":
bankImg = require('../../image/bank/bank-CEB.png');
break;
case "CGB":
bankImg = require('../../image/bank/bank-CGB.png');
break;
case "CIB":
bankImg = require('../../image/bank/bank-CIB.png');
break;
case "CITIC":
bankImg = require('../../image/bank/bank-CITIC.png');
break;
case "CMBC":
bankImg = require('../../image/bank/bank-CMBC.png');
break;
case "ICBC":
bankImg = require('../../image/bank/bank-ICBC.png');
break;
case "PAYH":
bankImg = require('../../image/bank/bank-PAYH.png');
break;
case "PSBC":
bankImg = require('../../image/bank/bank-PSBC.png');
break;
default:
bankImg = require('../../image/bank/bank-ICBC.png');
bankImg = require('../../image/bank/bank-EMPTY.png');
break;
}
return bankImg;
... ...