setting.js
4.62 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
* Created by DEV005 on 2017/10/27.
*/
/**
* Created by tdzl2003 on 12/18/16.
*/
import React, {Component, PropTypes} from 'react';
import {
StyleSheet,
Image,
TouchableOpacity,
TouchableHighlight,
ScrollView,
Button,
TextInput,
Text,
View,
Alert,
NativeModules,
ListView,
RefreshControl,
DeviceEventEmitter,
AsyncStorage
} from 'react-native';
import {xnToast} from "./../utils/utils";
import AppService from "./../service/AppService";
import mainCss from "./../css/css";
import Loading from '../components/Loading'
import { NavigationActions } from 'react-navigation'
import Verification from "./publish/verification";
import Password from "./publish/password";
import MD5 from "md5";
let passwordOne="";
let passwordTwo="";
export default class password extends Component {
static navigationOptions = ({ navigation, screenProps })=>({
title: '设置密码',
headerLeft:(<View style={{flexDirection: 'row',flex: 1}}>
<TouchableOpacity style={{flexDirection: 'column',justifyContent: 'center',paddingRight:10,paddingLeft:10}} onPress={navigation.state.params?navigation.state.params._goBack:null}>
<Image style={{ width:20,height:20}} source={require('../img/back.png')} resizeMode="contain"/>
</TouchableOpacity>
<TouchableOpacity style={{flexDirection: 'column',justifyContent: 'center',paddingLeft:10}} onPress={navigation.state.params?navigation.state.params._close:null}>
<Image style={{ width:20,height:20}} source={require('../img/close.png')} resizeMode="contain"/>
</TouchableOpacity>
</View>)
});
constructor(props){
super(props);
this.state = {
title:"输入交易密码",
isVerification:false,
isLoading:false
};
}
componentWillMount(){
//设置头部
this.props.navigation.setParams({
_goBack:()=>{
this.props.navigation.goBack();
},
_close:()=>{
NativeModules.system.navTo("BACK")
}
});
let _this=this;
//获取列表
this._init();
}
_init=()=>{
};
//跳转
verification=(status)=>{
console.log(status);
if(status){
this.setState({
isVerification:true
})
}
};
_password=(pass)=>{
console.log(pass);
let _this=this;
if(passwordOne==""){
passwordOne=pass;
this.setState({
title:"确认交易密码"
});
DeviceEventEmitter.emit("initPassword","init");
return;
}else {
passwordTwo=pass;
}
if(passwordOne!=passwordTwo){
passwordOne="";
passwordTwo="";
xnToast("两次密码不一致,请重新输入!");
this.setState({
title:"输入交易密码"
});
DeviceEventEmitter.emit("initPassword","init");
return
}
if(passwordOne==passwordTwo){
let vm={
id:global.userId,
tenantId:global.tenantId,
transactionPassword:MD5(passwordOne)
};
this.setState({
isLoading:true
});
AppService.userTransactionPasswordUpdate(vm).then(data=>{
this.setState({
isLoading:false
});
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
xnToast("设置成功!");
passwordOne="";
passwordTwo="";
setTimeout(function () {
if(_this.props.navigation.state.params){
_this.props.navigation.state.params.callBack()
}
_this.props.navigation.goBack();
},2000)
});
}else {
}
};
render() {
return (
<View style={mainCss.body}>
<View style={mainCss.main}>
{!this.state.isVerification&&<Verification toForget={this.toForget} callBack={this.verification}></Verification>}
{this.state.isVerification&&<Password title={this.state.title} callBack={this._password} ></Password>}
<Loading visible={this.state.isLoading} content="验证中" ></Loading>
</View>
</View>
);
};
}