Conexion a la API
This commit is contained in:
+22
-16
@@ -5,15 +5,19 @@
|
||||
<h2 class="is-size-1">CEDETEC</h2>
|
||||
</div>
|
||||
|
||||
<b-field label="Usuario" :type="error">
|
||||
<b-input type="text" @keyup.enter.native="login()" v-model="usuario" />
|
||||
<b-field label="Número de cuenta" :type="error">
|
||||
<b-input
|
||||
type="text"
|
||||
@keyup.enter.native="login()"
|
||||
v-model="numeroCuenta"
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Carrera" :type="error">
|
||||
<b-input type="text" @keyup.enter.native="login()" v-model="usuario" />
|
||||
</b-field>
|
||||
<!-- <b-field label="Carrera" :type="error">
|
||||
<b-input type="text" @keyup.enter.native="login()" v-model="carrera" />
|
||||
</b-field> -->
|
||||
|
||||
<b-field label="Contraseña" :type="error">
|
||||
<b-field label="NIP" :type="error">
|
||||
<b-input
|
||||
type="password"
|
||||
@keyup.enter.native="login()"
|
||||
@@ -26,7 +30,7 @@
|
||||
<b-button
|
||||
@click="login()"
|
||||
type="is-success"
|
||||
:disabled="error || !(usuario && password)"
|
||||
:disabled="error || !(numeroCuenta && password)"
|
||||
>
|
||||
Iniciar Sesión
|
||||
</b-button>
|
||||
@@ -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'
|
||||
|
||||
@@ -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))
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user