Commit 5b3cc6e309788dbdb52c9e8f2224bf9006712fc2

Authored by Marcelo Puebla
1 parent 6be0f6fecb
Exists in master and in 1 other branch validar_pve

Aumentado timer.

Showing 1 changed file with 1 additions and 1 deletions   Show diff stats
src/app/components/pago/pago.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } 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 { RouterLink, Router } from '@angular/router'; 5 import { RouterLink, Router } from '@angular/router';
6 import { Producto } from 'src/app/wrappers/producto'; 6 import { Producto } from 'src/app/wrappers/producto';
7 7
8 @Component({ 8 @Component({
9 selector: 'app-pago', 9 selector: 'app-pago',
10 templateUrl: './pago.component.html', 10 templateUrl: './pago.component.html',
11 styleUrls: ['./pago.component.scss'] 11 styleUrls: ['./pago.component.scss']
12 }) 12 })
13 export class PagoComponent implements OnInit { 13 export class PagoComponent implements OnInit {
14 14
15 private apiUrl: string = appSettings.apiUrl; 15 private apiUrl: string = appSettings.apiUrl;
16 private verQR: boolean = false; 16 private verQR: boolean = false;
17 private productos: Producto[] = []; 17 private productos: Producto[] = [];
18 private total: number = 0; 18 private total: number = 0;
19 19
20 private compraConQRfinalizada: boolean = false; 20 private compraConQRfinalizada: boolean = false;
21 private compraConEfectivofinalizada: boolean = false; 21 private compraConEfectivofinalizada: boolean = false;
22 22
23 constructor( 23 constructor(
24 private productoService: ProductoService, 24 private productoService: ProductoService,
25 private location: Location, 25 private location: Location,
26 private router: Router, 26 private router: Router,
27 ) { } 27 ) { }
28 28
29 ngOnInit() { 29 ngOnInit() {
30 30
31 this.productos = this.productoService.productos; 31 this.productos = this.productoService.productos;
32 } 32 }
33 33
34 pagar() { 34 pagar() {
35 35
36 this.verQR = true; 36 this.verQR = true;
37 alert('Procesando Pago'); 37 alert('Procesando Pago');
38 38
39 this.productoService.pagar() 39 this.productoService.pagar()
40 .subscribe(() => { 40 .subscribe(() => {
41 41
42 // alert('Compra finalizada'); 42 // alert('Compra finalizada');
43 this.compraConQRfinalizada = true; 43 this.compraConQRfinalizada = true;
44 setTimeout(() => { 44 setTimeout(() => {
45 45
46 this.router.navigate(['mensaje-final']); 46 this.router.navigate(['mensaje-final']);
47 }, 1000); 47 }, 3000);
48 }, err => { 48 }, err => {
49 console.log(err); 49 console.log(err);
50 alert('algo salió mal'); 50 alert('algo salió mal');
51 }) 51 })
52 } 52 }
53 53
54 volverPreviousPage() { 54 volverPreviousPage() {
55 55
56 if (this.verQR) { 56 if (this.verQR) {
57 this.verQR = false; 57 this.verQR = false;
58 return; 58 return;
59 } 59 }
60 this.location.back(); 60 this.location.back();
61 } 61 }
62 62
63 getTotal() { 63 getTotal() {
64 64
65 var subTotal = 0; 65 var subTotal = 0;
66 this.productos.forEach(producto => { 66 this.productos.forEach(producto => {
67 67
68 subTotal = subTotal + (producto.PreVen * producto.cantidad); 68 subTotal = subTotal + (producto.PreVen * producto.cantidad);
69 }); 69 });
70 return this.total = subTotal; 70 return this.total = subTotal;
71 } 71 }
72 72
73 } 73 }
74 74