增加银行卡详情逻辑。review by 张丽霞。
Showing
8 changed files
with
220 additions
and
9 deletions
@@ -147,7 +147,7 @@ export default function native(platform) { | @@ -147,7 +147,7 @@ export default function native(platform) { | ||
147 | </Provider> | 147 | </Provider> |
148 | ) | 148 | ) |
149 | } else if (type == 'installMyCardDetail') { | 149 | } else if (type == 'installMyCardDetail') { |
150 | - let cardIdNo = '9999';//this.props.cardIdNo; | 150 | + let cardIdNo = this.props.cardIdNo; |
151 | store.dispatch(setCardIdNo(cardIdNo)); | 151 | store.dispatch(setCardIdNo(cardIdNo)); |
152 | return ( | 152 | return ( |
153 | <Provider store={store}> | 153 | <Provider store={store}> |
@@ -37,6 +37,9 @@ export default class BankCardDetail extends React.Component { | @@ -37,6 +37,9 @@ export default class BankCardDetail extends React.Component { | ||
37 | let cardTip = isMaster ? "如果您更换银行预留手机号,请先新增其他还款银行卡,并将新增银行卡切换为主卡。然后解除绑定此卡,重新绑定即可。" | 37 | let cardTip = isMaster ? "如果您更换银行预留手机号,请先新增其他还款银行卡,并将新增银行卡切换为主卡。然后解除绑定此卡,重新绑定即可。" |
38 | : "如果您更换银行预留手机号,请先将银行卡解除绑定,再次重新绑定即可。"; | 38 | : "如果您更换银行预留手机号,请先将银行卡解除绑定,再次重新绑定即可。"; |
39 | 39 | ||
40 | + let showToast = this.props.showToast ? true : false; | ||
41 | + let showToastText = this.props.showToastText; | ||
42 | + | ||
40 | return ( | 43 | return ( |
41 | <View style={styles.container}> | 44 | <View style={styles.container}> |
42 | <View style={styles.cardDetailContainer}> | 45 | <View style={styles.cardDetailContainer}> |
@@ -74,9 +77,9 @@ export default class BankCardDetail extends React.Component { | @@ -74,9 +77,9 @@ export default class BankCardDetail extends React.Component { | ||
74 | </View> | 77 | </View> |
75 | } | 78 | } |
76 | </View> | 79 | </View> |
77 | - | ||
78 | - <Toast text="解绑成功" isVisible={false} /> | ||
79 | - | 80 | + { |
81 | + showToast ? <Toast text={showToastText} isVisible={true} /> : null | ||
82 | + } | ||
80 | </View> | 83 | </View> |
81 | ); | 84 | ); |
82 | } | 85 | } |
@@ -77,4 +77,6 @@ export default keyMirror({ | @@ -77,4 +77,6 @@ export default keyMirror({ | ||
77 | GET_CARD_DETAIL_REQUEST: null, | 77 | GET_CARD_DETAIL_REQUEST: null, |
78 | GET_CARD_DETAIL_FAILURE: null, | 78 | GET_CARD_DETAIL_FAILURE: null, |
79 | GET_CARD_DETAIL_SUCCESS: null, | 79 | GET_CARD_DETAIL_SUCCESS: null, |
80 | + UNBIND_CARD_SUCCESS: null, | ||
81 | + TOGGLE_CARD_SUCCESS: null, | ||
80 | }); | 82 | }); |
@@ -59,15 +59,32 @@ class InstallmentMyCardDetailContainer extends Component { | @@ -59,15 +59,32 @@ class InstallmentMyCardDetailContainer extends Component { | ||
59 | onPressReleaseCard(){ | 59 | onPressReleaseCard(){ |
60 | Alert.alert( | 60 | Alert.alert( |
61 | '', | 61 | '', |
62 | - "alertMessage", | 62 | + "你确定要解除绑定此卡吗?解除绑定后该银行卡将不出现在还款银行卡列表中。", |
63 | [ | 63 | [ |
64 | - {text: 'Cancel', onPress: () => console.log('Cancel Pressed!')}, | ||
65 | - {text: 'OK', onPress: () => console.log('OK Pressed!')}, | 64 | + {text: '取消', onPress: () => {}}, |
65 | + {text: '确定', onPress: () => { | ||
66 | + let cardIdNo = this.props.myCardDetail.cardIdNo; | ||
67 | + this.props.actions.unbindBankCard && this.props.actions.unbindBankCard(cardIdNo); | ||
68 | + } | ||
69 | + }, | ||
66 | ] | 70 | ] |
67 | - ); | 71 | + ); |
68 | } | 72 | } |
69 | 73 | ||
70 | onPressChangeCard(){ | 74 | onPressChangeCard(){ |
75 | + Alert.alert( | ||
76 | + '', | ||
77 | + "你确定要设置该银行卡为主卡吗?确定设置后原主卡将自动修改为副卡。", | ||
78 | + [ | ||
79 | + {text: '取消', onPress: () => {}}, | ||
80 | + {text: '确定', onPress: () => { | ||
81 | + let cardIdNo = this.props.myCardDetail.cardIdNo; | ||
82 | + this.props.actions.toggleBankCard && this.props.actions.toggleBankCard(cardIdNo); | ||
83 | + } | ||
84 | + }, | ||
85 | + ] | ||
86 | + ); | ||
87 | + | ||
71 | 88 | ||
72 | } | 89 | } |
73 | 90 | ||
@@ -82,6 +99,8 @@ class InstallmentMyCardDetailContainer extends Component { | @@ -82,6 +99,8 @@ class InstallmentMyCardDetailContainer extends Component { | ||
82 | cardInfo={cardInfo} | 99 | cardInfo={cardInfo} |
83 | onPressChangeCard={this.onPressChangeCard} | 100 | onPressChangeCard={this.onPressChangeCard} |
84 | onPressReleaseCard={this.onPressReleaseCard} | 101 | onPressReleaseCard={this.onPressReleaseCard} |
102 | + showToast={this.props.myCardDetail.showToast} | ||
103 | + showToastText={this.props.myCardDetail.showToastText} | ||
85 | /> | 104 | /> |
86 | ); | 105 | ); |
87 | } | 106 | } |
@@ -13,6 +13,9 @@ GET_CARD_DETAIL_REQUEST, | @@ -13,6 +13,9 @@ GET_CARD_DETAIL_REQUEST, | ||
13 | GET_CARD_DETAIL_FAILURE, | 13 | GET_CARD_DETAIL_FAILURE, |
14 | GET_CARD_DETAIL_SUCCESS, | 14 | GET_CARD_DETAIL_SUCCESS, |
15 | 15 | ||
16 | +UNBIND_CARD_SUCCESS, | ||
17 | +TOGGLE_CARD_SUCCESS, | ||
18 | + | ||
16 | 19 | ||
17 | } = require('../../constants/actionTypes').default; | 20 | } = require('../../constants/actionTypes').default; |
18 | 21 | ||
@@ -83,3 +86,96 @@ export function setTipMessage(message){ | @@ -83,3 +86,96 @@ export function setTipMessage(message){ | ||
83 | payload: message, | 86 | payload: message, |
84 | } | 87 | } |
85 | } | 88 | } |
89 | + | ||
90 | + | ||
91 | +export function unbindBankCard(cardIdNo) { | ||
92 | + return (dispatch, getState) => { | ||
93 | + let {app} = getState(); | ||
94 | + | ||
95 | + let unbindCard = (uid) => { | ||
96 | + return new InstallmentService(app.host).unbindCard(uid, cardIdNo) | ||
97 | + .then(json => { | ||
98 | + dispatch(unbindCardSuccess()); | ||
99 | + dispatch(backToMyCardList()); | ||
100 | + | ||
101 | + | ||
102 | + }) | ||
103 | + .catch(error => { | ||
104 | + dispatch(unbindCardSuccess()); | ||
105 | + dispatch(backToMyCardList()); | ||
106 | + | ||
107 | + dispatch(setTipMessage(error.message || '暂未获取到数据')); | ||
108 | + }); | ||
109 | + }; | ||
110 | + | ||
111 | + ReactNative.NativeModules.YH_CommonHelper.uid() | ||
112 | + .then(uid => { | ||
113 | + unbindCard(uid); | ||
114 | + }) | ||
115 | + .catch(error => { | ||
116 | + ReactNative.NativeModules.YH_CommonHelper.login() | ||
117 | + .then(uid => { | ||
118 | + unbindCard(uid); | ||
119 | + }) | ||
120 | + .catch(error => { | ||
121 | + | ||
122 | + }); | ||
123 | + }); | ||
124 | + }; | ||
125 | +} | ||
126 | + | ||
127 | +export function unbindCardSuccess(){ | ||
128 | + return { | ||
129 | + type: UNBIND_CARD_SUCCESS, | ||
130 | + payload: true, | ||
131 | + } | ||
132 | +} | ||
133 | + | ||
134 | +export function backToMyCardList() { | ||
135 | + return (dispatch, getState) => { | ||
136 | + let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.instalmentMyCard","params":{}}`; | ||
137 | + ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); | ||
138 | + } | ||
139 | +} | ||
140 | + | ||
141 | + | ||
142 | +export function toggleBankCard(cardIdNo) { | ||
143 | + return (dispatch, getState) => { | ||
144 | + let {app} = getState(); | ||
145 | + | ||
146 | + let toggleCard = (uid) => { | ||
147 | + return new InstallmentService(app.host).toggleCard(uid, cardIdNo) | ||
148 | + .then(json => { | ||
149 | + dispatch(toggleCardSuccess()); | ||
150 | + }) | ||
151 | + .catch(error => { | ||
152 | + dispatch(toggleCardSuccess()); | ||
153 | + | ||
154 | + dispatch(setTipMessage(error.message || '暂未获取到数据')); | ||
155 | + }); | ||
156 | + }; | ||
157 | + | ||
158 | + ReactNative.NativeModules.YH_CommonHelper.uid() | ||
159 | + .then(uid => { | ||
160 | + toggleCard(uid); | ||
161 | + }) | ||
162 | + .catch(error => { | ||
163 | + ReactNative.NativeModules.YH_CommonHelper.login() | ||
164 | + .then(uid => { | ||
165 | + toggleCard(uid); | ||
166 | + }) | ||
167 | + .catch(error => { | ||
168 | + | ||
169 | + }); | ||
170 | + }); | ||
171 | + }; | ||
172 | +} | ||
173 | + | ||
174 | +export function toggleCardSuccess(){ | ||
175 | + return { | ||
176 | + type: TOGGLE_CARD_SUCCESS, | ||
177 | + payload: true, | ||
178 | + } | ||
179 | +} | ||
180 | + | ||
181 | + |
@@ -12,6 +12,9 @@ const { | @@ -12,6 +12,9 @@ const { | ||
12 | GET_CARD_DETAIL_FAILURE, | 12 | GET_CARD_DETAIL_FAILURE, |
13 | GET_CARD_DETAIL_SUCCESS, | 13 | GET_CARD_DETAIL_SUCCESS, |
14 | 14 | ||
15 | + UNBIND_CARD_SUCCESS, | ||
16 | + TOGGLE_CARD_SUCCESS, | ||
17 | + | ||
15 | } = require('../../constants/actionTypes').default; | 18 | } = require('../../constants/actionTypes').default; |
16 | 19 | ||
17 | const initialState = new InitialState; | 20 | const initialState = new InitialState; |
@@ -33,6 +36,13 @@ export default function appReducer(state = initialState, action) { | @@ -33,6 +36,13 @@ export default function appReducer(state = initialState, action) { | ||
33 | case GET_CARD_DETAIL_SUCCESS: | 36 | case GET_CARD_DETAIL_SUCCESS: |
34 | return state.set('isFetching', false) | 37 | return state.set('isFetching', false) |
35 | .set('cardInfo', Immutable.fromJS(action.payload)); | 38 | .set('cardInfo', Immutable.fromJS(action.payload)); |
39 | + case UNBIND_CARD_SUCCESS: | ||
40 | + return state.set('showToast', true) | ||
41 | + .set('showToastText', "解除成功!"); | ||
42 | + case TOGGLE_CARD_SUCCESS: | ||
43 | + return state.set('showToast', true) | ||
44 | + .setIn(['cardInfo', "masterType"], "1") | ||
45 | + .set('showToastText', "切换成功!"); | ||
36 | 46 | ||
37 | } | 47 | } |
38 | 48 |
@@ -254,7 +254,30 @@ export default class InstallmentService { | @@ -254,7 +254,30 @@ export default class InstallmentService { | ||
254 | } | 254 | } |
255 | }) | 255 | }) |
256 | .then((json) => { | 256 | .then((json) => { |
257 | - return json; | 257 | + let json2 = [ |
258 | + { | ||
259 | + id: "1", | ||
260 | + userName: "*三", | ||
261 | + cardNo: "6228480443682025418", | ||
262 | + bankCode: "ABC", | ||
263 | + bankName: "农业银行", | ||
264 | + mobile: "18021200000", | ||
265 | + cardIdNo: "BK201610204789114", | ||
266 | + masterType: "1" | ||
267 | + }, | ||
268 | + { | ||
269 | + id: "2", | ||
270 | + userName: "*三", | ||
271 | + cardNo: "6222024301058186063", | ||
272 | + bankCode: "ICBC", | ||
273 | + bankName: "工商银行", | ||
274 | + mobile:"18021200001", | ||
275 | + cardIdNo: "BK20160909455542", | ||
276 | + masterType: "0" | ||
277 | + } | ||
278 | + ]; | ||
279 | + | ||
280 | + return json2; | ||
258 | }) | 281 | }) |
259 | .catch((error) => { | 282 | .catch((error) => { |
260 | throw(error); | 283 | throw(error); |
@@ -272,13 +295,68 @@ export default class InstallmentService { | @@ -272,13 +295,68 @@ export default class InstallmentService { | ||
272 | } | 295 | } |
273 | }) | 296 | }) |
274 | .then((json) => { | 297 | .then((json) => { |
298 | + let json2 = { | ||
299 | + id: "1", | ||
300 | + userName: "*三", | ||
301 | + cardNo: "*****************5433", | ||
302 | + bankCode: "ABC", | ||
303 | + bankName: "农业银行", | ||
304 | + mobile: "180****0000", | ||
305 | + cardIdNo: "BK201610204789114", | ||
306 | + masterType: "0" | ||
307 | + }; | ||
308 | + | ||
309 | + return json2; | ||
310 | + }) | ||
311 | + .catch((error) => { | ||
312 | + console.log("chenlin_Err", error); | ||
313 | + throw(error); | ||
314 | + }); | ||
315 | + } | ||
316 | + | ||
317 | + | ||
318 | + //解绑银行卡 | ||
319 | + async unbindCard(uid, cardIdNo) { | ||
320 | + return await this.api.get({ | ||
321 | + url: '', | ||
322 | + body: { | ||
323 | + method: 'user.instalment.unbindCard', | ||
324 | + uid, | ||
325 | + cardIdNo, | ||
326 | + } | ||
327 | + }) | ||
328 | + .then((json) => { | ||
329 | + console.log("chenlin_success", json); | ||
275 | return json; | 330 | return json; |
276 | }) | 331 | }) |
277 | .catch((error) => { | 332 | .catch((error) => { |
333 | + console.log("chenlin_Err", error); | ||
278 | throw(error); | 334 | throw(error); |
279 | }); | 335 | }); |
280 | } | 336 | } |
281 | 337 | ||
338 | + //切换银行卡 | ||
339 | + async toggleCard(uid, cardIdNo) { | ||
340 | + return await this.api.get({ | ||
341 | + url: '', | ||
342 | + body: { | ||
343 | + method: 'user.instalment.toggleCard', | ||
344 | + uid, | ||
345 | + cardIdNo, | ||
346 | + } | ||
347 | + }) | ||
348 | + .then((json) => { | ||
349 | + console.log("chenlin_success", json); | ||
350 | + return json; | ||
351 | + }) | ||
352 | + .catch((error) => { | ||
353 | + console.log("chenlin_Err", error); | ||
354 | + throw(error); | ||
355 | + }); | ||
356 | + } | ||
357 | + | ||
358 | + | ||
359 | + | ||
282 | //预付款 | 360 | //预付款 |
283 | async getPrerePay(params) { | 361 | async getPrerePay(params) { |
284 | return await this.api.get({ | 362 | return await this.api.get({ |
-
Please register or login to post a comment