Commit 8795bad63ad4135c1cced6c4306fd2f346d5eea4

Authored by Marcelo Puebla
1 parent f3edd01b95
Exists in master

Aumentado tiempo.

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 pagar(medioPago: string) { 72 pagar(medioPago: string) {
73 73
74 if (medioPago == 'electronico') { 74 if (medioPago == 'electronico') {
75 75
76 this.verQR = true; 76 this.verQR = true;
77 } 77 }
78 78
79 this.productoService.pagar(medioPago) 79 this.productoService.pagar(medioPago)
80 .subscribe(() => { 80 .subscribe(() => {
81 81
82 clearTimeout(this.timerReposo); 82 clearTimeout(this.timerReposo);
83 83
84 if (medioPago == 'efectivo') { 84 if (medioPago == 'efectivo') {
85 85
86 this.compraConEfectivofinalizada = true; 86 this.compraConEfectivofinalizada = true;
87 } else if (medioPago == 'electronico') { 87 } else if (medioPago == 'electronico') {
88 88
89 this.compraConQRfinalizada = true; 89 this.compraConQRfinalizada = true;
90 } 90 }
91 91
92 setTimeout(() => { 92 setTimeout(() => {
93 93
94 this.router.navigate(['mensaje-final']); 94 this.router.navigate(['mensaje-final']);
95 }, 3000); 95 }, 15000);
96 }, err => { 96 }, err => {
97 console.log(err); 97 console.log(err);
98 alert('algo salió mal'); 98 alert('algo salió mal');
99 }) 99 })
100 } 100 }
101 //#endregion 101 //#endregion
102 102
103 } 103 }
104 104