InstallmentMyCardAddContainer.js 2.64 KB
'use strict'

import React, {Component} from 'react';
import {
    StyleSheet,
    Dimensions,
    Platform,
    View,
    NativeModules,
    InteractionManager,
    NativeAppEventEmitter,
    Text,
    
    TouchableOpacity,
} from 'react-native'
import ListView from 'deprecated-react-native-listview'

import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as cardAddActions from '../reducers/bankCardAdd/cardAddActions';
import ServerError from '../components/installment/ServerError';
import BankCardAdd from '../components/installment/BankCardAdd';


const actions = [
    cardAddActions,
];
function mapStateToProps(state) {
    return {
        ...state
    };
}
function mapDispatchToProps(dispatch) {

    const creators = Map()
        .merge(...actions)
        .filter(value => typeof value === 'function')
        .toObject();

    return {
        actions: bindActionCreators(creators, dispatch),
        dispatch
    };
}
class InstallmentMyCardAddContainer extends Component {

    constructor(props) {
        super(props);
        this._onCardNoComplete = this._onCardNoComplete.bind(this);
        this._onPressBindingCard = this._onPressBindingCard.bind(this);
        this._onPressSuccessButton = this._onPressSuccessButton.bind(this);
        this._onPressFailButton = this._onPressFailButton.bind(this);
    }

    componentDidMount() {
        this.props.actions.getUserName();
    }


    /**
     *  卡号输入完成后
     **/
    _onCardNoComplete(cardNo) {
        this.props.actions.getBankInfo(cardNo);
    }

    /**
     *  点击绑定银行卡
     **/
    _onPressBindingCard(cardNo, mobile, bankName, bankCode) {
        this.props.actions.bindingCard(cardNo, mobile, bankName, bankCode);
    }

    /**
     *  返回我的银行卡页面
     **/
    _onPressSuccessButton(){
        this.props.actions.backToMyCardList();
    }

    /**
     *  返回新增银行卡页面
     **/
    _onPressFailButton(){
        this.props.actions.backToMyCardAdd();
    }

    

    render() {

        let {myCardAdd} = this.props;

        return (
            <BankCardAdd
                style={styles.container}
                cardAddState={myCardAdd}
                onCardNoComplete={this._onCardNoComplete}
                onPressBindingCard={this._onPressBindingCard}
                onPressSuccessButton={this._onPressSuccessButton}
                onPressFailButton={this._onPressFailButton}
            />
        );
    }
}
let styles = StyleSheet.create({
    container: {
        flex: 1,
    },


});

export default connect(mapStateToProps, mapDispatchToProps)(InstallmentMyCardAddContainer);