Commit 757dbe53ebd8a422e0a8e553f245ab7bb772d6f2
1 parent
6f920dbea4
Exists in
develop
Fix
Lint errors
Showing
2 changed files
with
3 additions
and
3 deletions
Show diff stats
src/app/modules/pago-electronico/pago-electronico.component.ts
1 | import { Component, OnInit, OnDestroy } from '@angular/core'; | 1 | import { Component, OnInit, OnDestroy } 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 { APP_SETTINGS } from 'src/etc/AppSettings'; | 4 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
5 | import { BsModalService } from 'ngx-bootstrap/modal'; | 5 | import { BsModalService } from 'ngx-bootstrap/modal'; |
6 | import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; | 6 | import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; |
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
9 | selector: 'app-pago-electronico', | 9 | selector: 'app-pago-electronico', |
10 | templateUrl: './pago-electronico.component.html', | 10 | templateUrl: './pago-electronico.component.html', |
11 | styleUrls: ['./pago-electronico.component.scss'] | 11 | styleUrls: ['./pago-electronico.component.scss'] |
12 | }) | 12 | }) |
13 | export class PagoElectronicoComponent implements OnInit, OnDestroy { | 13 | export class PagoElectronicoComponent implements OnInit, OnDestroy { |
14 | urlQr = `${APP_SETTINGS.apiImagenes}/qr/${APP_SETTINGS.deploy}/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`; | 14 | urlQr = `${APP_SETTINGS.apiImagenes}/qr/${APP_SETTINGS.deploy}/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`; |
15 | 15 | ||
16 | constructor( | 16 | constructor( |
17 | private articuloService: ArticuloService, | 17 | private articuloService: ArticuloService, |
18 | private router: Router, | 18 | private router: Router, |
19 | private modalService: BsModalService, | 19 | private modalService: BsModalService, |
20 | ) { } | 20 | ) { } |
21 | 21 | ||
22 | ngOnInit() { | 22 | ngOnInit() { |
23 | if (!this.articuloService.carrito.length) { | 23 | if (!this.articuloService.carrito.length) { |
24 | this.router.navigate(['']); | 24 | this.router.navigate(['']); |
25 | return; | 25 | return; |
26 | } | 26 | } |
27 | const dataPago = { | 27 | const dataPago = { |
28 | pedidoAnombreDe: '' | 28 | pedidoAnombreDe: '' |
29 | }; | 29 | }; |
30 | dataPago.pedidoAnombreDe = ''; | 30 | dataPago.pedidoAnombreDe = ''; |
31 | this.articuloService.pay(dataPago) | 31 | this.articuloService.pay(dataPago) |
32 | .subscribe((res: any) => { | 32 | .subscribe((res: any) => { |
33 | this.articuloService.idComanda = res.data; | 33 | this.articuloService.idComanda = res.data; |
34 | this.router.navigate(['mensaje-final']); | 34 | this.router.navigate(['mensaje-final']); |
35 | }, (err) => { | 35 | }, (err) => { |
36 | this.modalService.show(ErrorFormaPagoComponent, { | 36 | this.modalService.show(ErrorFormaPagoComponent, { |
37 | class: 'modal-lg modal-dialog-centered', | 37 | class: 'modal-lg modal-dialog-centered', |
38 | ignoreBackdropClick: true, | 38 | ignoreBackdropClick: true, |
39 | }); | 39 | }); |
40 | }); | 40 | }); |
41 | this.mediaPantalla(); | 41 | this.mediaPantalla(); |
42 | } | 42 | } |
43 | 43 | ||
44 | ngOnDestroy() { | 44 | ngOnDestroy() { |
45 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { | 45 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { |
46 | this.modalService.hide(i); | 46 | this.modalService.hide(i); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | mediaPantalla() { | 50 | mediaPantalla() { |
51 | if ($('body').hasClass('media-pantalla')) { | 51 | if ($('body').hasClass('media-pantalla')) { |
52 | $('.qr-mt').addClass('media-pantalla'); | 52 | $('.qr-mt').addClass('media-pantalla'); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 |
src/app/shared/header-publicidad/header-publicidad.component.ts
1 | import { Component, OnInit, TemplateRef } from '@angular/core'; | 1 | import { Component, OnInit, TemplateRef } from '@angular/core'; |
2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; | 3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; |
4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; | 4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; |
5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
6 | import { PromocionComponent } from '../promocion/promocion.component'; | 6 | import { PromocionComponent } from '../promocion/promocion.component'; |
7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | 7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; |
8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
9 | import { ConfirmacionComponent } from '../confirmacion/confirmacion.component'; | 9 | import { ConfirmacionComponent } from '../confirmacion/confirmacion.component'; |
10 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | 10 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; |
11 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 11 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
12 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; | 12 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; |
13 | import * as _ from 'lodash'; | 13 | import * as _ from 'lodash'; |
14 | 14 | ||
15 | @Component({ | 15 | @Component({ |
16 | selector: 'app-header-publicidad', | 16 | selector: 'app-header-publicidad', |
17 | templateUrl: './header-publicidad.component.html', | 17 | templateUrl: './header-publicidad.component.html', |
18 | styleUrls: ['./header-publicidad.component.scss'] | 18 | styleUrls: ['./header-publicidad.component.scss'] |
19 | }) | 19 | }) |
20 | export class HeaderPublicidadComponent implements OnInit { | 20 | export class HeaderPublicidadComponent implements OnInit { |
21 | urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`; | 21 | urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`; |
22 | publicidades: IPublicidad[] = []; | 22 | publicidades: IPublicidad[] = []; |
23 | modalRef: BsModalRef; | 23 | modalRef: BsModalRef; |
24 | modalSinonimo: BsModalRef; | 24 | modalSinonimo: BsModalRef; |
25 | 25 | ||
26 | constructor( | 26 | constructor( |
27 | private publicidadService: PublicidadService, | 27 | private publicidadService: PublicidadService, |
28 | private articuloService: ArticuloService, | 28 | private articuloService: ArticuloService, |
29 | private modalService: BsModalService, | 29 | private modalService: BsModalService, |
30 | private sinonimoService: SinonimoService | 30 | private sinonimoService: SinonimoService |
31 | ) { } | 31 | ) { } |
32 | 32 | ||
33 | ngOnInit() { | 33 | ngOnInit() { |
34 | this.getPublicidades(); | 34 | this.getPublicidades(); |
35 | this.mediaPantalla(); | 35 | this.mediaPantalla(); |
36 | } | 36 | } |
37 | 37 | ||
38 | getPublicidades() { | 38 | getPublicidades() { |
39 | this.publicidadService.getAll() | 39 | this.publicidadService.getAll() |
40 | .subscribe((res: IPublicidad[]) => { | 40 | .subscribe((res: IPublicidad[]) => { |
41 | this.publicidades = res; | 41 | this.publicidades = res; |
42 | }, err => console.error(err)); | 42 | }, err => console.error(err)); |
43 | } | 43 | } |
44 | 44 | ||
45 | elegirArticulo(publicidad: IPublicidad) { | 45 | elegirArticulo(publicidad: IPublicidad) { |
46 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); | 46 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); |
47 | } | 47 | } |
48 | 48 | ||
49 | getByID(id: number) { | 49 | getByID(id: number) { |
50 | this.articuloService.getById(id) | 50 | this.articuloService.getById(id) |
51 | .subscribe((res: IArticulo) => { | 51 | .subscribe((res: IArticulo) => { |
52 | if (res.FPP) { | 52 | if (res.FPP) { |
53 | this.openModalPromos(res); | 53 | this.openModalPromos(res); |
54 | return; | 54 | return; |
55 | } else { | 55 | } else { |
56 | this.openModalConfirmacion(res); | 56 | this.openModalConfirmacion(res); |
57 | return; | 57 | return; |
58 | } | 58 | } |
59 | }, err => console.error(err)); | 59 | }, err => console.error(err)); |
60 | } | 60 | } |
61 | 61 | ||
62 | openModalPromos(articulo: IArticulo) { | 62 | openModalPromos(articulo: IArticulo) { |
63 | if (this.modalRef) return; | 63 | if (this.modalRef) return; |
64 | this.modalRef = this.modalService.show(PromocionComponent, | 64 | this.modalRef = this.modalService.show(PromocionComponent, |
65 | { | 65 | { |
66 | initialState: { | 66 | initialState: { |
67 | idArticulo: articulo.id | 67 | idArticulo: articulo.id |
68 | }, | 68 | }, |
69 | class: 'modal-dialog-centered' | 69 | class: 'modal-dialog-centered' |
70 | }); | 70 | }); |
71 | } | 71 | } |
72 | 72 | ||
73 | openModalConfirmacion(articulo: IArticulo) { | 73 | openModalConfirmacion(articulo: IArticulo) { |
74 | if (this.modalRef) return; | 74 | if (this.modalRef) return; |
75 | this.articuloService.setArticulosSinImagen([articulo]); | 75 | this.articuloService.setArticulosSinImagen([articulo]); |
76 | this.modalRef = this.modalService.show(ConfirmacionComponent, | 76 | this.modalRef = this.modalService.show(ConfirmacionComponent, |
77 | { | 77 | { |
78 | initialState: { | 78 | initialState: { |
79 | titleMessage: articulo.DET_LAR, | 79 | titleMessage: articulo.DET_LAR, |
80 | imagenPath: articulo.imagenes.length ? articulo.imagenes[0].imagen : 'assets/img/imagen-no-encontrada.jpg', | 80 | imagenPath: articulo.imagenes.length ? articulo.imagenes[0].imagen : 'assets/img/imagen-no-encontrada.jpg', |
81 | footerMessageFirst: `¿DESEA AGREGAR ESTE COMBO`, | 81 | footerMessageFirst: `¿DESEA AGREGAR ESTE COMBO`, |
82 | footerMessageSecond: `a su carrito?`, | 82 | footerMessageSecond: `a su carrito?`, |
83 | footerConfirmation: articulo.PreVen | 83 | footerConfirmation: articulo.PreVen |
84 | }, | 84 | }, |
85 | ignoreBackdropClick: true, | 85 | ignoreBackdropClick: true, |
86 | class: 'modal-dialog-centered' | 86 | class: 'modal-dialog-centered' |
87 | }); | 87 | }); |
88 | this.modalRef.content.onClose.subscribe((res) => { | 88 | this.modalRef.content.onClose.subscribe((resClose) => { |
89 | this.modalRef = null; | 89 | this.modalRef = null; |
90 | if (!res) return; | 90 | if (!resClose) return; |
91 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) | 91 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) |
92 | .subscribe((res: ISinonimo[]) => { | 92 | .subscribe((res: ISinonimo[]) => { |
93 | if (res.length) { | 93 | if (res.length) { |
94 | const sinonimos = []; | 94 | const sinonimos = []; |
95 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); | 95 | const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); |
96 | Object.keys(gruposArticulos).forEach(key => { | 96 | Object.keys(gruposArticulos).forEach(key => { |
97 | sinonimos.push({ productos: gruposArticulos[key] }); | 97 | sinonimos.push({ productos: gruposArticulos[key] }); |
98 | }); | 98 | }); |
99 | res = sinonimos; | 99 | res = sinonimos; |
100 | this.openModalSinonimos(res, articulo); | 100 | this.openModalSinonimos(res, articulo); |
101 | } else { | 101 | } else { |
102 | articulo.cantidad = 1; | 102 | articulo.cantidad = 1; |
103 | this.articuloService.setArticulo(articulo); | 103 | this.articuloService.setArticulo(articulo); |
104 | } | 104 | } |
105 | }, err => console.error(err)); | 105 | }, err => console.error(err)); |
106 | }); | 106 | }); |
107 | this.mediaPantalla(); | 107 | this.mediaPantalla(); |
108 | } | 108 | } |
109 | 109 | ||
110 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { | 110 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { |
111 | if (this.modalSinonimo) return; | 111 | if (this.modalSinonimo) return; |
112 | this.modalSinonimo = this.modalService.show(SinonimoComponent, { | 112 | this.modalSinonimo = this.modalService.show(SinonimoComponent, { |
113 | initialState: { | 113 | initialState: { |
114 | sinonimos: sinonimosData, | 114 | sinonimos: sinonimosData, |
115 | articulo | 115 | articulo |
116 | }, | 116 | }, |
117 | class: 'modal-dialog-centered' | 117 | class: 'modal-dialog-centered' |
118 | }); | 118 | }); |
119 | this.modalSinonimo.content.onClose | 119 | this.modalSinonimo.content.onClose |
120 | .subscribe((res: any) => { | 120 | .subscribe((res: any) => { |
121 | for (const a of articulo.productos) { | 121 | for (const a of articulo.productos) { |
122 | for (const aRes of res.articulos) { | 122 | for (const aRes of res.articulos) { |
123 | if (a.idSinonimo === aRes.ID_SIN) { | 123 | if (a.idSinonimo === aRes.ID_SIN) { |
124 | a.CODA = aRes.CodArt; | 124 | a.CODA = aRes.CodArt; |
125 | a.CodArt = aRes.CodArt; | 125 | a.CodArt = aRes.CodArt; |
126 | a.SECA = aRes.CodSec; | 126 | a.SECA = aRes.CodSec; |
127 | aRes.CodSec = aRes.CodSec; | 127 | aRes.CodSec = aRes.CodSec; |
128 | a.PreVen = aRes.PreVen; | 128 | a.PreVen = aRes.PreVen; |
129 | a.id = aRes.id; | 129 | a.id = aRes.id; |
130 | a.DET_LAR = aRes.DET_LAR; | 130 | a.DET_LAR = aRes.DET_LAR; |
131 | a.DetArt = aRes.DetArt; | 131 | a.DetArt = aRes.DetArt; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | this.articuloService.setArticulo(articulo); | 135 | this.articuloService.setArticulo(articulo); |
136 | }); | 136 | }); |
137 | } | 137 | } |
138 | 138 | ||
139 | mediaPantalla() { | 139 | mediaPantalla() { |
140 | if ($('body').hasClass('media-pantalla')) { | 140 | if ($('body').hasClass('media-pantalla')) { |
141 | $('#headerPublicidad,#headerPad').addClass('media-pantalla'); | 141 | $('#headerPublicidad,#headerPad').addClass('media-pantalla'); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 |