Authored by chenl

调整了新增银行卡的跳转。review by 张丽霞。

@@ -8,7 +8,7 @@ import { @@ -8,7 +8,7 @@ import {
8 View, 8 View,
9 NativeModules, 9 NativeModules,
10 InteractionManager, 10 InteractionManager,
11 - NativeAppEventEmitter, 11 + DeviceEventEmitter,
12 Text, 12 Text,
13 ListView, 13 ListView,
14 TouchableOpacity, 14 TouchableOpacity,
@@ -48,6 +48,13 @@ class InstallmentMyCardContainer extends Component { @@ -48,6 +48,13 @@ class InstallmentMyCardContainer extends Component {
48 super(props); 48 super(props);
49 this.onPressCard = this.onPressCard.bind(this); 49 this.onPressCard = this.onPressCard.bind(this);
50 this._reloadPage = this._reloadPage.bind(this); 50 this._reloadPage = this._reloadPage.bind(this);
  51 +
  52 + this.subscription = DeviceEventEmitter.addListener(
  53 + 'BankCardChangeEvent',
  54 + () => {
  55 + this._reloadPage();
  56 + }
  57 + );
51 } 58 }
52 59
53 _reloadPage() { 60 _reloadPage() {
@@ -58,6 +65,10 @@ class InstallmentMyCardContainer extends Component { @@ -58,6 +65,10 @@ class InstallmentMyCardContainer extends Component {
58 this.props.actions.getBankCards(); 65 this.props.actions.getBankCards();
59 } 66 }
60 67
  68 + componentWillUnmount(){
  69 + this.subscription && this.subscription.remove();
  70 + }
  71 +
61 onPressCard(cardIdNo){ 72 onPressCard(cardIdNo){
62 this.props.actions.goMyCardDetail(cardIdNo); 73 this.props.actions.goMyCardDetail(cardIdNo);
63 } 74 }
@@ -9,6 +9,7 @@ import { @@ -9,6 +9,7 @@ import {
9 NativeModules, 9 NativeModules,
10 InteractionManager, 10 InteractionManager,
11 NativeAppEventEmitter, 11 NativeAppEventEmitter,
  12 + DeviceEventEmitter,
12 Text, 13 Text,
13 ListView, 14 ListView,
14 TouchableOpacity, 15 TouchableOpacity,
@@ -60,6 +61,13 @@ class InstallmentMyOrderDetailContainer extends Component { @@ -60,6 +61,13 @@ class InstallmentMyOrderDetailContainer extends Component {
60 this._reSendConfirmPaySnsCode = this._reSendConfirmPaySnsCode.bind(this); 61 this._reSendConfirmPaySnsCode = this._reSendConfirmPaySnsCode.bind(this);
61 this._confirmPayAction = this._confirmPayAction.bind(this); 62 this._confirmPayAction = this._confirmPayAction.bind(this);
62 this._clearTipMessage = this._clearTipMessage.bind(this); 63 this._clearTipMessage = this._clearTipMessage.bind(this);
  64 +
  65 + this.subscription = DeviceEventEmitter.addListener(
  66 + 'BankCardChangeEvent',
  67 + () => {
  68 + this.props.actions.getBankCards && this.props.actions.getBankCards();
  69 + }
  70 + );
63 } 71 }
64 72
65 _reloadPage() { 73 _reloadPage() {
@@ -125,6 +133,10 @@ class InstallmentMyOrderDetailContainer extends Component { @@ -125,6 +133,10 @@ class InstallmentMyOrderDetailContainer extends Component {
125 this.props.actions.getOrderDetail(); 133 this.props.actions.getOrderDetail();
126 } 134 }
127 135
  136 + componentWillUnmount(){
  137 + this.subscription && this.subscription.remove();
  138 + }
  139 +
128 render() { 140 render() {
129 141
130 let {error} = this.props.myOrderDetail; 142 let {error} = this.props.myOrderDetail;
@@ -9,6 +9,7 @@ import { @@ -9,6 +9,7 @@ import {
9 NativeModules, 9 NativeModules,
10 InteractionManager, 10 InteractionManager,
11 NativeAppEventEmitter, 11 NativeAppEventEmitter,
  12 + DeviceEventEmitter,
12 Text, 13 Text,
13 } from 'react-native' 14 } from 'react-native'
14 15
@@ -58,6 +59,13 @@ class RepayListContainer extends Component { @@ -58,6 +59,13 @@ class RepayListContainer extends Component {
58 this._reSendConfirmPaySnsCode = this._reSendConfirmPaySnsCode.bind(this); 59 this._reSendConfirmPaySnsCode = this._reSendConfirmPaySnsCode.bind(this);
59 this._confirmPayAction = this._confirmPayAction.bind(this); 60 this._confirmPayAction = this._confirmPayAction.bind(this);
60 this._reloadPage = this._reloadPage.bind(this); 61 this._reloadPage = this._reloadPage.bind(this);
  62 +
  63 + this.subscription = DeviceEventEmitter.addListener(
  64 + 'BankCardChangeEvent',
  65 + () => {
  66 + this.props.actions.getBankCards && this.props.actions.getBankCards();
  67 + }
  68 + );
61 } 69 }
62 componentDidMount() { 70 componentDidMount() {
63 let {repayList} = this.props; 71 let {repayList} = this.props;
@@ -65,6 +73,10 @@ class RepayListContainer extends Component { @@ -65,6 +73,10 @@ class RepayListContainer extends Component {
65 this.props.actions.getQueryAmtList(queryDays); 73 this.props.actions.getQueryAmtList(queryDays);
66 } 74 }
67 75
  76 + componentWillUnmount(){
  77 + this.subscription && this.subscription.remove();
  78 + }
  79 +
68 _reloadPage() { 80 _reloadPage() {
69 let {repayList} = this.props; 81 let {repayList} = this.props;
70 let {queryDays} = repayList; 82 let {queryDays} = repayList;
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 import ReactNative from 'react-native'; 3 import ReactNative from 'react-native';
4 import InstallmentService from '../../services/InstallmentService'; 4 import InstallmentService from '../../services/InstallmentService';
  5 +import {DeviceEventEmitter} from 'react-native';
5 6
6 const { 7 const {
7 8
@@ -181,8 +182,8 @@ export function showResultInfo(result) { @@ -181,8 +182,8 @@ export function showResultInfo(result) {
181 182
182 export function backToMyCardList() { 183 export function backToMyCardList() {
183 return (dispatch, getState) => { 184 return (dispatch, getState) => {
184 - let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.instalmentMyCard","params":{}}`;  
185 - ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); 185 + ReactNative.NativeModules.YH_CommonHelper.goBack();
  186 + DeviceEventEmitter.emit('BankCardChangeEvent');
186 } 187 }
187 } 188 }
188 189
1 'use strict'; 1 'use strict';
2 2
3 import ReactNative from 'react-native'; 3 import ReactNative from 'react-native';
  4 +import {DeviceEventEmitter} from 'react-native';
4 import InstallmentService from '../../services/InstallmentService'; 5 import InstallmentService from '../../services/InstallmentService';
5 6
6 const { 7 const {
@@ -141,8 +142,8 @@ export function unbindCardSuccess(){ @@ -141,8 +142,8 @@ export function unbindCardSuccess(){
141 142
142 export function backToMyCardList() { 143 export function backToMyCardList() {
143 return (dispatch, getState) => { 144 return (dispatch, getState) => {
144 - let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.instalmentMyCard","params":{}}`;  
145 - ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); 145 + ReactNative.NativeModules.YH_CommonHelper.goBack();
  146 + DeviceEventEmitter.emit('BankCardChangeEvent');
146 } 147 }
147 } 148 }
148 149
@@ -154,11 +155,10 @@ export function toggleBankCard(cardIdNo) { @@ -154,11 +155,10 @@ export function toggleBankCard(cardIdNo) {
154 let toggleCard = (uid) => { 155 let toggleCard = (uid) => {
155 return new InstallmentService(app.host).toggleCard(uid, cardIdNo) 156 return new InstallmentService(app.host).toggleCard(uid, cardIdNo)
156 .then(json => { 157 .then(json => {
  158 + DeviceEventEmitter.emit('BankCardChangeEvent');
157 dispatch(toggleCardSuccess()); 159 dispatch(toggleCardSuccess());
158 }) 160 })
159 .catch(error => { 161 .catch(error => {
160 - dispatch(toggleCardSuccess());  
161 -  
162 dispatch(setTipMessage(error.message || '暂未获取到数据')); 162 dispatch(setTipMessage(error.message || '暂未获取到数据'));
163 }); 163 });
164 }; 164 };