Files
premiaciones_front2/components/Login.vue
T

135 lines
3.1 KiB
Vue
Raw Normal View History

2022-05-08 23:45:51 -05:00
<template>
2022-05-14 23:40:38 -05:00
<div class="full-h cont">
2022-05-25 19:27:02 -05:00
<h2 class="has-text-centered is-size-2">Registro de invitados</h2>
2022-06-01 11:50:26 -05:00
<div class="cont-2 is-flex">
<div class="img">
2022-05-17 00:00:55 -05:00
<b-image
:src="require('@/assets/login_image.png')"
alt="LoginImage"
ratio="601by235"
class="my-4 img"
></b-image>
</div>
2022-06-01 11:50:26 -05:00
<div class="is-flex is-justify-content-center cont-login">
2022-05-25 19:27:02 -05:00
<form class="box" @submit.prevent="">
2022-05-17 00:00:55 -05:00
<p>
Para garantizar el acceso de sus invitados a la ceremonia de entrega
de medallas en la que usted será distinguido(a), le pedimos
completar el siguiente dato:
</p>
2022-05-23 17:54:44 -05:00
<b-field label="Número de trabajador" :type="error">
2022-05-17 00:00:55 -05:00
<b-input
type="number"
v-model="noTrabajador"
2022-05-25 19:27:02 -05:00
v-on:keydown.prevent="submit"
2022-05-17 00:00:55 -05:00
/>
</b-field>
2022-05-08 23:45:51 -05:00
2022-05-17 00:00:55 -05:00
<div class="has-text-centered">
<b-button
type="is-success"
2022-05-25 19:27:02 -05:00
native-type="submit"
@click="login()"
2022-05-17 00:00:55 -05:00
:disabled="error || !noTrabajador"
>
Iniciar sesión
</b-button>
</div>
</form>
</div>
2022-05-14 23:40:38 -05:00
</div>
2022-05-08 23:45:51 -05:00
</div>
</template>
<script>
import axios from 'axios'
export default {
props: {
imprimirMensaje: { type: Function, required: true },
imprimirWarning: { type: Function, required: true },
imprimirError: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
},
data() {
return {
noTrabajador: '',
error: '',
}
},
methods: {
login() {
2022-05-14 23:40:38 -05:00
if (this.noTrabajador && !this.error) {
const data = {
numeroTrabajador: this.noTrabajador,
2022-05-08 23:45:51 -05:00
}
this.updateIsLoading(true)
axios
.post(`${process.env.api}/profesor/login`, data)
.then((res) => {
2022-05-20 10:45:21 -05:00
this.updateIsLoading(false)
2022-05-08 23:45:51 -05:00
const info = res.data
localStorage.setItem('token', info.token)
localStorage.setItem('idProfesor', info.Profesor.idProfesor)
2022-05-11 00:45:13 -05:00
localStorage.setItem('nombre', info.Profesor.nombre)
localStorage.setItem('adscripcion', info.Profesor.adscripcion)
2022-05-14 23:40:38 -05:00
localStorage.setItem(
'numeroTrabajador',
info.Profesor.numeroTrabajador
)
2022-05-24 13:52:25 -05:00
this.$router.push('Profesor')
2022-05-08 23:45:51 -05:00
})
.catch((err) => {
this.updateIsLoading(false)
2022-05-20 10:45:21 -05:00
this.error = 'is-danger'
2022-05-24 18:06:54 -05:00
this.imprimirError(err.response.data.message)
2022-05-08 23:45:51 -05:00
})
}
},
},
watch: {
password() {
if (this.error) this.error = ''
},
usuario() {
if (this.error) this.error = ''
},
2022-05-14 23:40:38 -05:00
loginType() {
2022-05-08 23:45:51 -05:00
this.noTrabajador = ''
2022-05-14 23:40:38 -05:00
},
2022-05-08 23:45:51 -05:00
},
}
</script>
<style scoped>
.full-h {
2022-05-14 23:40:38 -05:00
min-height: 75vh;
}
.cont {
2022-05-17 00:00:55 -05:00
margin-top: 10rem;
}
2022-06-01 11:50:26 -05:00
@media (max-width: 768px) {
.img {
display: none;
}
.cont-login{
width: 382px;
}
.box
{
padding: 15px !important;
}
}
2022-05-25 19:27:02 -05:00
.img {
2022-05-17 00:00:55 -05:00
width: 30rem;
height: 14rem;
margin-right: 2rem;
2022-05-08 23:45:51 -05:00
}
form {
width: 30rem;
2022-05-17 00:00:55 -05:00
max-height: 15rem;
2022-05-08 23:45:51 -05:00
}
</style>