|
|
From b10c11f1958e272ede5b63d47333e9aebc460f01 Mon Sep 17 00:00:00 2001
|
|
|
From: "lixia.zhang" <yoho@lixiazhangdeiMac.local>
|
|
|
Date: Mon, 23 Apr 2018 11:55:10 +0800
|
|
|
Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E9=94=80=E7=8A=B6?=
|
|
|
=?UTF-8?q?=E6=80=81=E5=88=A4=E6=96=AD=EF=BC=8C=E9=A1=B5=E9=9D=A2=E5=B1=95?=
|
|
|
=?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=EF=BC=8Creview=20by=20=E7=8E=8B?=
|
|
|
=?UTF-8?q?=E6=B5=B7=E5=85=83?=
|
|
|
MIME-Version: 1.0
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
---
|
|
|
js/userLogout/constants/actionTypes.js | 5 +-
|
|
|
js/userLogout/containers/UserLogoutContainer.js | 66 +++++++++++++++-------
|
|
|
.../reducers/userLogout/userLogoutActions.js | 29 +++++++---
|
|
|
.../reducers/userLogout/userLogoutInitialState.js | 4 +-
|
|
|
.../reducers/userLogout/userLogoutReducer.js | 19 ++++++-
|
|
|
5 files changed, 89 insertions(+), 34 deletions(-)
|
|
|
|
|
|
diff --git a/js/userLogout/constants/actionTypes.js b/js/userLogout/constants/actionTypes.js
|
|
|
index 2f51f3a..d214322 100644
|
|
|
--- a/js/userLogout/constants/actionTypes.js
|
|
|
+++ b/js/userLogout/constants/actionTypes.js
|
|
|
@@ -12,8 +12,9 @@ export default keyMirror({
|
|
|
SET_HOST: null,
|
|
|
SET_SERVICE_HOST: null,
|
|
|
UPDATE_LOGOUT_MODAL_STATE: null,
|
|
|
- UPDATE_LOGOUT_STATUS: null,
|
|
|
-
|
|
|
+ FETCH_LOGOUT_STATUS_REQUEST: null,
|
|
|
+ FETCH_LOGOUT_STATUS_SUCCESS: null,
|
|
|
+ FETCH_LOGOUT_STATUS_FAILURE: null,
|
|
|
|
|
|
//注销原因
|
|
|
ENABLE_SUBMIT_BTN: null,
|
|
|
diff --git a/js/userLogout/containers/UserLogoutContainer.js b/js/userLogout/containers/UserLogoutContainer.js
|
|
|
index 329d982..28c71b1 100644
|
|
|
--- a/js/userLogout/containers/UserLogoutContainer.js
|
|
|
+++ b/js/userLogout/containers/UserLogoutContainer.js
|
|
|
@@ -9,7 +9,7 @@
|
|
|
import React, {Component} from 'react';
|
|
|
import {
|
|
|
StyleSheet,
|
|
|
- Dimensions
|
|
|
+ Dimensions,
|
|
|
} from 'react-native'
|
|
|
|
|
|
import {bindActionCreators} from 'redux';
|
|
|
@@ -19,6 +19,8 @@ import * as userLogoutActions from '../reducers/userLogout/userLogoutActions';
|
|
|
import UserLogout from '../components/userLogout/UserLogout';
|
|
|
import UserLogoutFaild from '../components/userLogout/UserLogoutFaild';
|
|
|
import UserLogoutStatus from '../components/userLogout/UserLogoutStatus';
|
|
|
+import LoadingIndicator from '../../common/components/LoadingIndicator';
|
|
|
+
|
|
|
|
|
|
const actions = [
|
|
|
userLogoutActions,
|
|
|
@@ -82,29 +84,51 @@ class UserLogoutContainer extends Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- let {showConfirmLogoutModal, logoutStatus} = this.props.userLogout;
|
|
|
+ let {showConfirmLogoutModal, logoutStatus, isFetching, tipMessage} = this.props.userLogout;
|
|
|
if (logoutStatus == 0) {
|
|
|
- return (
|
|
|
- <UserLogout
|
|
|
- showConfirmLogoutModal = {showConfirmLogoutModal}
|
|
|
- onPressLogoutClause = {this._onPressLogoutClause}
|
|
|
- confirmLogoutAction = {this._confirmLogoutAction}
|
|
|
- updateLogoutModalState = {this._updateLogoutModalState}
|
|
|
- />
|
|
|
- );
|
|
|
+ if (isFetching) {
|
|
|
+ return (
|
|
|
+ <LoadingIndicator isVisible={isFetching}/>
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return(
|
|
|
+ <UserLogout
|
|
|
+ showConfirmLogoutModal = {showConfirmLogoutModal}
|
|
|
+ onPressLogoutClause = {this._onPressLogoutClause}
|
|
|
+ confirmLogoutAction = {this._confirmLogoutAction}
|
|
|
+ updateLogoutModalState = {this._updateLogoutModalState}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
} else if(logoutStatus == 1){
|
|
|
- return (
|
|
|
- <UserLogoutStatus
|
|
|
- />
|
|
|
- );
|
|
|
+ if (isFetching) {
|
|
|
+ return (
|
|
|
+ <LoadingIndicator isVisible={isFetching}/>
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return (
|
|
|
+ <UserLogoutStatus
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}else if(logoutStatus == 3){
|
|
|
- return (
|
|
|
- <UserLogoutFaild
|
|
|
- isFaildReasonPage={false}
|
|
|
- gotoLogoutFaildReason={this._gotoLogoutFaildReason}
|
|
|
- gotoLogoutReason={this._gotoLogoutReason}
|
|
|
- />
|
|
|
- );
|
|
|
+ if (isFetching) {
|
|
|
+ return (
|
|
|
+ <LoadingIndicator isVisible={isFetching}/>
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return (
|
|
|
+ <UserLogoutFaild
|
|
|
+ isFaildReasonPage={false}
|
|
|
+ gotoLogoutFaildReason={this._gotoLogoutFaildReason}
|
|
|
+ gotoLogoutReason={this._gotoLogoutReason}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
diff --git a/js/userLogout/reducers/userLogout/userLogoutActions.js b/js/userLogout/reducers/userLogout/userLogoutActions.js
|
|
|
index 7c1cd0f..73e296d 100644
|
|
|
--- a/js/userLogout/reducers/userLogout/userLogoutActions.js
|
|
|
+++ b/js/userLogout/reducers/userLogout/userLogoutActions.js
|
|
|
@@ -15,7 +15,9 @@ import UserLogoutService from '../../services/UserLogoutService';
|
|
|
|
|
|
const {
|
|
|
UPDATE_LOGOUT_MODAL_STATE,
|
|
|
- UPDATE_LOGOUT_STATUS,
|
|
|
+ FETCH_LOGOUT_STATUS_REQUEST,
|
|
|
+ FETCH_LOGOUT_STATUS_SUCCESS,
|
|
|
+ FETCH_LOGOUT_STATUS_FAILURE,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
export function onPressLogoutClause() {
|
|
|
@@ -32,10 +34,23 @@ export function updateLogoutModalState(flag) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function updateLogoutStatus(status) {
|
|
|
+export function fetchLogoutStatusRequest() {
|
|
|
return{
|
|
|
- type: UPDATE_LOGOUT_STATUS,
|
|
|
- payload: status
|
|
|
+ type: FETCH_LOGOUT_STATUS_REQUEST
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function fetchLogoutStatusSuccess(obj) {
|
|
|
+ return{
|
|
|
+ type: FETCH_LOGOUT_STATUS_SUCCESS,
|
|
|
+ payload: obj
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function fetchLogoutStatusFailure(message) {
|
|
|
+ return{
|
|
|
+ type: FETCH_LOGOUT_STATUS_FAILURE,
|
|
|
+ payload: message
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -50,14 +65,14 @@ export function confirmLogoutAction() {
|
|
|
export function checkUserLogedIn() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app} = getState();
|
|
|
-
|
|
|
+ dispatch(fetchLogoutStatusRequest());
|
|
|
let fetchLogoutState = (uid) => {
|
|
|
return new UserLogoutService(app.host).fetchLogoutState(uid)
|
|
|
.then(json => {
|
|
|
- dispatch(updateLogoutStatus(json.status));
|
|
|
+ dispatch(fetchLogoutStatusSuccess({state:json.status, descList:json.desc}));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
- console.log(error);
|
|
|
+ dispatch(fetchLogoutStatusFailure(error.message?error.message:'网络错误'));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
diff --git a/js/userLogout/reducers/userLogout/userLogoutInitialState.js b/js/userLogout/reducers/userLogout/userLogoutInitialState.js
|
|
|
index 2cfd563..7c29171 100755
|
|
|
--- a/js/userLogout/reducers/userLogout/userLogoutInitialState.js
|
|
|
+++ b/js/userLogout/reducers/userLogout/userLogoutInitialState.js
|
|
|
@@ -9,9 +9,11 @@
|
|
|
import {Record, List, Map} from 'immutable';
|
|
|
|
|
|
let InitialState = Record({
|
|
|
- isFetching: false,
|
|
|
+ isFetching: true,
|
|
|
showConfirmLogoutModal: false,
|
|
|
logoutStatus: 0,
|
|
|
+ tipMessage: '',
|
|
|
+ cancleFialdDesc: List(),
|
|
|
});
|
|
|
|
|
|
export default InitialState;
|
|
|
diff --git a/js/userLogout/reducers/userLogout/userLogoutReducer.js b/js/userLogout/reducers/userLogout/userLogoutReducer.js
|
|
|
index db68fd4..d82c037 100644
|
|
|
--- a/js/userLogout/reducers/userLogout/userLogoutReducer.js
|
|
|
+++ b/js/userLogout/reducers/userLogout/userLogoutReducer.js
|
|
|
@@ -4,14 +4,18 @@
|
|
|
* @date: 2018/04/13
|
|
|
*/
|
|
|
|
|
|
+
|
|
|
'use strict';
|
|
|
|
|
|
import InitialState from './userLogoutInitialState';
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
+import {fetchLogoutStatusFailure, fetchLogoutStatusRequest} from "./userLogoutActions";
|
|
|
|
|
|
const {
|
|
|
UPDATE_LOGOUT_MODAL_STATE,
|
|
|
- UPDATE_LOGOUT_STATUS
|
|
|
+ FETCH_LOGOUT_STATUS_REQUEST,
|
|
|
+ FETCH_LOGOUT_STATUS_SUCCESS,
|
|
|
+ FETCH_LOGOUT_STATUS_FAILURE,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
const initialState = new InitialState;
|
|
|
@@ -21,8 +25,17 @@ export default function userLogoutReducer(state=initialState, action) {
|
|
|
case UPDATE_LOGOUT_MODAL_STATE:{
|
|
|
return state.set('showConfirmLogoutModal',action.payload);
|
|
|
}
|
|
|
- case UPDATE_LOGOUT_STATUS: {
|
|
|
- return state.set('logoutStatus',action.payload);
|
|
|
+ case fetchLogoutStatusRequest:{
|
|
|
+ return state.set('isFetching', true);
|
|
|
+ }
|
|
|
+ case FETCH_LOGOUT_STATUS_SUCCESS:{
|
|
|
+ return state.set('logoutStatus',action.payload.state)
|
|
|
+ .set('cancleFialdDesc', Immutable.fromJS(action.payload.descList))
|
|
|
+ .set('isFetching', false);
|
|
|
+ }
|
|
|
+ case fetchLogoutStatusFailure:{
|
|
|
+ return state.set('isFetching', false)
|
|
|
+ .set('tipMessage', action.payload);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
--
|
|
|
2.10.1
|
|
|
|
...
|
...
|
|