From 68e08c36d0251db6b09318ba789cbaef04d798e7 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Wed, 26 Jan 2022 20:43:35 -0600 Subject: [PATCH] Conexion a la API --- components/Login.vue | 38 ++++++++++++++++------------ components/registro/DatosUsuario.vue | 12 +++------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/components/Login.vue b/components/Login.vue index 830f837..828715b 100644 --- a/components/Login.vue +++ b/components/Login.vue @@ -5,15 +5,19 @@

CEDETEC

- - + + - - - + - + Iniciar Sesión @@ -47,29 +51,31 @@ export default { }, data() { return { - usuario: '', - carrera: '', + numeroCuenta: '', + // carrera: '', password: '', error: '', } }, methods: { login() { - if (this.usuario && this.password && !this.error) { + if (this.numeroCuenta && this.password && !this.error) { const data = { - usuario: this.usuario, - password: this.password, + usuario: 'votacionesUser', + password: 'poasfnr*/049_]', + numeroCuenta: this.numeroCuenta, + passwordUser: this.password, } this.updateIsLoading(true) axios .post(`${process.env.api}/usuario/login`, data) .then((res) => { - const info = res.data - - localStorage.setItem('token', info.token) + const info = res.data.data + localStorage.setItem('datosUsuario', JSON.stringify(info)) + // localStorage.setItem('token', info.token) this.updateIsLoading(false) - this.$router.push(`/${''}`) + this.$router.push(`/${'registro'}`) }) .catch((err) => { this.error = 'is-danger' diff --git a/components/registro/DatosUsuario.vue b/components/registro/DatosUsuario.vue index dec4872..544bef0 100644 --- a/components/registro/DatosUsuario.vue +++ b/components/registro/DatosUsuario.vue @@ -38,13 +38,7 @@ export default { data() { return { - datosUsuario: { - numeroCuenta: 419085500, - semestre: 7, - nombre: 'Saavedra Trejo Andrés Hernan', - carrera: 'MAT. APLICADAS Y COMP. (PLAN NUEVO)', - tipoCarrera: 2, - }, + datosUsuario: {}, data: [ { nombreArea: 'Windows', @@ -64,8 +58,8 @@ export default { return status === 1 ? 'Si' : 'No' }, }, - mounted() { - localStorage.setItem('datosUsuario', JSON.stringify(this.datosUsuario)) + created() { + this.datosUsuario = JSON.parse(localStorage.getItem('datosUsuario')) localStorage.setItem('inscripcionesUsuario', JSON.stringify(this.data)) }, }