Commit 442aea3a785d47ab83c9cc987fcad19a2ad3bb2b

Authored by Eric Fernandez
1 parent 36ceddeb30
Exists in master

no alert

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