myEvents.js
8.69 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/**
* Created by Cassie on 2018/03/21
*/
import React, { Component } from 'react';
import {
StyleSheet,
ScrollView,
View,
Text,
TouchableOpacity,
Image,
TextInput,
ActivityIndicator,
Keyboard
} from 'react-native';
import {width,height,zoomW,zoomH} from '../../utils/getSize';
import {getHeaderPadding,xnToast,MD5} from "../../utils/utils";
import xnService from "../../service/AppService";
import md5 from 'md5';
import { NavigationActions } from 'react-navigation';
const bgImg = require('../../img/bgImg.png');
const logo = require('../../img/logo.png');
const phone = require('../../img/phone.png');
const pwd = require('../../img/pwd.png');
const bitmap = require('../../img/bitmap.png');
const phoneRule = /^1[3456789]\d{9}$/;
export default class myEvents extends Component {
static navigationOptions = ({navigation,screenProps}) => ({
header:null
});
constructor(props){
super(props);
this.state = {
};
};
/*登录*/
logoIn(){
Keyboard.dismiss();
if(this.state.mobile.length ==0 || !phoneRule.test(this.state.mobile)){
xnToast('请输入正确的手机号!');
return;
}
if(this.state.password.length == 0){
xnToast('请输入密码!');
return;
}
if(this.state.password.length < 6 || this.state.password.length > 16){
xnToast('密码为6到16位!');
return;
}
let params = {
account:this.state.mobile,
password:md5(this.state.password).toLocaleLowerCase(),
};
this.setState({
loading:true
});
xnService.loginIn(params).then((data) => {
this.setState({
loading:false
});
if(data.message){
xnToast(data.message);
return;
}
if(data.errors.length > 0){
xnToast(data.errors[0].message);
}else{
global.user = data.user;
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Root'})
]
})
this.props.navigation.dispatch(resetAction)
}
});
};
/*跳转到忘记密码页面*/
toforgetPwd(){
this.props.navigation.navigate('ForgetPwd',{})
};
/*跳转到注册页面*/
toRegister(){
this.props.navigation.navigate('Register',{})
};
render(){
return(
<View style={styles.background}>
<View style={styles.bgImg}>
<Image style={{width:width,height:height}} source={bgImg} resizeMode="stretch" />
</View>
<View style={[styles.bgImg,{backgroundColor:'rgba(0,0,0,.2)'}]} resizeMode="cover" />
<View style={styles.signTop}>
<Image style={styles.logoImg} source={logo} />
<Text style={{color:'#fff',fontSize:18,fontWeight:'bold',backgroundColor:'rgba(0,0,0,0)'}}>平安地铁</Text>
</View>
<ScrollView style={styles.signMiddle} keyboardShouldPersistTaps="handled">
<View style={styles.inputItem}>
<View style={{width:(60/zoomW),display:'flex',justifyContent:'center',alignItems:'center'}}>
<Image style={{width:(22/zoomW),height:(22/zoomW)}} source={phone} resizeMode="center" />
</View>
<TextInput keyboardType="numeric" style={styles.input} placeholderTextColor="#fbfbfb" underlineColorAndroid="transparent" placeholder="输入手机号码" onChangeText={(value) => this.setState({mobile:value})} />
<View style={{width:(70/zoomW)}} />
</View>
<View style={styles.inputItem}>
<View style={{width:(60/zoomW),display:'flex',justifyContent:'center',alignItems:'center'}}>
<Image style={{width:(22/zoomW),height:(22/zoomW)}} source={pwd} resizeMode="center" />
</View>
<TextInput style={styles.input} placeholderTextColor="#fbfbfb" underlineColorAndroid="transparent" secureTextEntry={true} placeholder="输入密码" onChangeText={(value) => this.setState({password:value})} />
<TouchableOpacity style={{paddingLeft:(6/zoomW),paddingRight:(6/zoomW),display:'flex',justifyContent:'center',alignItems:'center'}} onPress={() => {this.toforgetPwd()}}>
<Text style={{fontSize:14,color:'#abd9ff',backgroundColor:'rgba(0,0,0,0)'}}>忘记密码?</Text>
</TouchableOpacity>
</View>
<TouchableOpacity activeOpacity={0.8} style={styles.signBtn} onPress={() => this.logoIn()}>
<Text style={{fontSize:18,color:'#fff'}}>登录</Text>
</TouchableOpacity>
<View style={{width:'100%',display:'flex',alignItems:'flex-end'}}>
<TouchableOpacity style={styles.registerBtn} onPress={() => this.toRegister()}>
<Text style={{fontSize:14,color:'#fff',backgroundColor:'rgba(0,0,0,0)'}}>立即注册</Text>
</TouchableOpacity>
</View>
</ScrollView>
{/*<View style={styles.signBottom}>*/}
{/*<View style={styles.quickTip}>*/}
{/*<View style={{flex:1,height:1,backgroundColor:'#f6f6f6'}} />*/}
{/*<View style={{width:(107/zoomW),display:'flex',justifyContent:'center',alignItems:'center'}}>*/}
{/*<Text style={{fontSize:14,color:'#fff'}}>快捷登录</Text>*/}
{/*</View>*/}
{/*<View style={{flex:1,height:1,backgroundColor:'#f6f6f6'}} />*/}
{/*</View>*/}
{/*<TouchableOpacity>*/}
{/*<Image style={{width:(40/zoomW),height:(40/zoomW)}} source={bitmap} resizeMode="cover" />*/}
{/*</TouchableOpacity>*/}
{/*</View>*/}
{/*<View style={{display:'flex',flexDirection:'row',justifyContent:'center'}}>*/}
{/*<Text style={{fontSize:13,color:'#fff'}}>登录即代表阅读并同意</Text>*/}
{/*<TouchableOpacity>*/}
{/*<Text style={{fontSize:13,color:'#239afa'}}>《平安地铁用户协议》</Text>*/}
{/*</TouchableOpacity>*/}
{/*</View>*/}
{this.state.loading && <View style={styles.loadingBg}>
<ActivityIndicator size="large" />
</View>}
</View>
);
}
}
const styles = StyleSheet.create({
background:{
flex:1,
paddingTop:getHeaderPadding()
},
bgImg:{
width:width,
height:height,
position:'absolute',
top:0,
bottom:0
},
signTop:{
width:'100%',
height:(160/zoomH),
display:'flex',
justifyContent:'flex-end',
alignItems:'center',
marginBottom:(20/zoomH)
},
logoImg:{
width:(84/zoomW),
height:(84/zoomW),
marginBottom:(8/zoomH)
},
signMiddle:{
width:'100%',
paddingLeft:(30/zoomW),
paddingRight:(30/zoomW)
},
inputItem:{
width:'100%',
height:(72/zoomH),
borderBottomWidth:1,
borderColor:'#f6f6f6',
borderStyle:'solid',
display:'flex',
flexDirection:'row',
},
input:{
flex:1,
height:'100%',
color:'#fbfbfb',
fontSize:16
},
signBtn:{
width:'100%',
height:(50/zoomH),
backgroundColor:'#239afa',
opacity:.7,
borderRadius:4,
marginTop:(38/zoomH),
display:'flex',
justifyContent:'center',
alignItems:'center'
},
registerBtn:{
width:(60/zoomW),
height:(54/zoomH),
display:'flex',
justifyContent:'center'
},
signBottom:{
width:'100%',
display:'flex',
alignItems:'center',
paddingLeft:(30/zoomW),
paddingRight:(30/zoomW),
marginTop:(40/zoomH),
marginBottom:(22/zoomH)
},
quickTip:{
width:'100%',
height:(20/zoomH),
display:'flex',
flexDirection:'row',
alignItems:'center',
marginBottom:(16/zoomH)
},
loadingBg:{
width:'100%',
height:'100%',
position:'absolute',
display:'flex',
alignItems:'center',
justifyContent:'center'
}
});