Commit 3db8ca57b39ce01ba175e5e2d58ab6b7588cc8de
1 parent
cc2d5a0568
Exists in
master
fix qr
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts
1 | import { Component, OnInit, OnDestroy } from '@angular/core'; | 1 | import { Component, OnInit, OnDestroy } from '@angular/core'; |
2 | import { appSettings } from 'src/etc/AppSettings'; | 2 | import { appSettings } from 'src/etc/AppSettings'; |
3 | import { Location } from '@angular/common'; | 3 | import { Location } from '@angular/common'; |
4 | import { ProductoService } from 'src/app/services/producto.service'; | 4 | import { ProductoService } from 'src/app/services/producto.service'; |
5 | import { Producto } from 'src/app/wrappers/producto'; | 5 | import { Producto } from 'src/app/wrappers/producto'; |
6 | import { Router } from '@angular/router'; | 6 | import { Router } from '@angular/router'; |
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
9 | selector: 'app-confirmacion-carrito', | 9 | selector: 'app-confirmacion-carrito', |
10 | templateUrl: './confirmacion-carrito.component.html', | 10 | templateUrl: './confirmacion-carrito.component.html', |
11 | styleUrls: ['./confirmacion-carrito.component.scss'] | 11 | styleUrls: ['./confirmacion-carrito.component.scss'] |
12 | }) | 12 | }) |
13 | export class ConfirmacionCarritoComponent implements OnInit, OnDestroy { | 13 | export class ConfirmacionCarritoComponent implements OnInit, OnDestroy { |
14 | 14 | ||
15 | private productos: Producto[] = []; | 15 | private productos: Producto[] = []; |
16 | private total: number = 0; | 16 | private total: number = 0; |
17 | private apiImagenes: string = appSettings.apiImagenes; | 17 | private apiImagenes: string = appSettings.apiImagenes; |
18 | private timerReposo: any; | 18 | private timerReposo: any; |
19 | private compraConEfectivofinalizada: boolean = false; | 19 | private compraConEfectivofinalizada: boolean = false; |
20 | private compraConQRfinalizada: boolean = false; | 20 | private compraConQRfinalizada: boolean = false; |
21 | private verQR: boolean = false; | 21 | private verQR: boolean = false; |
22 | 22 | ||
23 | constructor( | 23 | constructor( |
24 | private location: Location, | 24 | private location: Location, |
25 | private productoService: ProductoService, | 25 | private productoService: ProductoService, |
26 | private router: Router | 26 | private router: Router |
27 | ) { } | 27 | ) { } |
28 | 28 | ||
29 | ngOnInit() { | 29 | ngOnInit() { |
30 | 30 | ||
31 | this.timerReposo = setTimeout(() => { | 31 | this.timerReposo = setTimeout(() => { |
32 | 32 | ||
33 | this.router.navigate(['cancelar-compra']); | 33 | this.router.navigate(['cancelar-compra']); |
34 | }, 90000) | 34 | }, 90000) |
35 | this.productos = this.productoService.productos; | 35 | this.productos = this.productoService.productos; |
36 | } | 36 | } |
37 | 37 | ||
38 | ngOnDestroy() { | 38 | ngOnDestroy() { |
39 | 39 | ||
40 | clearTimeout(this.timerReposo); | 40 | clearTimeout(this.timerReposo); |
41 | } | 41 | } |
42 | 42 | ||
43 | volverPreviousPage() { | 43 | volverPreviousPage() { |
44 | 44 | ||
45 | if (this.verQR) { | 45 | if (this.verQR) { |
46 | this.verQR = !this.verQR; | 46 | this.verQR = !this.verQR; |
47 | return; | 47 | return; |
48 | } | 48 | } |
49 | this.location.back(); | 49 | this.location.back(); |
50 | } | 50 | } |
51 | 51 | ||
52 | getTotal() { | 52 | getTotal() { |
53 | 53 | ||
54 | var subTotal = 0; | 54 | var subTotal = 0; |
55 | this.productos.forEach(producto => { | 55 | this.productos.forEach(producto => { |
56 | 56 | ||
57 | subTotal = subTotal + (producto.PreVen * producto.cantidad); | 57 | subTotal = subTotal + (producto.PreVen * producto.cantidad); |
58 | }); | 58 | }); |
59 | return this.total = subTotal; | 59 | return this.total = subTotal; |
60 | } | 60 | } |
61 | 61 | ||
62 | reiniciarTimer() { | 62 | reiniciarTimer() { |
63 | 63 | ||
64 | clearTimeout(this.timerReposo); | 64 | clearTimeout(this.timerReposo); |
65 | this.timerReposo = setTimeout(() => { | 65 | this.timerReposo = setTimeout(() => { |
66 | 66 | ||
67 | this.router.navigate(['cancelar-compra']); | 67 | this.router.navigate(['cancelar-compra']); |
68 | }, 90000) | 68 | }, 90000) |
69 | } | 69 | } |
70 | 70 | ||
71 | //#region METODOS PARA LA FORMA DE PAGO | 71 | //#region METODOS PARA LA FORMA DE PAGO |
72 | pagoEfectivo() { | 72 | pagoEfectivo() { |
73 | 73 | ||
74 | this.compraConEfectivofinalizada = true; | 74 | this.compraConEfectivofinalizada = true; |
75 | clearTimeout(this.timerReposo); | 75 | clearTimeout(this.timerReposo); |
76 | setTimeout(() => { | 76 | setTimeout(() => { |
77 | 77 | ||
78 | this.router.navigate(['mensaje-final']); | 78 | this.router.navigate(['mensaje-final']); |
79 | }, 3000); | 79 | }, 3000); |
80 | } | 80 | } |
81 | 81 | ||
82 | pagar(medioPago: string) { | 82 | pagar(medioPago: string) { |
83 | 83 | ||
84 | if (medioPago == 'electronico') { | ||
85 | |||
86 | this.verQR = true; | ||
87 | } | ||
88 | |||
84 | this.productoService.pagar(medioPago) | 89 | this.productoService.pagar(medioPago) |
85 | .subscribe(() => { | 90 | .subscribe(() => { |
86 | 91 | ||
87 | clearTimeout(this.timerReposo); | 92 | clearTimeout(this.timerReposo); |
88 | 93 | ||
89 | if (medioPago == 'efectivo') { | 94 | if (medioPago == 'efectivo') { |
90 | 95 | ||
91 | this.compraConEfectivofinalizada = true; | 96 | this.compraConEfectivofinalizada = true; |
92 | } else if (medioPago == 'electronico') { | 97 | } else if (medioPago == 'electronico') { |
93 | 98 | ||
94 | this.compraConQRfinalizada = true; | 99 | this.compraConQRfinalizada = true; |
95 | this.verQR = true; | ||
96 | } | 100 | } |
97 | 101 | ||
98 | setTimeout(() => { | 102 | setTimeout(() => { |
99 | 103 | ||
100 | this.router.navigate(['mensaje-final']); | 104 | this.router.navigate(['mensaje-final']); |
101 | }, 3000); | 105 | }, 3000); |
102 | }, err => { | 106 | }, err => { |
103 | console.log(err); | 107 | console.log(err); |
104 | alert('algo salió mal'); | 108 | alert('algo salió mal'); |
105 | }) | 109 | }) |
106 | } | 110 | } |
107 | //#endregion | 111 | //#endregion |
108 | 112 | ||
109 | } | 113 | } |