Commit 3a86ac77de103172f68c206b821205c90756b43c

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master(mpuebla)

See merge request !55
src/app/components/confirmacion-carrito/confirmacion-carrito.component.html
1   -<div class="row m-0 fade-in bg-primary-gradient disable-user-select">
  1 +<div
  2 + class="row m-0 fade-in bg-primary-gradient disable-user-select"
  3 + (click)="reiniciarTimer">
2 4 <div class="col-12 p-0 vh-100">
3 5  
4 6 <!-- TOP HEADER -->
... ... @@ -19,7 +21,7 @@
19 21  
20 22 <!-- TEXTO DE IZQUIERDA -->
21 23 <div class="row mx-2 mt-4 text-white">
22   - <div class="col-sm-2 my-auto">
  24 + <div class="col-sm-auto my-auto">
23 25 <p class="h2">Mi Compra
24 26 <i class="fa fa-shopping-cart "></i>
25 27 </p>
... ... @@ -36,14 +38,15 @@
36 38 <div class="row ml-4 pr-3 vh-70 overflow-scroll text-dark">
37 39 <div class="col-4 p-2" *ngFor="let producto of productos">
38 40 <div class="bg-white rounded-sm shadow border-0">
39   - <img src="{{apiUrl}}/imagenes/{{producto.imagenes[0].imagen}}" class="rounded-sm w-100 m-auto">
  41 + <img
  42 + src="{{apiUrl}}/imagenes/{{producto.imagenes[0].imagen}}"
  43 + class="shadow rounded-sm w-100 m-auto">
40 44 <div class="p-2">
41 45 <p class="h6 text-left m-0">{{producto.DetArt}}</p>
42 46 <div class="row justify-content-between m-0">
43 47 <div class="col-12 p-0">
44 48 <div class="text-left">
45 49 <p class="m-0 h6"><small>{{producto.DET_LAR}}</small></p>
46   - <p class="m-0 h6"><small>{{producto.CodSec}}-{{producto.CodArt}}</small></p>
47 50 </div>
48 51 </div>
49 52 <div class="col-12 my-auto pt-2 pr-2 p-0">
src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts
1   -import { Component, OnInit } from '@angular/core';
  1 +import { Component, OnInit, OnDestroy } from '@angular/core';
2 2 import { appSettings } from 'src/etc/AppSettings';
3 3 import { Location } from '@angular/common';
4 4 import { ProductoService } from 'src/app/services/producto.service';
5 5 import { Producto } from 'src/app/wrappers/producto';
  6 +import { Router } from '@angular/router';
