From ce9dee24c3053f4003c4cfaec6c88c562dc64650 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Tue, 10 May 2022 23:36:02 -0500 Subject: [PATCH] separacion del credito --- components/admin/restarCredito.vue | 12 ++++++++++-- components/impresion/datosTicket.vue | 23 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/components/admin/restarCredito.vue b/components/admin/restarCredito.vue index 9da6652..f97d639 100644 --- a/components/admin/restarCredito.vue +++ b/components/admin/restarCredito.vue @@ -35,6 +35,8 @@ export default { }, data() { return { + token: '', + numeroCuenta: '', credito: '', datos: {}, @@ -45,7 +47,8 @@ export default { this.updateIsLoading(true) axios .get( - `${process.env.api}/usuario/credito?numeroCuenta=${this.numeroCuenta}` + `${process.env.api}/admin/credito?numeroCuenta=${this.numeroCuenta}`, + this.token ) .then((res) => { this.updateIsLoading(false) @@ -65,7 +68,7 @@ export default { } this.updateIsLoading(true) axios - .get(`${process.env.api}/usuario/restar_credito`, data) + .get(`${process.env.api}/usuario/restar_credito`, data, this.token) .then((res) => { this.updateIsLoading(false) ;(this.datos.nombre = res.data.nombre), @@ -79,6 +82,11 @@ export default { }) }, }, + created() { + this.token = { + headers: { token: localStorage.getItem('token') }, + } + }, } diff --git a/components/impresion/datosTicket.vue b/components/impresion/datosTicket.vue index fc56a33..e10e04a 100644 --- a/components/impresion/datosTicket.vue +++ b/components/impresion/datosTicket.vue @@ -38,7 +38,7 @@
-

Tu crédito es de: $0 pesos

+

Tu crédito es de: ${{ creditoDisponible }} pesos

@@ -75,6 +75,8 @@ export default { monto: '', fechaTicket: null, + creditoDisponible: 0, + minDate: this.diaMin(today), maxDate: new Date(), @@ -82,6 +84,22 @@ export default { } }, methods: { + traerCredito() { + this.updateIsLoading(true) + axios + .get( + `${process.env.api}/usuario/credito?numeroCuenta=${this.numeroCuenta}`, + this.token + ) + .then((res) => { + this.updateIsLoading(false) + this.creditoDisponible = res.data.credito + }) + .catch((err) => { + this.updateIsLoading(false) + this.imprimirError(err.response.data) + }) + }, diaMin(today) { return new Date( today.getFullYear(), @@ -113,5 +131,8 @@ export default { }) }, }, + created() { + this.traerCredito() + }, }