최동원

error fix

...@@ -5,11 +5,13 @@ const instance = axios.create({ ...@@ -5,11 +5,13 @@ const instance = axios.create({
5 }); 5 });
6 6
7 function registerUser(userData) { 7 function registerUser(userData) {
8 - return instance.post('RegistUser', userData); 8 + // const url = 'http://localhost:3000/api/signup'
9 + return axios.post('/api/RegistUser', userData);
9 } 10 }
10 11
11 function loginUser(userData) { 12 function loginUser(userData) {
12 - return instance.post('login', userData); 13 + // const url = 'http://localhost:3000/api/login'
14 + return axios.post('/api/login', userData);
13 } 15 }
14 16
15 export { registerUser, loginUser }; 17 export { registerUser, loginUser };
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -22,23 +22,10 @@ ...@@ -22,23 +22,10 @@
22 > 22 >
23 <v-toolbar-title>KhuLoud</v-toolbar-title> 23 <v-toolbar-title>KhuLoud</v-toolbar-title>
24 <v-spacer></v-spacer> 24 <v-spacer></v-spacer>
25 - <!-- <v-tooltip bottom> 25 +
26 - <template v-slot:activator="{ on }">
27 - <v-btn
28 - :href="source"
29 - icon
30 - large
31 - target="_blank"
32 - v-on="on"
33 - >
34 - <v-icon>mdi-code-tags</v-icon>
35 - </v-btn>
36 - </template>
37 - <span>Source</span>
38 - </v-tooltip> -->
39 </v-toolbar> 26 </v-toolbar>
40 <v-card-text> 27 <v-card-text>
41 - <v-form @submit.prevent="submitForm"> 28 + <v-form >
42 <v-text-field 29 <v-text-field
43 label="ID" 30 label="ID"
44 name="ID" 31 name="ID"
...@@ -57,8 +44,7 @@ ...@@ -57,8 +44,7 @@
57 </v-card-text> 44 </v-card-text>
58 <v-card-actions> 45 <v-card-actions>
59 <v-spacer></v-spacer> 46 <v-spacer></v-spacer>
60 - <!-- <v-btn color="primary" @click = "$router.push({name: 'RegistUser'})">Regist</v-btn> --> 47 + <v-btn color="primary" :disabled="!id || !password" @click="submitForm">Login</v-btn>
61 - <v-btn color="primary" :disabled="!id || !password" router :to="{name: 'Main'}" exact>Login</v-btn>
62 </v-card-actions> 48 </v-card-actions>
63 </v-card> 49 </v-card>
64 </v-col> 50 </v-col>
...@@ -69,7 +55,7 @@ ...@@ -69,7 +55,7 @@
69 </template> 55 </template>
70 56
71 <script> 57 <script>
72 - 58 +import { loginUser } from '../api/index'
73 59
74 export default { 60 export default {
75 data() { 61 data() {
...@@ -81,24 +67,27 @@ ...@@ -81,24 +67,27 @@
81 methods: { 67 methods: {
82 async submitForm(){ 68 async submitForm(){
83 try { 69 try {
84 - const usderData = { 70 + const userData = {
85 - id: this.id, 71 + user_id: this.id,
86 - password: this.password 72 + user_pw: this.password
87 }; 73 };
88 const { data } = await loginUser(userData); 74 const { data } = await loginUser(userData);
89 - this.$store.commit('setid', data.user.userid); 75 + console.log(data);
76 +
77 + this.$store.commit('setId', data.user_id);
90 this.$router.push('/main'); 78 this.$router.push('/main');
91 79
92 } catch (error) { 80 } catch (error) {
81 + console.log("에러");
93 console.log(error.response.data); 82 console.log(error.response.data);
94 } finally { 83 } finally {
95 this.initForm(); 84 this.initForm();
96 } 85 }
97 - }
98 }, 86 },
99 initForm(){ 87 initForm(){
100 this.id =''; 88 this.id ='';
101 this.password=''; 89 this.password='';
102 } 90 }
91 + },
103 } 92 }
104 </script> 93 </script>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
24 <v-spacer></v-spacer> 24 <v-spacer></v-spacer>
25 </v-toolbar> 25 </v-toolbar>
26 <v-card-text> 26 <v-card-text>
27 - <v-form @submit.prevent="submitForm"> 27 + <v-form>
28 <v-text-field 28 <v-text-field
29 label="ID" 29 label="ID"
30 v-model="id" 30 v-model="id"
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
49 <v-text-field 49 <v-text-field
50 label="E-mail" 50 label="E-mail"
51 v-model="email" 51 v-model="email"
52 - :rules="emailRules"
53 name="Email" 52 name="Email"
54 ></v-text-field> 53 ></v-text-field>
55 54
...@@ -62,7 +61,7 @@ ...@@ -62,7 +61,7 @@
62 </v-card-text> 61 </v-card-text>
63 <v-card-actions> 62 <v-card-actions>
64 <v-spacer></v-spacer> 63 <v-spacer></v-spacer>
65 - <v-btn color="primary" :disabled="!id || !password || !name || !email || !contact" @click = "$router.push({name: 'Login'})">Regist</v-btn> 64 + <v-btn color="primary" :disabled="!id || !password || !name || !email || !contact" @click="submitForm">Regist</v-btn>
66 </v-card-actions> 65 </v-card-actions>
67 </v-card> 66 </v-card>
68 </v-col> 67 </v-col>
...@@ -73,6 +72,8 @@ ...@@ -73,6 +72,8 @@
73 </template> 72 </template>
74 73
75 <script> 74 <script>
75 +import { registerUser } from '../api/index'
76 +
76 export default { 77 export default {
77 data() { 78 data() {
78 return { 79 return {
...@@ -86,17 +87,19 @@ ...@@ -86,17 +87,19 @@
86 methods: { 87 methods: {
87 async submitForm() { 88 async submitForm() {
88 try { 89 try {
89 - const usderData = { 90 + const userData = {
90 - id: this.id, 91 + user_id: this.id,
91 - password: this.password, 92 + user_pw: this.password,
92 - name: this.name, 93 + user_name: this.name,
93 - email: this.email, 94 + user_email: this.email,
94 - contact: this.contact 95 + user_phone: this.contact
95 }; 96 };
96 const { data } = await registerUser(userData); 97 const { data } = await registerUser(userData);
97 console.log("회원가입 완료"); 98 console.log("회원가입 완료");
98 this.$router.push('/'); 99 this.$router.push('/');
99 } catch (error) { 100 } catch (error) {
101 + console.log("에러");
102 +
100 console.log(error.response.data); 103 console.log(error.response.data);
101 } finally{ 104 } finally{
102 this.initForm(); 105 this.initForm();
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
4 v-model="drawer" 4 v-model="drawer"
5 :clipped="$vuetify.breakpoint.lgAndUp" 5 :clipped="$vuetify.breakpoint.lgAndUp"
6 app 6 app
7 + v-if="isUserLogin"
7 > 8 >
8 <v-list dense> 9 <v-list dense>
9 <v-list-item router :to="{name: 'Main'}" exact> 10 <v-list-item router :to="{name: 'Main'}" exact>
...@@ -88,10 +89,8 @@ ...@@ -88,10 +89,8 @@
88 color="blue darken-3" 89 color="blue darken-3"
89 dark 90 dark
90 > 91 >
91 - <!-- <template v-if="isUserLogin"> 92 +
92 - <v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon> 93 + <v-app-bar-nav-icon @click.stop="drawer = !drawer" v-if="isUserLogin"></v-app-bar-nav-icon>
93 - </template> -->
94 - <v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
95 <v-toolbar-title 94 <v-toolbar-title
96 style="width: 300px" 95 style="width: 300px"
97 class="ml-0 pl-4" 96 class="ml-0 pl-4"
...@@ -111,32 +110,20 @@ ...@@ -111,32 +110,20 @@
111 <template v-else> 110 <template v-else>
112 <div></div> 111 <div></div>
113 </template> 112 </template>
114 - <!-- <v-text-field
115 - v-if="isUserLogin"
116 - flat
117 - solo-inverted
118 - hide-details
119 - prepend-inner-icon="mdi-magnify"
120 - label="전체 검색"
121 - class="hidden-sm-and-down"
122 - ></v-text-field> -->
123 <v-spacer></v-spacer> 113 <v-spacer></v-spacer>
124 <template v-if="isUserLogin"> 114 <template v-if="isUserLogin">
125 <v-btn icon @click = "logoutUser"> 115 <v-btn icon @click = "logoutUser">
126 - <v-icon>mid-login</v-icon> 116 + <v-icon>mdi-login</v-icon>
127 </v-btn> 117 </v-btn>
128 </template> 118 </template>
129 <template v-else> 119 <template v-else>
130 <v-btn icon @click = "$router.push({name: 'Login'})"> 120 <v-btn icon @click = "$router.push({name: 'Login'})">
131 <v-icon>mdi-login</v-icon> 121 <v-icon>mdi-login</v-icon>
132 </v-btn> 122 </v-btn>
133 - <v-btn icon @click="$router.push({name: 'RegistUser'})"> 123 + <v-btn icon @click = "$router.push({name: 'RegistUser'})">
134 <v-icon>mdi-account</v-icon> 124 <v-icon>mdi-account</v-icon>
135 </v-btn> 125 </v-btn>
136 </template> 126 </template>
137 - <!-- <v-btn icon @click = "$router.push({name: 'Login'})">
138 - <v-icon>mdi-login</v-icon>
139 - </v-btn> -->
140 </v-app-bar> 127 </v-app-bar>
141 <v-content> 128 <v-content>
142 <v-container 129 <v-container
...@@ -272,7 +259,7 @@ export default { ...@@ -272,7 +259,7 @@ export default {
272 }), 259 }),
273 computed: { 260 computed: {
274 isUserLogin(){ 261 isUserLogin(){
275 - return this.$store.getters.isUserLogin; 262 + return this.$store.getters.isLogin;
276 }, 263 },
277 }, 264 },
278 methods: { 265 methods: {
......
...@@ -9,7 +9,7 @@ export default new Vuex.Store({ ...@@ -9,7 +9,7 @@ export default new Vuex.Store({
9 }, 9 },
10 mutations: { 10 mutations: {
11 setId(state, userid){ 11 setId(state, userid){
12 - state.id = id; 12 + state.id = userid;
13 }, 13 },
14 clearid(state){ 14 clearid(state){
15 state.id= ''; 15 state.id= '';
......