6 7  
7 8 @Component({
8 9 selector: 'app-confirmacion-carrito',
9 10 templateUrl: './confirmacion-carrito.component.html',
10 11 styleUrls: ['./confirmacion-carrito.component.scss']
11 12 })
12   -export class ConfirmacionCarritoComponent implements OnInit {
  13 +export class ConfirmacionCarritoComponent implements OnInit, OnDestroy {
13 14  
14   - productos: Producto[] = [];
15   - total: number = 0;
  15 + private productos: Producto[] = [];
  16 + private total: number = 0;
16 17 private apiUrl: string = appSettings.apiUrl;
  18 + private timerReposo: any;
17 19  
18 20 constructor(
19 21 private location: Location,
20   - private productoService: ProductoService
  22 + private productoService: ProductoService,
  23 + private router: Router
21 24 ) { }
22 25  
23 26 ngOnInit() {
24 27  
  28 + this.timerReposo = setTimeout(() => {
  29 +
  30 + this.router.navigate(['cancelar-compra']);
  31 + }, 90000)
25 32 this.productos = this.productoService.productos;
26 33 }
27 34  
  35 + ngOnDestroy() {
  36 +
  37 + clearTimeout(this.timerReposo);
  38 + }
  39 +
28 40 volverPreviousPage() {
29 41  
30 42 this.location.back();
... ... @@ -40,4 +52,13 @@ export class ConfirmacionCarritoComponent implements OnInit {
40 52 return this.total = subTotal;
41 53 }
42 54  
  55 + reiniciarTimer() {
  56 +
  57 + clearTimeout(this.timerReposo);
  58 + this.timerReposo = setTimeout(() => {
  59 +
  60 + this.router.navigate(['cancelar-compra']);
  61 + }, 90000)
  62 + }
  63 +
43 64 }
src/app/components/inicio/inicio.component.ts
... ... @@ -13,6 +13,18 @@ import { Sinonimo } from &#39;src/app/wrappers/sinonimo&#39;;
13 13 })
14 14 export class InicioComponent implements OnInit {
15 15  
  16 + private tienePromo = false;
  17 + private productoEsPromo = false;
  18 + private busqueda: string = '';
  19 + private productoAcargar: Producto;
  20 + private promoAcargar: Producto;
  21 + private productos: Producto[] = [];
  22 + private promociones: Producto[] = [];
  23 + private sinonimos: Sinonimo[] = [];
  24 + private apiUrl: string = appSettings.apiUrl
  25 +
  26 + @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective;
  27 +
16 28 @HostListener('document:keypress', ["$event"]) catchInput(e: KeyboardEvent) {
17 29  
18 30 if (e.keyCode == 13) {
... ... @@ -24,19 +36,6 @@ export class InicioComponent implements OnInit {
24 36  
25 37 };
26 38  
27   - @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective;
28   - private tienePromo = false;
29   - private productoEsPromo = false;
30   - private busqueda: string = '';
31   -
32   - private productoAcargar: Producto;
33   - private promoAcargar: Producto;
34   -
35   - productos: Producto[] = [];
36   - promociones: Producto[] = [];
37   - sinonimos: Sinonimo[] = [];
38   - apiUrl: string = appSettings.apiUrl
39   -
40 39 constructor(
41 40 private router: Router,
42 41 private productoService: ProductoService) { }
... ... @@ -78,7 +77,7 @@ export class InicioComponent implements OnInit {
78 77 }
79 78  
80 79 getProductos() {
81   -
  80 +
82 81 this.productoService.getAll()
83 82 .subscribe((productos: Producto[]) => {
84 83 this.productos = productos;
... ... @@ -128,7 +127,7 @@ export class InicioComponent implements OnInit {
128 127 if ($event.tieneSinonimos) {
129 128  
130 129 this.productoService.getProductoById($event.id)
131   - .subscribe((res : Producto) => {
  130 + .subscribe((res: Producto) => {
132 131  
133 132 $event.imagenes = res.imagenes;
134 133 this.promoAcargar = $event;
src/app/components/master/master.component.ts
... ... @@ -8,7 +8,7 @@ import { Router } from &#39;@angular/router&#39;;
8 8 })
9 9 export class MasterComponent implements OnInit, OnDestroy {
10 10  
11   - private timerReposo: any
  11 + private timerReposo: any;
12 12  
13 13 constructor(
14 14 private router: Router
... ... @@ -34,7 +34,6 @@ export class MasterComponent implements OnInit, OnDestroy {
34 34  
35 35 this.router.navigate(['cancelar-compra']);
36 36 }, 90000)
37   -
38 37 }
39 38  
40 39 }
src/app/components/pago/pago.component.html
1 1 <div
2 2 *ngIf="!compraConEfectivofinalizada && !compraConQRfinalizada"
3   - class="row m-0 fade-in bg-primary-gradient disable-user-select">
  3 + class="row m-0 fade-in bg-primary-gradient disable-user-select"
  4 + (click)="reiniciarTimer()">
4 5  
5 6 <div class="col-12 p-0 vh-100">
6 7  
src/app/components/pago/pago.component.ts
1   -import { Component, OnInit } from '@angular/core';
  1 +import { Component, OnInit, OnDestroy } from '@angular/core';
2 2 import { appSettings } from 'src/etc/AppSettings';
3 3 import { Location } from '@angular/common';
4 4 import { ProductoService } from 'src/app/services/producto.service';
5   -import { RouterLink, Router } from '@angular/router';
  5 +import { Router } from '@angular/router';
6 6 import { Producto } from 'src/app/wrappers/producto';
7 7  
8 8 @Component({
... ... @@ -10,7 +10,7 @@ import { Producto } from &#39;src/app/wrappers/producto&#39;;
10 10 templateUrl: './pago.component.html',
11 11 styleUrls: ['./pago.component.scss']
12 12 })
13   -export class PagoComponent implements OnInit {
  13 +export class PagoComponent implements OnInit, OnDestroy {
14 14  
15 15 private apiUrl: string = appSettings.apiUrl;
16 16 private verQR: boolean = false;
... ... @@ -19,6 +19,7 @@ export class PagoComponent implements OnInit {
19 19  
20 20 private compraConQRfinalizada: boolean = false;
21 21 private compraConEfectivofinalizada: boolean = false;
  22 + private timerReposo: any;
22 23  
23 24 constructor(
24 25 private productoService: ProductoService,
... ... @@ -28,12 +29,22 @@ export class PagoComponent implements OnInit {
28 29  
29 30 ngOnInit() {
30 31  
  32 + this.timerReposo = setTimeout(() => {
  33 +
  34 + this.router.navigate(['cancelar-compra']);
  35 + }, 90000)
31 36 this.productos = this.productoService.productos;
32 37 }
33 38  
  39 + ngOnDestroy() {
  40 +
  41 + clearTimeout(this.timerReposo);
  42 + }
  43 +
34 44 pagoEfectivo() {
35 45  
36 46 this.compraConEfectivofinalizada = true;
  47 + clearTimeout(this.timerReposo);
37 48 setTimeout(() => {
38 49  
39 50 this.router.navigate(['mensaje-final']);
... ... @@ -47,7 +58,7 @@ export class PagoComponent implements OnInit {
47 58 this.productoService.pagar()
48 59 .subscribe(() => {
49 60  
50   - // alert('Compra finalizada');
  61 + clearTimeout(this.timerReposo);
51 62 this.compraConQRfinalizada = true;
52 63 setTimeout(() => {
53 64  
... ... @@ -78,4 +89,13 @@ export class PagoComponent implements OnInit {
78 89 return this.total = subTotal;
79 90 }
80 91  
  92 + reiniciarTimer() {
  93 +
  94 + clearTimeout(this.timerReposo);
  95 + this.timerReposo = setTimeout(() => {
  96 +
  97 + this.router.navigate(['cancelar-compra']);
  98 + }, 90000)
  99 + }
  100 +
81 101 }