Authored by chenl

增加了新增银行卡逻辑。review by 张丽霞。

... ... @@ -83,26 +83,31 @@ export default class BankCardAdd extends React.Component {
}
}
onPressButton(){
}
render() {
if(true){
let {showResult, result, message, description, buttonText} = this.props.cardAddState;
if(showResult){
return (
<ResultView
result={"success"}
result={result}
fromPage={"BankCardAdd"}
message={"恭喜您,新增还款银行卡成功!"}
buttonText={"确认"}
onPressButton={this.onPressButton}
message={message}
description={description}
buttonText={buttonText}
onPressButton={() => {
if(result == 'success'){
this.props.onPressSuccessButton && this.props.onPressSuccessButton();
}
else{
this.props.onPressFailButton && this.props.onPressFailButton();
}
}}
/>
);
}
let cardAddState = this.props.cardAddState;
let bankName = cardAddState.get("bankName");
... ... @@ -111,8 +116,7 @@ export default class BankCardAdd extends React.Component {
let bankSupport = cardAddState.get("bankSupport");
let showBankInfo = cardAddState.get("showBankInfo");
let userName = "**聪";
let userName = '';
let nextBtnBgColor = this.state.nextBtnEnable ? {backgroundColor:'#444444'} : {backgroundColor:'#b0b0b0'};
... ...
... ... @@ -32,7 +32,7 @@ export default class ResultView extends React.Component {
render() {
let {result, fromPage, message, buttonText} = this.props;
let {result, fromPage, message, description, buttonText} = this.props;
let resultImg = this.getResultImg(result, fromPage);
... ... @@ -48,6 +48,10 @@ export default class ResultView extends React.Component {
{message}
</Text>
<Text style={styles.description}>
{description}
</Text>
<TouchableOpacity onPress={() => {this.props.onPressButton && this.props.onPressButton()}} >
<View style={styles.buttonContainer}>
<Text style={styles.button}>
... ... @@ -91,8 +95,15 @@ let styles = StyleSheet.create({
textAlign: 'center',
lineHeight: Math.ceil(16 * DEVICE_WIDTH_RATIO),
color: '#444444',
},
description: {
fontSize: 12 * DEVICE_WIDTH_RATIO,
width: 200 * DEVICE_WIDTH_RATIO,
textAlign: 'center',
lineHeight: Math.ceil(16 * DEVICE_WIDTH_RATIO),
color: '#b0b0b0',
},
reason: {
width: 260 * DEVICE_WIDTH_RATIO,
fontSize: 12 * DEVICE_WIDTH_RATIO,
... ...
... ... @@ -71,4 +71,6 @@ export default keyMirror({
GET_CARD_LIST_SUCCESS: null,
SHOW_BANK_INFO: null,
SHOW_RESULT_INFO: null,
RESET_CARD_ADD_INFO: null,
});
... ...
... ... @@ -48,10 +48,12 @@ class InstallmentMyCardAddContainer extends Component {
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.getBankCards();
}
... ... @@ -69,6 +71,22 @@ class InstallmentMyCardAddContainer extends Component {
this.props.actions.bindingCard(cardNo, mobile, bankName, bankCode);
}
/**
* 返回我的银行卡页面
**/
_onPressSuccessButton(){
this.props.actions.backToMyCardList();
}
/**
* 返回新增银行卡页面
**/
_onPressFailButton(){
this.props.actions.backToMyCardAdd();
}
render() {
let {myCardAdd} = this.props;
... ... @@ -79,6 +97,8 @@ class InstallmentMyCardAddContainer extends Component {
cardAddState={myCardAdd}
onCardNoComplete={this._onCardNoComplete}
onPressBindingCard={this._onPressBindingCard}
onPressSuccessButton={this._onPressSuccessButton}
onPressFailButton={this._onPressFailButton}
/>
);
}
... ...
... ... @@ -7,7 +7,8 @@ const {
SET_ERROR,
SHOW_BANK_INFO,
SHOW_RESULT_INFO,
RESET_CARD_ADD_INFO,
} = require('../../constants/actionTypes').default;
... ... @@ -17,7 +18,7 @@ export function getBankInfo(cardNo) {
return (dispatch, getState) => {
let bankInfo = (uid) => {
let {app, myCardAdd} = getState();
let {app} = getState();
let info = {
bankCode: '',
bankName: '',
... ... @@ -80,20 +81,30 @@ export function bindingCard(cardNo, mobile, bankName, bankCode) {
let bindCards = (uid) => {
let {app} = getState();
let result = {
showResult: false,
result: '',
message: '',
description: '',
buttonText: '',
};
return new InstallmentService(app.host).bindingCards(uid, cardNo, mobile, bankName, bankCode)
.then(json => {
console.log("chenlin9999", JSON.stringify(json));
// dispatch(showBankInfo(info));
result.showResult = true;
result.result = 'success';
result.message = '恭喜您,新增还款银行卡成功!';
result.description = '';
result.buttonText = '确认';
dispatch(showResultInfo(result));
})
.catch(error => {
console.log("chenlin6666", JSON.stringify(error));
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.instalmentMyCardAdd","params":{}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
result.showResult = true;
result.result = 'fail';
result.message = '对不起,绑定银行卡失败!';
result.description = '失败的原因可能是:银行卡户名、银行卡、预留的手机号不一致';
result.buttonText = '重新绑定银行卡';
dispatch(showResultInfo(result));
});
}
... ... @@ -114,7 +125,47 @@ export function bindingCard(cardNo, mobile, bankName, bankCode) {
}
export function showResultInfo(result) {
return {
type: SHOW_RESULT_INFO,
payload: result,
}
}
export function backToMyCardList() {
return (dispatch, getState) => {
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.instalmentMyCard","params":{}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
}
export function backToMyCardAdd() {
return (dispatch, getState) => {
let reset = {
bankCode: '',
bankName: '',
cardNO: '',
bankSupport: false,
showBankInfo: false,
showResult: false,
result: '',
message: '',
description: '',
buttonText: '',
};
dispatch(resetStateInfo(reset));
}
}
export function resetStateInfo(state) {
return {
type: RESET_CARD_ADD_INFO,
payload: state,
}
}
... ...
... ... @@ -14,6 +14,12 @@ let InitialState = Record({
showBankInfo: false,
banks: bankList.join('、'),
showResult: false,
result: '',
message: '',
description: '',
buttonText: '',
});
... ...
... ... @@ -5,6 +5,8 @@ import Immutable, {Map} from 'immutable';
const {
SHOW_BANK_INFO,
SHOW_RESULT_INFO,
RESET_CARD_ADD_INFO,
} = require('../../constants/actionTypes').default;
... ... @@ -20,6 +22,23 @@ export default function cardAddReducer(state = initialState, action) {
.set('cardNO', action.payload.cardNO)
.set('bankSupport', action.payload.bankSupport)
.set('showBankInfo', action.payload.showBankInfo);
case SHOW_RESULT_INFO:
return state.set('showResult', action.payload.showResult)
.set('result', action.payload.result)
.set('message', action.payload.message)
.set('description', action.payload.description)
.set('buttonText', action.payload.buttonText);
case RESET_CARD_ADD_INFO:
return state.set('bankCode', action.payload.bankCode)
.set('bankName', action.payload.bankName)
.set('cardNO', action.payload.cardNO)
.set('bankSupport', action.payload.bankSupport)
.set('showBankInfo', action.payload.showBankInfo)
.set('showResult', action.payload.showResult)
.set('result', action.payload.result)
.set('message', action.payload.message)
.set('description', action.payload.description)
.set('buttonText', action.payload.buttonText);
}
return state;
... ...