Commit 6be0f6fecb2e603f0883428c7e732e1e770cb0a5

Authored by Marcelo Puebla
1 parent 23ff236737
Exists in master and in 1 other branch validar_pve

Agregados espacios.

Showing 1 changed file with 2 additions and 0 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 this.productos = this.productoService.productos; 31 this.productos = this.productoService.productos;
31 } 32 }
32 33
33 pagar() { 34 pagar() {
34 35
35 this.verQR = true; 36 this.verQR = true;
36 alert('Procesando Pago'); 37 alert('Procesando Pago');
37 38
38 this.productoService.pagar() 39 this.productoService.pagar()
39 .subscribe(() => { 40 .subscribe(() => {
41
40 // alert('Compra finalizada'); 42 // alert('Compra finalizada');
41 this.compraConQRfinalizada = true; 43 this.compraConQRfinalizada = true;
42 setTimeout(() => { 44 setTimeout(() => {
43 45
44 this.router.navigate(['mensaje-final']); 46 this.router.navigate(['mensaje-final']);
45 }, 1000); 47 }, 1000);
46 }, err => { 48 }, err => {
47 console.log(err); 49 console.log(err);
48 alert('algo salió mal'); 50 alert('algo salió mal');
49 }) 51 })
50 } 52 }
51 53
52 volverPreviousPage() { 54 volverPreviousPage() {
53 55
54 if (this.verQR) { 56 if (this.verQR) {
55 this.verQR = false; 57 this.verQR = false;
56 return; 58 return;
57 } 59 }
58 this.location.back(); 60 this.location.back();
59 } 61 }
60 62
61 getTotal() { 63 getTotal() {
62 64
63 var subTotal = 0; 65 var subTotal = 0;
64 this.productos.forEach(producto => { 66 this.productos.forEach(producto => {
65 67
66 subTotal = subTotal + (producto.PreVen * producto.cantidad); 68 subTotal = subTotal + (producto.PreVen * producto.cantidad);
67 }); 69 });
68 return this.total = subTotal; 70 return this.total = subTotal;
69 } 71 }
70 72
71 } 73 }
72 74