|
|
'use strict';
|
|
|
import React from 'react';
|
|
|
import ReactNative, {
|
|
|
View,
|
|
|
Text,
|
|
|
Image,
|
|
|
StyleSheet,
|
|
|
Dimensions,
|
|
|
PixelRatio,
|
|
|
TouchableOpacity,
|
|
|
ListView,
|
|
|
Alert,
|
|
|
} from 'react-native';
|
|
|
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
|
|
|
export default class ChangeBankCard extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
});
|
|
|
this.renderRow = this.renderRow.bind(this);
|
|
|
this.renderSeparator = this.renderSeparator.bind(this);
|
|
|
this.renderFooter = this.renderFooter.bind(this);
|
|
|
}
|
|
|
|
|
|
renderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
let title = rowData ? rowData.get("outBankNameNumb") : "";
|
|
|
|
|
|
//判断是否为当前支付银行卡
|
|
|
let payCard = this.props.payCard;
|
|
|
let isPayCard = Immutable.is(payCard, rowData);
|
|
|
// cardIdNo
|
|
|
|
|
|
return (
|
|
|
<TouchableOpacity key={"row_"+rowID} activeOpacity={0.5} onPress={() => {
|
|
|
this.props.changeBankCard && this.props.changeBankCard(); }}>
|
|
|
<View style={styles.choseCardContainer}>
|
|
|
<Text style={styles.choseCardTitle}>{title}</Text>
|
|
|
{
|
|
|
isPayCard ? <Image source={require("../../image/check_icon.png")}/> : null
|
|
|
}
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderSeparator(sectionID, rowID, adjacentRowHighlighted){
|
|
|
return (
|
|
|
<View key={"sep_"+rowID} style={styles.splitLine}/>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderFooter(){
|
|
|
return (
|
|
|
<View >
|
|
|
<View style={styles.choseCardContainer}>
|
|
|
<Text style={styles.choseCardTitle}>使用新卡还款</Text>
|
|
|
<Image style={{marginRight:4*DEVICE_WIDTH_RATIO}} source={require("../../image/arrow_gray.png")}/>
|
|
|
</View>
|
|
|
<View style={styles.splitLine}/>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let{bankCardsList}=this.props;
|
|
|
|
|
|
let bankCardArray = bankCardsList ? bankCardsList.toArray() : [];
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<View style={styles.changeCardContainer}>
|
|
|
<View style={styles.titleContainer}>
|
|
|
<Text style={{fontSize:16*DEVICE_WIDTH_RATIO,lineHeight:Math.ceil(30 * DEVICE_WIDTH_RATIO),color:'#444444'}}>选择支付方式</Text>
|
|
|
<TouchableOpacity style={styles.closeIcon} onPress={() => {this.props.closeBankSafePay && this.props.closeBankSafePay()}} >
|
|
|
<Image
|
|
|
source={require('../../image/close_ic.png')}
|
|
|
resizeMode={'contain'}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
<View style={styles.splitLine}/>
|
|
|
|
|
|
<ListView
|
|
|
style={styles.cardListContainer}
|
|
|
conta
|
|
|
dataSource={this.dataSource.cloneWithRows(bankCardArray)}
|
|
|
enableEmptySections={true}
|
|
|
renderRow={this.renderRow}
|
|
|
renderSeparator={this.renderSeparator}
|
|
|
renderFooter={this.renderFooter}/>
|
|
|
|
|
|
<View style={styles.splitLine}/>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
const DEVICE_WIDTH_RATIO = width / 320;
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
|
alignItems: 'center',
|
|
|
position: 'absolute',
|
|
|
width: width,
|
|
|
height: height,
|
|
|
top: 0,
|
|
|
},
|
|
|
changeCardContainer: {
|
|
|
position: 'absolute',
|
|
|
bottom: 0,
|
|
|
width: width,
|
|
|
height: 375 * DEVICE_WIDTH_RATIO,
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
titleContainer: {
|
|
|
width: width,
|
|
|
height: 44 * DEVICE_WIDTH_RATIO,
|
|
|
alignItems: 'center',
|
|
|
position: 'relative',
|
|
|
},
|
|
|
closeIcon: {
|
|
|
position: 'absolute',
|
|
|
right: 10 * DEVICE_WIDTH_RATIO,
|
|
|
top: 0 * DEVICE_WIDTH_RATIO,
|
|
|
paddingLeft: 10 * DEVICE_WIDTH_RATIO,
|
|
|
paddingRight: 10 * DEVICE_WIDTH_RATIO,
|
|
|
paddingTop: 14 * DEVICE_WIDTH_RATIO,
|
|
|
},
|
|
|
splitLine: {
|
|
|
width: width,
|
|
|
height: 1,
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
},
|
|
|
cardListContainer: {
|
|
|
width: width,
|
|
|
height: 200 * DEVICE_WIDTH_RATIO,
|
|
|
},
|
|
|
choseCardContainer: {
|
|
|
height: 44 * DEVICE_WIDTH_RATIO,
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'space-between',
|
|
|
marginRight: 15 * DEVICE_WIDTH_RATIO,
|
|
|
},
|
|
|
choseCardTitle: {
|
|
|
marginLeft: 15 * DEVICE_WIDTH_RATIO,
|
|
|
color: '#444444',
|
|
|
fontSize: 14,
|
|
|
},
|
|
|
|
|
|
|
|
|
}); |
...
|
...
|
|