134 lines
3.2 KiB
Vue
134 lines
3.2 KiB
Vue
<template>
|
|
<div class="full-h is-flex is-justify-content-center is-align-items-center">
|
|
<form class="box">
|
|
<div class="has-text-centered">
|
|
<h2 class="is-size-4">
|
|
<strong>Inscripción de servicios de CeDeTec</strong>
|
|
</h2>
|
|
|
|
<h2 class="is-size-4"><strong>periodo 2022-2</strong></h2>
|
|
</div>
|
|
|
|
<b-field label="Número de cuenta" :type="error">
|
|
<b-input
|
|
type="text"
|
|
placeholder="Número de cuenta"
|
|
@keyup.enter.native="login()"
|
|
v-model="numeroCuenta"
|
|
/>
|
|
</b-field>
|
|
|
|
<b-field label="Contraseña" :type="error">
|
|
<b-input
|
|
type="password"
|
|
placeholder="NIP de escolares"
|
|
@keyup.enter.native="login()"
|
|
v-model="password"
|
|
password-reveal
|
|
/>
|
|
</b-field>
|
|
<p class="font" :class="colorSize">
|
|
Si no recuerdas tu NIP de escolares, ingresa aquí:
|
|
<a href="https://sistemas.acatlan.unam.mx/recuperanip/" target="_blanc"
|
|
>Escolares</a
|
|
>
|
|
</p>
|
|
|
|
<div class="has-text-centered">
|
|
<b-button
|
|
@click="login()"
|
|
type="is-success"
|
|
:disabled="error || !(numeroCuenta && password)"
|
|
>
|
|
Iniciar Sesión
|
|
</b-button>
|
|
</div>
|
|
</form>
|
|
</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 {
|
|
numeroCuenta: '',
|
|
password: '',
|
|
error: '',
|
|
}
|
|
},
|
|
methods: {
|
|
login() {
|
|
if (this.numeroCuenta && this.password && !this.error) {
|
|
const data = {
|
|
numeroCuenta: this.numeroCuenta,
|
|
passwordUser: this.password,
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.post(`${process.env.api}/Usuario/login`, data)
|
|
.then((res) => {
|
|
const info = res.data.Usuario
|
|
|
|
localStorage.setItem('token', res.data.token)
|
|
localStorage.setItem('idUsuario', info.idUsuario)
|
|
localStorage.setItem('nombre', info.nombre)
|
|
localStorage.setItem('generacion', info.generacion)
|
|
localStorage.setItem('usuario', info.numeroCuenta)
|
|
localStorage.setItem('idCarrera', info.idCarrera)
|
|
localStorage.setItem('carrera', info.carrera)
|
|
|
|
this.updateIsLoading(false)
|
|
this.$router.push(`/registro`)
|
|
})
|
|
.catch((err) => {
|
|
this.error = 'is-danger'
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
password() {
|
|
if (this.error) this.error = ''
|
|
},
|
|
usuario() {
|
|
if (this.error) this.error = ''
|
|
},
|
|
},
|
|
computed: {
|
|
colorSize() {
|
|
return { fontColor: this.error == 'is-danger' }
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.font {
|
|
font-size: 12px;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
.fontColor {
|
|
color: red;
|
|
}
|
|
|
|
.full-h {
|
|
height: 75vh;
|
|
}
|
|
|
|
form {
|
|
width: 30rem;
|
|
}
|
|
</style>
|