최동원

error fix

......@@ -5,11 +5,13 @@ const instance = axios.create({
});
function registerUser(userData) {
return instance.post('RegistUser', userData);
// const url = 'http://localhost:3000/api/signup'
return axios.post('/api/RegistUser', userData);
}
function loginUser(userData) {
return instance.post('login', userData);
// const url = 'http://localhost:3000/api/login'
return axios.post('/api/login', userData);
}
export { registerUser, loginUser };
\ No newline at end of file
......
......@@ -22,23 +22,10 @@
>
<v-toolbar-title>KhuLoud</v-toolbar-title>
<v-spacer></v-spacer>
<!-- <v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn
:href="source"
icon
large
target="_blank"
v-on="on"
>
<v-icon>mdi-code-tags</v-icon>
</v-btn>
</template>
<span>Source</span>
</v-tooltip> -->
</v-toolbar>
<v-card-text>
<v-form @submit.prevent="submitForm">
<v-form >
<v-text-field
label="ID"
name="ID"
......@@ -57,8 +44,7 @@
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<!-- <v-btn color="primary" @click = "$router.push({name: 'RegistUser'})">Regist</v-btn> -->
<v-btn color="primary" :disabled="!id || !password" router :to="{name: 'Main'}" exact>Login</v-btn>
<v-btn color="primary" :disabled="!id || !password" @click="submitForm">Login</v-btn>
</v-card-actions>
</v-card>
</v-col>
......@@ -69,7 +55,7 @@
</template>
<script>
import { loginUser } from '../api/index'
export default {
data() {
......@@ -81,24 +67,27 @@
methods: {
async submitForm(){
try {
const usderData = {
id: this.id,
password: this.password
const userData = {
user_id: this.id,
user_pw: this.password
};
const { data } = await loginUser(userData);
this.$store.commit('setid', data.user.userid);
console.log(data);
this.$store.commit('setId', data.user_id);
this.$router.push('/main');
} catch (error) {
console.log("에러");
console.log(error.response.data);
} finally {
this.initForm();
}
}
},
initForm(){
this.id ='';
this.password='';
}
},
}
</script>
......
......@@ -24,7 +24,7 @@
<v-spacer></v-spacer>
</v-toolbar>
<v-card-text>
<v-form @submit.prevent="submitForm">
<v-form>
<v-text-field
label="ID"
v-model="id"
......@@ -49,7 +49,6 @@
<v-text-field
label="E-mail"
v-model="email"
:rules="emailRules"
name="Email"
></v-text-field>
......@@ -62,7 +61,7 @@
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" :disabled="!id || !password || !name || !email || !contact" @click = "$router.push({name: 'Login'})">Regist</v-btn>
<v-btn color="primary" :disabled="!id || !password || !name || !email || !contact" @click="submitForm">Regist</v-btn>
</v-card-actions>
</v-card>
</v-col>
......@@ -73,6 +72,8 @@
</template>
<script>
import { registerUser } from '../api/index'
export default {
data() {
return {
......@@ -86,17 +87,19 @@
methods: {
async submitForm() {
try {
const usderData = {
id: this.id,
password: this.password,
name: this.name,
email: this.email,
contact: this.contact
const userData = {
user_id: this.id,
user_pw: this.password,
user_name: this.name,
user_email: this.email,
user_phone: this.contact
};
const { data } = await registerUser(userData);
console.log("회원가입 완료");
this.$router.push('/');
} catch (error) {
console.log("에러");
console.log(error.response.data);
} finally{
this.initForm();
......
......@@ -4,6 +4,7 @@
v-model="drawer"
:clipped="$vuetify.breakpoint.lgAndUp"
app
v-if="isUserLogin"
>
<v-list dense>
<v-list-item router :to="{name: 'Main'}" exact>
......@@ -88,10 +89,8 @@
color="blue darken-3"
dark
>
<!-- <template v-if="isUserLogin">
<v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
</template> -->
<v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
<v-app-bar-nav-icon @click.stop="drawer = !drawer" v-if="isUserLogin"></v-app-bar-nav-icon>
<v-toolbar-title
style="width: 300px"
class="ml-0 pl-4"
......@@ -111,32 +110,20 @@
<template v-else>
<div></div>
</template>
<!-- <v-text-field
v-if="isUserLogin"
flat
solo-inverted
hide-details
prepend-inner-icon="mdi-magnify"
label="전체 검색"
class="hidden-sm-and-down"
></v-text-field> -->
<v-spacer></v-spacer>
<template v-if="isUserLogin">
<v-btn icon @click = "logoutUser">
<v-icon>mid-login</v-icon>
<v-icon>mdi-login</v-icon>
</v-btn>
</template>
<template v-else>
<v-btn icon @click = "$router.push({name: 'Login'})">
<v-icon>mdi-login</v-icon>
</v-btn>
<v-btn icon @click="$router.push({name: 'RegistUser'})">
<v-btn icon @click = "$router.push({name: 'RegistUser'})">
<v-icon>mdi-account</v-icon>
</v-btn>
</template>
<!-- <v-btn icon @click = "$router.push({name: 'Login'})">
<v-icon>mdi-login</v-icon>
</v-btn> -->
</v-app-bar>
<v-content>
<v-container
......@@ -272,7 +259,7 @@ export default {
}),
computed: {
isUserLogin(){
return this.$store.getters.isUserLogin;
return this.$store.getters.isLogin;
},
},
methods: {
......
......@@ -9,7 +9,7 @@ export default new Vuex.Store({
},
mutations: {
setId(state, userid){
state.id = id;
state.id = userid;
},
clearid(state){
state.id= '';
......