Authored by lixia.zhang

用户注销,review by 孙凯

... ... @@ -10,9 +10,9 @@ import React, {Component} from 'react';
import ReactNative, {
View,
StyleSheet,
Image,
ScrollView,
Text,
TouchableOpacity
Dimensions
} from 'react-native';
... ... @@ -26,7 +26,7 @@ export default class LogoutClause extends Component {
render() {
return (
<View style={styles.container}>
<ScrollView style={[styles.container, {width: width, height:height}]}>
<View style={styles.titleContainer}>
<Text style={styles.title}>《有货账户注销条款》</Text>
</View>
... ... @@ -53,15 +53,17 @@ export default class LogoutClause extends Component {
3)账户在有货商城系统中无欠款;
</Text>
</View>
</View>
</ScrollView>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0'
backgroundColor: '#f0f0f0',
overflow: 'scroll'
},
title: {
fontSize: 14,
... ...
... ... @@ -168,10 +168,10 @@ let styles = StyleSheet.create({
height: 44,
borderRadius: 5,
alignItems: 'center',
justifyContent: 'center'
},
confirmText: {
textAlign: 'center',
lineHeight: 43,
color: 'white',
fontSize: 16
},
... ...
... ... @@ -12,6 +12,7 @@ export default keyMirror({
SET_HOST: null,
SET_SERVICE_HOST: null,
UPDATE_LOGOUT_MODAL_STATE: null,
UPDATE_LOGOUT_STATUS: null,
//注销原因
... ...
... ... @@ -17,6 +17,8 @@ import {connect} from 'react-redux';
import {Map} from 'immutable';
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';
const actions = [
userLogoutActions,
... ... @@ -47,10 +49,12 @@ class UserLogoutContainer extends Component {
this._onPressLogoutClause = this._onPressLogoutClause.bind(this);
this._confirmLogoutAction = this._confirmLogoutAction.bind(this);
this._updateLogoutModalState = this._updateLogoutModalState.bind(this);
this._gotoLogoutFaildReason = this._gotoLogoutFaildReason.bind(this);
this._gotoLogoutReason = this._gotoLogoutReason.bind(this);
}
componentDidMount() {
this.props.actions.checkUserLogedIn();
}
componentWillUnmount() {
... ... @@ -69,16 +73,39 @@ class UserLogoutContainer extends Component {
this.props.actions.updateLogoutModalState(flag);
}
_gotoLogoutFaildReason(){
this.props.actions.gotoLogoutFaildReason()
}
_gotoLogoutReason(){
this.props.actions.gotoLogoutReason()
}
render() {
let {showConfirmLogoutModal} = this.props.userLogout;
return (
<UserLogout
showConfirmLogoutModal = {showConfirmLogoutModal}
onPressLogoutClause = {this._onPressLogoutClause}
confirmLogoutAction = {this._confirmLogoutAction}
updateLogoutModalState = {this._updateLogoutModalState}
/>
);
let {showConfirmLogoutModal, logoutStatus} = this.props.userLogout;
if (logoutStatus == 0) {
return (
<UserLogout
showConfirmLogoutModal = {showConfirmLogoutModal}
onPressLogoutClause = {this._onPressLogoutClause}
confirmLogoutAction = {this._confirmLogoutAction}
updateLogoutModalState = {this._updateLogoutModalState}
/>
);
} else if(logoutStatus == 1){
return (
<UserLogoutStatus
/>
);
}else if(logoutStatus == 3){
return (
<UserLogoutFaild
isFaildReasonPage={false}
gotoLogoutFaildReason={this._gotoLogoutFaildReason}
gotoLogoutReason={this._gotoLogoutReason}
/>
);
}
}
}
... ...
... ... @@ -67,6 +67,9 @@ class UserLogoutReasonContainer extends Component {
}
_showLogoutReasonModalAction(state) {
if(state){
this.props.actions.generateCheckImageUrl();
}
this.props.actions.showLogoutReasonModal(state);
}
... ...
... ... @@ -15,6 +15,7 @@ import UserLogoutService from '../../services/UserLogoutService';
const {
UPDATE_LOGOUT_MODAL_STATE,
UPDATE_LOGOUT_STATUS,
} = require('../../constants/actionTypes').default;
export function onPressLogoutClause() {
... ... @@ -31,11 +32,47 @@ export function updateLogoutModalState(flag) {
}
}
export function updateLogoutStatus(status) {
return{
type: UPDATE_LOGOUT_STATUS,
payload: status
}
}
export function confirmLogoutAction() {
return (dispatch, getState) => {
dispatch(updateLogoutModalState(false));
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.userLogout","params":{"title":"注销原因","type":"userLogouReason"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
}
export function checkUserLogedIn() {
return (dispatch, getState) => {
let {app} = getState();
let fetchLogoutState = (uid) => {
return new UserLogoutService('http://api-test3.yohops.com:9999/').fetchLogoutState(uid)
.then(json => {
dispatch(updateLogoutStatus(json.status));
})
.catch(error => {
console.log(error);
});
}
NativeModules.YH_CommonHelper.uid()
.then(uid => {
fetchLogoutState(uid)
})
.catch(error => {
NativeModules.YH_CommonHelper.login()
.then(uid => {
fetchLogoutState(uid)
})
.catch(error => {
});
});
}
}
... ...
... ... @@ -10,7 +10,8 @@ import {Record, List, Map} from 'immutable';
let InitialState = Record({
isFetching: false,
showConfirmLogoutModal: false
showConfirmLogoutModal: false,
logoutStatus: 0,
});
export default InitialState;
... ...
... ... @@ -11,6 +11,7 @@ import Immutable, {Map} from 'immutable';
const {
UPDATE_LOGOUT_MODAL_STATE,
UPDATE_LOGOUT_STATUS
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -20,6 +21,9 @@ 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);
}
}
return state;
... ...
... ... @@ -9,7 +9,6 @@
import ReactNative from 'react-native';
import UserLogoutReasonService from '../../services/UserLogoutReasonService';
import message from "../../../community/reducers/message/messageReducer";
const {
ENABLE_SUBMIT_BTN,
... ... @@ -60,9 +59,6 @@ export function fetchImageCheckSwitchState() {
let udid = ReactNative.NativeModules.RNNativeConfig.udid;
return new UserLogoutReasonService('http://api-test3.yohops.com:9999/').fetchImageCheckSwitchState(udid)
.then(json => {
if (json){
dispatch(generateCheckImageUrl());
}
dispatch(setImageCheckSwitchState(json));
})
.catch(error => {
... ... @@ -78,7 +74,7 @@ export function fetchCanleCode(mobile, degrees) {
return new UserLogoutReasonService('http://api-test3.yohops.com:9999/').fetchCancleCode(mobile, degrees, udid)
.then(json => {
dispatch(fetchImageCheckSwitchState());
console.log(json);
dispatch(updateTipMessage('验证短信已发送,请注意查收'));
})
.catch(error => {
if(error.message != '') {
... ... @@ -96,7 +92,6 @@ export function confirmLogout(code, reason) {
.then(json => {
dispatch(showLogoutReasonModal(false));
dispatch(gotoLogoutStatus());
})
.catch(error => {
if(error.message != '') {
... ... @@ -111,7 +106,7 @@ export function generateCheckImageUrl() {
let {app} = getState();
let udid = ReactNative.NativeModules.RNNativeConfig.udid;
var timeStamp = Date.parse(new Date());
let imageUrl = 'http://api-test3.yohops.com:9999/' + '/passport/img-check' + '?business_line=yohobuy' + '&udid=' + udid + '&fromPage=' + 'UserLogoutReason' + '&timeStamp=' + timeStamp;
let imageUrl = 'http://api-test3.yohops.com:9999' + '/passport/img-check' + '?business_line=yohobuy' + '&udid=' + udid + '&fromPage=' + 'UserLogoutReason' + '&timeStamp=' + timeStamp;
dispatch(imgeCheckCodeUrl(imageUrl));
}
}
... ...
... ... @@ -11,11 +11,27 @@ import Request from '../../common/services/NativeRequest';
export default class UserLogoutService {
constructor (host) {
let baseURL = 'http://api.yoho.cn';
if(host){
baseURL = host;
}
this.api = new Request(baseURL);
}
constructor (host) {
let baseURL = 'http://api.yoho.cn';
if(host){
baseURL = host;
}
this.api = new Request(baseURL);
}
async fetchLogoutState(uid) {
return await this.api.get({
url: '',
body: {
method: 'app.cancel.status',
uid,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...