userLogoutReasonActions.js
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* sub app userLogout
* @author: lixia.zhang
* @date: 2018/04/13
*/
'use strict';
import ReactNative from 'react-native';
import UserLogoutReasonService from '../../services/UserLogoutReasonService';
const {
ENABLE_SUBMIT_BTN,
SHOW_LOGOUT_REASON_MODAL,
SET_IMAGE_CHECK_SWITCH_STATE,
IMAGE_CHECK_CODE_URL,
UPDATE_TIP_MESSAGE,
} = require('../../constants/actionTypes').default;
export function enableSubmitBtn(flag) {
return{
type:ENABLE_SUBMIT_BTN,
payload: flag
}
}
export function showLogoutReasonModal(state) {
return{
type:SHOW_LOGOUT_REASON_MODAL,
payload: state
}
}
export function setImageCheckSwitchState(state) {
return {
type: SET_IMAGE_CHECK_SWITCH_STATE,
payload: state
}
}
export function imgeCheckCodeUrl(url) {
return {
type: IMAGE_CHECK_CODE_URL,
payload: url
}
}
export function updateTipMessage(tipMesage) {
return {
type: UPDATE_TIP_MESSAGE,
payload: tipMesage
}
}
export function fetchImageCheckSwitchState() {
return (dispatch, getState) => {
let {app} = getState();
let udid = ReactNative.NativeModules.RNNativeConfig.udid;
return new UserLogoutReasonService('http://api-test3.yohops.com:9999/').fetchImageCheckSwitchState(udid)
.then(json => {
dispatch(setImageCheckSwitchState(json));
})
.catch(error => {
console.log(error);
});
}
}
export function fetchCanleCode(mobile, degrees) {
return (dispatch, getState) => {
let {app} = getState();
let udid = ReactNative.NativeModules.RNNativeConfig.udid;
return new UserLogoutReasonService('http://api-test3.yohops.com:9999/').fetchCancleCode(mobile, degrees, udid)
.then(json => {
dispatch(fetchImageCheckSwitchState());
dispatch(updateTipMessage('验证短信已发送,请注意查收'));
})
.catch(error => {
if(error.message != '') {
dispatch(updateTipMessage(error.message));
}
});
}
}
export function confirmLogout(code, reason) {
return (dispatch, getState) => {
let {app} = getState();
let udid = ReactNative.NativeModules.RNNativeConfig.udid;
return new UserLogoutReasonService('http://api-test3.yohops.com:9999/').confirmLogout(code, reason, udid)
.then(json => {
dispatch(showLogoutReasonModal(false));
dispatch(gotoLogoutStatus());
})
.catch(error => {
if(error.message != '') {
dispatch(updateTipMessage(error.message));
}
});
}
}
export function generateCheckImageUrl() {
return (dispatch, getState) => {
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;
dispatch(imgeCheckCodeUrl(imageUrl));
}
}
export function gotoLogoutStatus() {
return (dispatch, getState) => {
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.userLogout","params":{"title":"申请状态","type":"userLogoutStatus"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
}