Commit 900dccb8b94b08ab3e1c7720a41da31d4e3236dc

Authored by Marcelo Puebla
1 parent ef82f8bd36
Exists in master

comenta alerta.

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