Authored by chenl

增加银行卡详情逻辑。review by 张丽霞。

... ... @@ -147,7 +147,7 @@ export default function native(platform) {
</Provider>
)
} else if (type == 'installMyCardDetail') {
let cardIdNo = '9999';//this.props.cardIdNo;
let cardIdNo = this.props.cardIdNo;
store.dispatch(setCardIdNo(cardIdNo));
return (
<Provider store={store}>
... ...
... ... @@ -37,6 +37,9 @@ export default class BankCardDetail extends React.Component {
let cardTip = isMaster ? "如果您更换银行预留手机号,请先新增其他还款银行卡,并将新增银行卡切换为主卡。然后解除绑定此卡,重新绑定即可。"
: "如果您更换银行预留手机号,请先将银行卡解除绑定,再次重新绑定即可。";
let showToast = this.props.showToast ? true : false;
let showToastText = this.props.showToastText;
return (
<View style={styles.container}>
<View style={styles.cardDetailContainer}>
... ... @@ -74,9 +77,9 @@ export default class BankCardDetail extends React.Component {
</View>
}
</View>
<Toast text="解绑成功" isVisible={false} />
{
showToast ? <Toast text={showToastText} isVisible={true} /> : null
}
</View>
);
}
... ...
... ... @@ -77,4 +77,6 @@ export default keyMirror({
GET_CARD_DETAIL_REQUEST: null,
GET_CARD_DETAIL_FAILURE: null,
GET_CARD_DETAIL_SUCCESS: null,
UNBIND_CARD_SUCCESS: null,
TOGGLE_CARD_SUCCESS: null,
});
... ...
... ... @@ -59,15 +59,32 @@ class InstallmentMyCardDetailContainer extends Component {
onPressReleaseCard(){
Alert.alert(
'',
"alertMessage",
"你确定要解除绑定此卡吗?解除绑定后该银行卡将不出现在还款银行卡列表中。",
[
{text: 'Cancel', onPress: () => console.log('Cancel Pressed!')},
{text: 'OK', onPress: () => console.log('OK Pressed!')},
{text: '取消', onPress: () => {}},
{text: '确定', onPress: () => {
let cardIdNo = this.props.myCardDetail.cardIdNo;
this.props.actions.unbindBankCard && this.props.actions.unbindBankCard(cardIdNo);
}
},
]
);
);
}
onPressChangeCard(){
Alert.alert(
'',
"你确定要设置该银行卡为主卡吗?确定设置后原主卡将自动修改为副卡。",
[
{text: '取消', onPress: () => {}},
{text: '确定', onPress: () => {
let cardIdNo = this.props.myCardDetail.cardIdNo;
this.props.actions.toggleBankCard && this.props.actions.toggleBankCard(cardIdNo);
}
},
]
);
}
... ... @@ -82,6 +99,8 @@ class InstallmentMyCardDetailContainer extends Component {
cardInfo={cardInfo}
onPressChangeCard={this.onPressChangeCard}
onPressReleaseCard={this.onPressReleaseCard}
showToast={this.props.myCardDetail.showToast}
showToastText={this.props.myCardDetail.showToastText}
/>
);
}
... ...
... ... @@ -13,6 +13,9 @@ GET_CARD_DETAIL_REQUEST,
GET_CARD_DETAIL_FAILURE,
GET_CARD_DETAIL_SUCCESS,
UNBIND_CARD_SUCCESS,
TOGGLE_CARD_SUCCESS,
} = require('../../constants/actionTypes').default;
... ... @@ -83,3 +86,96 @@ export function setTipMessage(message){
payload: message,
}
}
export function unbindBankCard(cardIdNo) {
return (dispatch, getState) => {
let {app} = getState();
let unbindCard = (uid) => {
return new InstallmentService(app.host).unbindCard(uid, cardIdNo)
.then(json => {
dispatch(unbindCardSuccess());
dispatch(backToMyCardList());
})
.catch(error => {
dispatch(unbindCardSuccess());
dispatch(backToMyCardList());
dispatch(setTipMessage(error.message || '暂未获取到数据'));
});
};
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
unbindCard(uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
unbindCard(uid);
})
.catch(error => {
});
});
};
}
export function unbindCardSuccess(){
return {
type: UNBIND_CARD_SUCCESS,
payload: true,
}
}
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 toggleBankCard(cardIdNo) {
return (dispatch, getState) => {
let {app} = getState();
let toggleCard = (uid) => {
return new InstallmentService(app.host).toggleCard(uid, cardIdNo)
.then(json => {
dispatch(toggleCardSuccess());
})
.catch(error => {
dispatch(toggleCardSuccess());
dispatch(setTipMessage(error.message || '暂未获取到数据'));
});
};
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
toggleCard(uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
toggleCard(uid);
})
.catch(error => {
});
});
};
}
export function toggleCardSuccess(){
return {
type: TOGGLE_CARD_SUCCESS,
payload: true,
}
}
... ...
... ... @@ -7,6 +7,9 @@ let InitialState = Record({
cardIdNo: '',
cardInfo: Map(),
showToast: false,
showToastText: '',
error: null,
tipMessage: '',
});
... ...
... ... @@ -12,6 +12,9 @@ const {
GET_CARD_DETAIL_FAILURE,
GET_CARD_DETAIL_SUCCESS,
UNBIND_CARD_SUCCESS,
TOGGLE_CARD_SUCCESS,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -33,6 +36,13 @@ export default function appReducer(state = initialState, action) {
case GET_CARD_DETAIL_SUCCESS:
return state.set('isFetching', false)
.set('cardInfo', Immutable.fromJS(action.payload));
case UNBIND_CARD_SUCCESS:
return state.set('showToast', true)
.set('showToastText', "解除成功!");
case TOGGLE_CARD_SUCCESS:
return state.set('showToast', true)
.setIn(['cardInfo', "masterType"], "1")
.set('showToastText', "切换成功!");
}
... ...
... ... @@ -254,7 +254,30 @@ export default class InstallmentService {
}
})
.then((json) => {
return json;
let json2 = [
{
id: "1",
userName: "*三",
cardNo: "6228480443682025418",
bankCode: "ABC",
bankName: "农业银行",
mobile: "18021200000",
cardIdNo: "BK201610204789114",
masterType: "1"
},
{
id: "2",
userName: "*三",
cardNo: "6222024301058186063",
bankCode: "ICBC",
bankName: "工商银行",
mobile:"18021200001",
cardIdNo: "BK20160909455542",
masterType: "0"
}
];
return json2;
})
.catch((error) => {
throw(error);
... ... @@ -272,13 +295,68 @@ export default class InstallmentService {
}
})
.then((json) => {
let json2 = {
id: "1",
userName: "*三",
cardNo: "*****************5433",
bankCode: "ABC",
bankName: "农业银行",
mobile: "180****0000",
cardIdNo: "BK201610204789114",
masterType: "0"
};
return json2;
})
.catch((error) => {
console.log("chenlin_Err", error);
throw(error);
});
}
//解绑银行卡
async unbindCard(uid, cardIdNo) {
return await this.api.get({
url: '',
body: {
method: 'user.instalment.unbindCard',
uid,
cardIdNo,
}
})
.then((json) => {
console.log("chenlin_success", json);
return json;
})
.catch((error) => {
console.log("chenlin_Err", error);
throw(error);
});
}
//切换银行卡
async toggleCard(uid, cardIdNo) {
return await this.api.get({
url: '',
body: {
method: 'user.instalment.toggleCard',
uid,
cardIdNo,
}
})
.then((json) => {
console.log("chenlin_success", json);
return json;
})
.catch((error) => {
console.log("chenlin_Err", error);
throw(error);
});
}
//预付款
async getPrerePay(params) {
return await this.api.get({
... ...