...
|
...
|
@@ -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,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|