Files
premiaciones_front2/pages/Operador/index.vue
T
2022-05-29 23:17:52 -05:00

78 lines
1.8 KiB
Vue

<template>
<section class="container full-h">
<div class="my-3 has-text-centered">
<p class="is-size-2">Lector de códigos QR</p>
</div>
<div v-if="!isReading" class="has-text-centered mb-4">
<b-button type="is-info" @click="() => (this.isReading = true)">
Leer QR
</b-button>
</div>
<Scanner :enviar="enviar" v-if="isReading" />
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="false" />
</section>
</template>
<script>
import axios from 'axios'
import Scanner from '../../components/operador/Scanner.vue'
export default {
components: {
Scanner,
},
data() {
return {
isLoading: false,
isReading: false,
}
},
methods: {
enviar(idProfesor, idPremiacion) {
this.isLoading = true
this.isReading = false
const data = { idProfesor, idPremiacion }
axios
.post(`${process.env.api}/profesor/entradaInvitado`, data, {
headers: {
token: localStorage.getItem('token'),
},
})
.then((res) => {
this.isLoading = false
this.successUpload()
})
.catch((err) => {
this.isLoading = false
console.log(err)
this.errorMessage(err.response.data.message)
})
},
successUpload() {
this.$swal({
title: 'Se ha registrado la entrada del invitado.',
type: 'success',
timer: 5000,
confirmButtonText: 'Aceptar',
confirmButtonColor: '#1e3c70',
})
},
errorMessage(err) {
this.$swal({
title: err,
type: 'error',
timer: 5000,
confirmButtonText: 'Aceptar',
confirmButtonColor: '#1e3c70',
})
},
},
layout: 'default',
}
</script>
<style scoped>
.full-h {
min-height: 75vh;
}
</style>