Commit 1bdd0808e78f2b0f12a9c5e81688fce6b2fa9346
1 parent
554a319682
Exists in
develop
Change
Orden variables
Showing
1 changed file
with
1 additions
and
5 deletions
Show diff stats
src/app/modules/pago-tarjeta/pago-tarjeta.component.ts
| 1 | import { Component, OnInit, TemplateRef, OnDestroy, ViewChild } from '@angular/core'; | 1 | import { Component, OnInit, TemplateRef, OnDestroy, ViewChild } from '@angular/core'; |
| 2 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 2 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 3 | import { Router } from '@angular/router'; | 3 | import { Router } from '@angular/router'; |
| 4 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | 4 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; |
| 5 | import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; | 5 | import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; |
| 6 | import { Subscription } from 'rxjs'; | 6 | import { Subscription } from 'rxjs'; |
| 7 | 7 | ||
| 8 | @Component({ | 8 | @Component({ |
| 9 | selector: 'app-pago-tarjeta', | 9 | selector: 'app-pago-tarjeta', |
| 10 | templateUrl: './pago-tarjeta.component.html', | 10 | templateUrl: './pago-tarjeta.component.html', |
| 11 | styleUrls: ['./pago-tarjeta.component.scss'] | 11 | styleUrls: ['./pago-tarjeta.component.scss'] |
| 12 | }) | 12 | }) |
| 13 | export class PagoTarjetaComponent implements OnInit, OnDestroy { | 13 | export class PagoTarjetaComponent implements OnInit, OnDestroy { |
| 14 | timer: any; | 14 | timer: any; |
| 15 | <<<<<<< HEAD | ||
| 16 | subscription: Subscription; | 15 | subscription: Subscription; |
| 17 | @ViewChild('template', { static: true }) public template: TemplateRef<any>; | ||
| 18 | ======= | ||
| 19 | @ViewChild('template', {static: true}) public template: TemplateRef<any>; | ||
| 20 | modalRef: BsModalRef; | 16 | modalRef: BsModalRef; |
| 21 | >>>>>>> 94610cc5cc92408a3384da70848a2722dc5b6bc5 | 17 | @ViewChild('template', { static: true }) public template: TemplateRef<any>; |
| 22 | 18 | ||
| 23 | constructor( | 19 | constructor( |
| 24 | private articuloService: ArticuloService, | 20 | private articuloService: ArticuloService, |
| 25 | private router: Router, | 21 | private router: Router, |
| 26 | private modalService: BsModalService, | 22 | private modalService: BsModalService, |
| 27 | ) { } | 23 | ) { } |
| 28 | 24 | ||
| 29 | ngOnInit() { | 25 | ngOnInit() { |
| 30 | if (!this.articuloService.carrito.length) { | 26 | if (!this.articuloService.carrito.length) { |
| 31 | this.router.navigate(['']); | 27 | this.router.navigate(['']); |
| 32 | return; | 28 | return; |
| 33 | } | 29 | } |
| 34 | this.openModalEspera(this.template); | 30 | this.openModalEspera(this.template); |
| 35 | const dataPago = { | 31 | const dataPago = { |
| 36 | pedidoAnombreDe: '' | 32 | pedidoAnombreDe: '' |
| 37 | }; | 33 | }; |
| 38 | this.subscription = this.articuloService.pay(dataPago) | 34 | this.subscription = this.articuloService.pay(dataPago) |
| 39 | .subscribe((res: any) => { | 35 | .subscribe((res: any) => { |
| 40 | this.modalRef.hide(); | 36 | this.modalRef.hide(); |
| 41 | this.articuloService.idComanda = res.data; | 37 | this.articuloService.idComanda = res.data; |
| 42 | this.router.navigate(['mensaje-final']); | 38 | this.router.navigate(['mensaje-final']); |
| 43 | }, (err) => { | 39 | }, (err) => { |
| 44 | this.modalRef.hide(); | 40 | this.modalRef.hide(); |
| 45 | this.modalService.show(ErrorFormaPagoComponent, { | 41 | this.modalService.show(ErrorFormaPagoComponent, { |
| 46 | class: 'modal-lg modal-dialog-centered', | 42 | class: 'modal-lg modal-dialog-centered', |
| 47 | ignoreBackdropClick: true, | 43 | ignoreBackdropClick: true, |
| 48 | }); | 44 | }); |
| 49 | }); | 45 | }); |
| 50 | this.mediaPantalla(); | 46 | this.mediaPantalla(); |
| 51 | } | 47 | } |
| 52 | 48 | ||
| 53 | ngOnDestroy() { | 49 | ngOnDestroy() { |
| 54 | if (this.subscription) this.subscription.unsubscribe(); | 50 | if (this.subscription) this.subscription.unsubscribe(); |
| 55 | if (this.timer) clearTimeout(this.timer); | 51 | if (this.timer) clearTimeout(this.timer); |
| 56 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { | 52 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { |
| 57 | this.modalService.hide(i); | 53 | this.modalService.hide(i); |
| 58 | } | 54 | } |
| 59 | } | 55 | } |
| 60 | 56 | ||
| 61 | mediaPantalla() { | 57 | mediaPantalla() { |
| 62 | if ($('body').hasClass('media-pantalla')) { | 58 | if ($('body').hasClass('media-pantalla')) { |
| 63 | $('.pago-tarjeta').addClass('media-pantalla'); | 59 | $('.pago-tarjeta').addClass('media-pantalla'); |
| 64 | } | 60 | } |
| 65 | } | 61 | } |
| 66 | 62 | ||
| 67 | openModalEspera(templateRef: TemplateRef<any>) { | 63 | openModalEspera(templateRef: TemplateRef<any>) { |
| 68 | this.modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); | 64 | this.modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); |
| 69 | } | 65 | } |
| 70 | } | 66 | } |
| 71 | 67 |