Signup.js
3.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
import React, { Component } from 'react';
import { View, Text, StyleSheet,TextInput, TouchableOpacity } from 'react-native';
import {SERVER} from '../../common/servername'
import {post} from 'axios'
import AsyncStorage from '@react-native-community/async-storage';
export default class AddTab extends Component {
static navigationOptions = {
headerShown: false
}
state = {
nickname:"",
email:"",
password:"",
provider:'local',
res:"",
phone:""
}
constructor(props) {
super(props)
}
componentDidMount() {
if(this.props.navigation.state.params && this.props.navigation.state.params.phone) {
this.setState({
phone:this.props.navigation.state.params.phone
})
}
}
HandleNavigate= () => {
const {nickname,email,password,provider} = this.state
post(`http://${SERVER}/auth/join`,{nickname,email,password,provider,phone:this.state.phone}).then(e => {
if(e.data.success) {
alert("회원가입이 완료되었습니다.")
AsyncStorage.setItem('user', JSON.stringify(e.data.data));
this.props.navigation.navigate("LoginTab")
}
else {
alert(e.data.message)
}
})
}
render() {
return (
<View style={{paddingTop:"10%",flex:1,justifyContent:"center",backgroundColor:"white"}}>
<View>
<Text style={{paddingLeft:"10%",color:"#615F5F",fontSize:15}}>
닉네임
</Text>
</View>
<TextInput value={this.state.nickname} onChangeText={e => {
this.setState({
nickname:e
})
}} placeholder="상가톡" style={{marginLeft:"10%",marginRight:"10%",paddingLeft:16,fontSize:15,borderColor:"#FFD63A",borderWidth:1,paddingTop:9,paddingBottom:9,marginTop:16,marginBottom:16}}/>
<View>
<Text style={{paddingLeft:"10%",color:"#615F5F",fontSize:15}}>
이메일 아이디
</Text>
</View>
<TextInput value={this.state.email} onChangeText={e => this.setState({email:e})} keyboardType="email-address" placeholder="talk@sangga.io" style={{marginLeft:"10%",marginRight:"10%",paddingLeft:16,fontSize:15,borderColor:"#FFD63A",borderWidth:1,paddingTop:9,paddingBottom:9,marginTop:16,marginBottom:16}}/>
<View>
<Text style={{paddingLeft:"10%",color:"#615F5F",fontSize:15}}>
비밀번호
</Text>
</View>
<TextInput secureTextEntry={true} value={this.state.password} onChangeText={e => this.setState({password:e})} placeholder="*************" style={{marginLeft:"10%",marginRight:"10%",paddingLeft:16,fontSize:15,borderColor:"#FFD63A",borderWidth:1,paddingTop:9,paddingBottom:9,marginTop:16,marginBottom:16}}/>
<View style={{display:"flex",flexDirection:"row",position:"absolute",bottom:0,width:"100%"}}>
<TouchableOpacity onPress={() => this.HandleNavigate()} style={{flex:1,backgroundColor:"#f4cd37",padding:10}}>
<Text style={{textAlign:"center",fontSize:18,color:"white"}}>
확인
</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const style = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});