Commit 3d1313517b736fadb7a85d05cf4f54d69579540a

Authored by Marcelo Puebla
1 parent 2077d36199
Exists in develop

Agregado pago con tarjeta

src/app/app-routing.module.ts
1 import { NgModule } from '@angular/core'; 1 import { NgModule } from '@angular/core';
2 import { Routes, RouterModule } from '@angular/router'; 2 import { Routes, RouterModule } from '@angular/router';
3 import { SplashScreenComponent } from './modules/splash-screen/splash-screen.component'; 3 import { SplashScreenComponent } from './modules/splash-screen/splash-screen.component';
4 import { AdminComponent } from './modules/admin/admin.component'; 4 import { AdminComponent } from './modules/admin/admin.component';
5 5
6 const routes: Routes = [ 6 const routes: Routes = [
7 { path: '', component: SplashScreenComponent }, 7 { path: '', component: SplashScreenComponent },
8 { 8 {
9 path: '', 9 path: '',
10 component: AdminComponent, 10 component: AdminComponent,
11 children: [ 11 children: [
12 { 12 {
13 path: 'info-formas-pago', 13 path: 'info-formas-pago',
14 loadChildren: () => import('./modules/info-formas-pago/info-formas-pago.module').then(m => m.InfoFormasPagoModule) 14 loadChildren: () => import('./modules/info-formas-pago/info-formas-pago.module').then(m => m.InfoFormasPagoModule)
15 }, 15 },
16 { 16 {
17 path: 'opcion-pedido', 17 path: 'opcion-pedido',
18 loadChildren: () => import('./modules/opcion-pedido/opcion-pedido.module').then(m => m.OpcionPedidoModule) 18 loadChildren: () => import('./modules/opcion-pedido/opcion-pedido.module').then(m => m.OpcionPedidoModule)
19 }, 19 },
20 { 20 {
21 path: 'seleccion-articulos', 21 path: 'seleccion-articulos',
22 loadChildren: () => import('./modules/seleccion-articulos/seleccion-articulos.module').then(m => m.SeleccionArticulosModule) 22 loadChildren: () => import('./modules/seleccion-articulos/seleccion-articulos.module').then(m => m.SeleccionArticulosModule)
23 }, 23 },
24 { 24 {
25 path: 'carrito', 25 path: 'carrito',
26 loadChildren: () => import('./modules/carrito/carrito.module').then(m => m.CarritoModule) 26 loadChildren: () => import('./modules/carrito/carrito.module').then(m => m.CarritoModule)
27 }, 27 },
28 { 28 {
29 path: 'forma-pago', 29 path: 'forma-pago',
30 loadChildren: () => import('./modules/forma-pago/forma-pago.module').then(m => m.FormaPagoModule) 30 loadChildren: () => import('./modules/forma-pago/forma-pago.module').then(m => m.FormaPagoModule)
31 }, 31 },
32 { 32 {
33 path: 'pago-electronico', 33 path: 'pago-electronico',
34 loadChildren: () => import('./modules/pago-electronico/pago-electronico.module').then(m => m.PagoElectronicoModule) 34 loadChildren: () => import('./modules/pago-electronico/pago-electronico.module').then(m => m.PagoElectronicoModule)
35 }, 35 },
36 { 36 {
37 path: 'pago-tarjeta', 37 path: 'pago-tarjeta',
38 loadChildren: () => import('./modules/pago-tarjeta/pago-tarjeta.module').then(m => m.PagoTarjetaModule) 38 loadChildren: () => import('./modules/pago-tarjeta/pago-tarjeta.module').then(m => m.PagoTarjetaModule)
39 }, 39 },
40 {
41 path: 'mensaje-final',
42 loadChildren: () => import('./modules/mensaje-final/mensaje-final.module').then(m => m.MensajeFinalModule)
43 },
44 ] 40 ]
45 }, 41 },
42 {
43 path: 'mensaje-final',
44 loadChildren: () => import('./modules/mensaje-final/mensaje-final.module').then(m => m.MensajeFinalModule)
45 },
46 { path: '**', redirectTo: '', pathMatch: 'full' }, 46 { path: '**', redirectTo: '', pathMatch: 'full' },
47 ]; 47 ];
48 48
49 @NgModule({ 49 @NgModule({
50 imports: [RouterModule.forRoot(routes, { useHash: true })], 50 imports: [RouterModule.forRoot(routes, { useHash: true })],
src/app/modules/forma-pago/forma-pago.component.html
1 <div class="h-92 bg-white fade-in-left"> 1 <div class="h-92 bg-white fade-in-left">
2 <div class="row mx-0 h-15"> 2 <div class="row mx-0 h-15">
3 <div class="col-12 px-0 h-80 my-auto"> 3 <div class="col-12 px-0 h-80 my-auto">
4 <img 4 <img
5 draggable="false" 5 draggable="false"
6 ondragstart="return false;" 6 ondragstart="return false;"
7 (contextmenu)="false" 7 (contextmenu)="false"
8 class="d-block mx-auto h-100" 8 class="d-block mx-auto h-100"
9 src="assets/img/logo-spot.svg"> 9 src="assets/img/logo-spot.svg">
10 </div> 10 </div>
11 </div> 11 </div>
12 <div class="h-85"> 12 <div class="h-85">
13 <div class="row mt-5 mx-3 h-auto border border-primary rounded-sm"> 13 <div class="row mt-5 mx-3 h-auto border border-primary rounded-sm">
14 <div class="col-12 px-0 py-2 align-self-center"> 14 <div class="col-12 px-0 py-2 align-self-center">
15 <div class="px-3 text-center"> 15 <div class="px-3 text-center">
16 <p class="h6 text-truncate">SELECCIONA UNA FORMA DE PAGO</p> 16 <p class="h6 text-truncate">SELECCIONA UNA FORMA DE PAGO</p>
17 </div> 17 </div>
18 </div> 18 </div>
19 </div> 19 </div>
20 <!-- OPCION PAGO ELECTRONICO --> 20 <!-- OPCION PAGO ELECTRONICO -->
21 <div class="row mt-5 h-auto justify-content-center mx-0"> 21 <div class="row mt-5 h-auto justify-content-center mx-0">
22 <div class="col-auto px-0 h-auto align-self-start"> 22 <div class="col-auto px-0 h-auto align-self-start">
23 <div 23 <div
24 class="btn-effect col-auto align-self-center px-0 bg-white" 24 class="btn-effect col-auto align-self-center px-0 bg-white"
25 [routerLink]="['/pago-electronico']"> 25 [routerLink]="['/pago-electronico']">
26 <div class="row mx-0 bg-primary badge-pill"> 26 <div class="row mx-0 bg-primary badge-pill">
27 <div class="col-auto p-0"> 27 <div class="col-auto p-0">
28 <img 28 <img
29 draggable="false" 29 draggable="false"
30 ondragstart="return false;" 30 ondragstart="return false;"
31 (contextmenu)="false" 31 (contextmenu)="false"
32 class="p-1 icon-50" 32 class="p-1 icon-50"
33 src="assets/img/icono-plato.svg"> 33 src="assets/img/icono-plato.svg">
34 </div> 34 </div>
35 <div class="col-auto align-self-center text-white">Pago electrónico</div> 35 <div class="col-auto align-self-center text-white">Pago electrónico</div>
36 <div class="col-auto align-self-center p-0"> 36 <div class="col-auto align-self-center p-0">
37 <img 37 <img
38 draggable="false" 38 draggable="false"
39 ondragstart="return false;" 39 ondragstart="return false;"
40 (contextmenu)="false" 40 (contextmenu)="false"
41 class="p-1 icon-30" 41 class="p-1 icon-30"
42 src="assets/img/ir.svg"> 42 src="assets/img/ir.svg">
43 </div> 43 </div>
44 </div> 44 </div>
45 </div> 45 </div>
46 </div> 46 </div>
47 </div> 47 </div>
48 <!-- OPCION PAGO CON TARJETA --> 48 <!-- OPCION PAGO CON TARJETA -->
49 <div class="row mt-5 h-auto justify-content-center mx-0"> 49 <div class="row mt-5 h-auto justify-content-center mx-0">
50 <div class="col-auto px-0 h-auto align-self-start"> 50 <div class="col-auto px-0 h-auto align-self-start">
51 <div 51 <div
52 class="btn-effect col-auto align-self-center px-0 bg-white" 52 class="btn-effect col-auto align-self-center px-0 bg-white"
53 [routerLink]="['/pago-tarjeta']"> 53 (click)="medioPago(4)">
54 <div class="row mx-0 bg-primary badge-pill"> 54 <div class="row mx-0 bg-primary badge-pill">
55 <div class="col-auto p-0"> 55 <div class="col-auto p-0">
56 <img 56 <img
57 draggable="false" 57 draggable="false"
58 ondragstart="return false;" 58 ondragstart="return false;"
59 (contextmenu)="false" 59 (contextmenu)="false"
60 class="p-1 icon-50" 60 class="p-1 icon-50"
61 src="assets/img/icono-take-away.svg"> 61 src="assets/img/icono-take-away.svg">
62 </div> 62 </div>
63 <div class="col-auto align-self-center text-white">Pago con tarjeta</div> 63 <div class="col-auto align-self-center text-white">Pago con tarjeta</div>
64 <div class="col-auto align-self-center p-0"> 64 <div class="col-auto align-self-center p-0">
65 <img 65 <img
66 draggable="false" 66 draggable="false"
67 ondragstart="return false;" 67 ondragstart="return false;"
68 (contextmenu)="false" 68 (contextmenu)="false"
69 class="p-1 icon-30" 69 class="p-1 icon-30"
70 src="assets/img/ir.svg"> 70 src="assets/img/ir.svg">
71 </div> 71 </div>
72 </div> 72 </div>
73 </div> 73 </div>
74 </div> 74 </div>
75 </div> 75 </div>
76 </div> 76 </div>
77 </div> 77 </div>
78 78
src/app/modules/forma-pago/forma-pago.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
3 import { Router } from '@angular/router';
2 4
3 @Component({ 5 @Component({
4 selector: 'app-forma-pago', 6 selector: 'app-forma-pago',
5 templateUrl: './forma-pago.component.html', 7 templateUrl: './forma-pago.component.html',
6 styleUrls: ['./forma-pago.component.scss'] 8 styleUrls: ['./forma-pago.component.scss']
7 }) 9 })
8 export class FormaPagoComponent implements OnInit { 10 export class FormaPagoComponent implements OnInit {
9 11
10 constructor() { } 12 constructor(
13 private articuloService: ArticuloService,
14 private router: Router,
15 ) { }
11 16
12 ngOnInit() { 17 ngOnInit() {
13 } 18 }
14 19
20 medioPago(medioPago: number) {
21 this.articuloService.medioPago = medioPago;
22 switch (medioPago) {
23 case 4:
24 this.router.navigate(['pago-tarjeta']);
25 break;
26 case 9:
27 this.router.navigate(['pago-electronico']);
28 break;
29 }
30 }
31
15 } 32 }
16 33
src/app/modules/mensaje-final/mensaje-final.component.html
1 <div class="h-92 bg-white fade-in-left"> 1 <div class="h-92 bg-white fade-in-left">
2 <div class="row mx-0 h-15"> 2 <div class="row mx-0 h-15">
3 <div class="col-12 px-0 h-80 my-auto"> 3 <div class="col-12 px-0 h-80 my-auto">
4 <img 4 <img
5 draggable="false" 5 draggable="false"
6 ondragstart="return false;" 6 ondragstart="return false;"
7 (contextmenu)="false" 7 (contextmenu)="false"
8 class="d-block mx-auto h-100" 8 class="d-block mx-auto h-100"
9 src="assets/img/logo-spot.svg"> 9 src="assets/img/logo-spot.svg">
10 </div> 10 </div>
11 </div> 11 </div>
12 <div class="h-85"> 12 <div class="h-85">
13 <div class="row mt-5 mx-3 h-auto"> 13 <div class="row mt-5 mx-3 h-auto">
14 <div class="col-12 px-0 py-2 align-self-center text-center"> 14 <div class="col-12 px-0 py-2 align-self-center text-center">
15 <p class="h6 text-truncate">SEGUÍ ESTOS PASOS PARA</p> 15 <p class="h6 text-truncate">SEGUÍ ESTOS PASOS PARA</p>
16 <p class="h2 text-truncate text-secondary">retirar tu comida</p> 16 <p class="h2 text-truncate text-secondary">retirar tu comida</p>
17 </div> 17 </div>
18 </div> 18 </div>
19 <div class="row h-auto mt-5 mx-0 justify-content-center text-center"> 19 <div class="row h-auto mt-5 mx-0 justify-content-center text-center">
20 <div class="col-8 p-5 h-auto align-self-end border border-primary rounded"> 20 <div class="col-8 p-5 h-auto align-self-end border border-primary rounded">
21 <img 21 <img
22 draggable="false" 22 draggable="false"
23 ondragstart="return false;" 23 ondragstart="return false;"
24 (contextmenu)="false" 24 (contextmenu)="false"
25 class="img-in-top px-4 bg-white" 25 class="img-in-top px-4 bg-white"
26 src="assets/img/ticket.svg"> 26 src="assets/img/ticket.svg">
27 <p class="h6 mb-2"><small>PRESENTÁ EL TICKET EN CAJA Y AGUARDÁ TU PEDIDO</small></p> 27 <p class="h6 mb-2"><small>PRESENTÁ EL TICKET EN CAJA Y AGUARDÁ TU PEDIDO</small></p>
28 <p class="h2 text-primary">Número de pedido {{023}}</p> 28 <p class="h2 text-primary">Número de pedido {{articuloService.idComanda}}</p>
29 </div> 29 </div>
30 </div> 30 </div>
31 <div class="row h-auto mt-6 mx-0 justify-content-center text-center"> 31 <div class="row h-auto mt-6 mx-0 justify-content-center text-center">
32 <div class="col-8 p-5 h-auto align-self-end border border-primary rounded"> 32 <div class="col-8 p-5 h-auto align-self-end border border-primary rounded">
33 <img 33 <img
34 draggable="false" 34 draggable="false"
35 ondragstart="return false;" 35 ondragstart="return false;"
36 (contextmenu)="false" 36 (contextmenu)="false"
37 class="img-in-top px-4 bg-white" 37 class="img-in-top px-4 bg-white"
38 src="assets/img/bebidas.svg"> 38 src="assets/img/bebidas.svg">
39 <p class="h6"> 39 <p class="h6">
40 <small>TUS BEBIDAS Y COMIDAS FRÍAS RETIRALAS EN LAS HELADERAS Y DISPENSERS</small> 40 <small>TUS BEBIDAS Y COMIDAS FRÍAS RETIRALAS EN LAS HELADERAS Y DISPENSERS</small>
41 </p> 41 </p>
42 </div> 42 </div>
43 </div> 43 </div>
44 <div class="row h-auto mt-5 mx-0 justify-content-center text-center"> 44 <div class="row h-auto mt-5 mx-0 justify-content-center text-center">
45 <div class="col-8 p-5 h-auto align-self-end"> 45 <div class="col-8 p-5 h-auto align-self-end">
46 <p class="h2 text-info"> 46 <p class="h2 text-info">
47 ¡Listo!<br> 47 ¡Listo!<br>
48 Que lo disfrutes 48 Que lo disfrutes
49 </p> 49 </p>
50 </div> 50 </div>
51 </div> 51 </div>
52 <div class="row justify-content-center">
53 <div class="col-auto">
54 <div
55 class="d-inline-block py-1 btn-effect bg-primary badge-pill text-white"
56 (click)="goToSplash()">
57 <span class="px-4">FINALIZAR</span>
58 <img
59 draggable="false"
60 ondragstart="return false;"
61 (contextmenu)="false"
62 class="icon-30"
63 src="assets/img/ir.svg">
64 </div>
65 </div>
66 </div>
52 </div> 67 </div>
53 </div> 68 </div>
54 69
src/app/modules/mensaje-final/mensaje-final.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
3 import { Router } from '@angular/router';
2 4
3 @Component({ 5 @Component({
4 selector: 'app-mensaje-final', 6 selector: 'app-mensaje-final',
5 templateUrl: './mensaje-final.component.html', 7 templateUrl: './mensaje-final.component.html',
6 styleUrls: ['./mensaje-final.component.scss'] 8 styleUrls: ['./mensaje-final.component.scss']
7 }) 9 })
8 export class MensajeFinalComponent implements OnInit { 10 export class MensajeFinalComponent implements OnInit {
9 11
10 constructor() { } 12 constructor(
13 public articuloService: ArticuloService,
14 private router: Router,
15 ) { }
11 16
12 ngOnInit() { 17 ngOnInit() {
18 setTimeout(() => {
19 this.goToSplash();
20 }, 10000)
21 }
22
23 goToSplash() {
24 this.articuloService.cleanShoppingCar();
25 this.router.navigate(['']);
13 } 26 }
14 27
15 } 28 }
16 29
src/app/modules/pago-tarjeta/pago-tarjeta.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
3 import { Router } from '@angular/router';
2 4
3 @Component({ 5 @Component({
4 selector: 'app-pago-tarjeta', 6 selector: 'app-pago-tarjeta',
5 templateUrl: './pago-tarjeta.component.html', 7 templateUrl: './pago-tarjeta.component.html',
6 styleUrls: ['./pago-tarjeta.component.scss'] 8 styleUrls: ['./pago-tarjeta.component.scss']
7 }) 9 })
8 export class PagoTarjetaComponent implements OnInit { 10 export class PagoTarjetaComponent implements OnInit {
9 11
10 constructor() { } 12 constructor(
13 private articuloService: ArticuloService,
14 private router: Router,
15 ) { }
11 16
12 ngOnInit() { 17 ngOnInit() {
18 let dataPago = {
19 pedidoAnombreDe: ''
20 }
21 this.articuloService.pay(dataPago)
22 .subscribe((res: any) => {
23 this.articuloService.idComanda = res.data;
24 this.router.navigate(['mensaje-final']);
25 }, err => console.error(err));
13 } 26 }
14 27
15 } 28 }
16 29
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
1 import { Component, OnInit } from "@angular/core"; 1 import { Component, OnInit } from "@angular/core";
2 import { BsModalRef } from 'ngx-bootstrap/modal'; 2 import { BsModalRef } from 'ngx-bootstrap/modal';
3 import { ArticuloService } from 'src/app/services/articulo/articulo.service'; 3 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
4 import { IArticulo } from 'src/app/interfaces/IArticulo'; 4 import { IArticulo } from 'src/app/interfaces/IArticulo';
5 import { APP_SETTINGS } from 'src/etc/AppSettings'; 5 import { APP_SETTINGS } from 'src/etc/AppSettings';
6 import { ICategoria } from 'src/app/interfaces/ICategoria'; 6 import { ICategoria } from 'src/app/interfaces/ICategoria';
7 import { CategoriaService } from 'src/app/services/categoria/categoria.service'; 7 import { CategoriaService } from 'src/app/services/categoria/categoria.service';
8 8
9 @Component({ 9 @Component({
10 selector: "app-seleccion-articulos", 10 selector: "app-seleccion-articulos",
11 templateUrl: "./seleccion-articulos.component.html", 11 templateUrl: "./seleccion-articulos.component.html",
12 styleUrls: ["./seleccion-articulos.component.scss"] 12 styleUrls: ["./seleccion-articulos.component.scss"]
13 }) 13 })
14 export class SeleccionArticulosComponent implements OnInit { 14 export class SeleccionArticulosComponent implements OnInit {
15 showSpinner = true; 15 showSpinner = true;
16 timeoutHandler: any; 16 timeoutHandler: any;
17 urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; 17 urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`;
18 articulos: IArticulo[] = []; 18 articulos: IArticulo[] = [];
19 auxArticulos: IArticulo[] = []; 19 auxArticulos: IArticulo[] = [];
20 showQuantity = 100; 20 showQuantity = 100;
21 queMostrar = 'todos'; 21 queMostrar = 'todos';
22 categoriaActive: number = null; 22 categoriaActive: number = null;
23 categorias: ICategoria[] = []; 23 categorias: ICategoria[] = [];
24 searchTerm = ''; 24 searchTerm = '';
25 ordenandoByVendidos = true; 25 ordenandoByVendidos = true;
26 allActive = true; 26 allActive = true;
27 modalRef: BsModalRef; 27 modalRef: BsModalRef;
28 28
29 constructor( 29 constructor(
30 public articuloService: ArticuloService, 30 public articuloService: ArticuloService,
31 private categoriaService: CategoriaService, 31 private categoriaService: CategoriaService,
32 ) { } 32 ) { }
33 33
34 ngOnInit() { 34 ngOnInit() {
35 this.getCategorias(); 35 this.getCategorias();
36 } 36 }
37 37
38 getCategorias() { 38 getCategorias() {
39 this.categoriaService.getCategorias() 39 this.categoriaService.getCategorias()
40 .subscribe((categorias: ICategoria[]) => { 40 .subscribe((categorias: ICategoria[]) => {
41 switch (this.queMostrar) { 41 switch (this.queMostrar) {
42 case 'todos': 42 case 'todos':
43 this.categorias = categorias; 43 this.categorias = categorias;
44 this.categoriaActive = 0; 44 this.categoriaActive = 0;
45 break; 45 break;
46 case 'promociones': 46 case 'promociones':
47 this.categorias = categorias; 47 this.categorias = categorias;
48 this.categoriaActive = 19; 48 this.categoriaActive = 19;
49 break; 49 break;
50 case 'ordenar': 50 case 'ordenar':
51 this.categorias = categorias.filter((categoria: ICategoria) => { 51 this.categorias = categorias.filter((categoria: ICategoria) => {
52 return categoria.ES_PEDIDO; 52 return categoria.ES_PEDIDO;
53 }); 53 });
54 this.categoriaActive = 4; 54 this.categoriaActive = 4;
55 break; 55 break;
56 default: 56 default:
57 this.categorias = categorias; 57 this.categorias = categorias;
58 this.categoriaActive = 0; 58 this.categoriaActive = 0;
59 break; 59 break;
60 } 60 }
61 !localStorage.getItem('articulos') ? 61 !localStorage.getItem('articulos') ?
62 this.getProductos() : 62 this.getProductos() :
63 this.setProductos(); 63 this.setProductos();
64 }); 64 });
65 } 65 }
66 66
67 getProductos() { 67 getProductos() {
68 this.articuloService.getAll() 68 this.articuloService.getAll()
69 .subscribe((result: IArticulo[]) => { 69 .subscribe((result: IArticulo[]) => {
70 this.articuloService.setArticulosSinImagen(result); 70 this.articuloService.setArticulosSinImagen(result);
71 if (this.queMostrar == 'ordenar') { 71 if (this.queMostrar == 'ordenar') {
72 this.categorias.forEach((categoria: ICategoria) => { 72 this.categorias.forEach((categoria: ICategoria) => {
73 let tempArticulos = result.filter((articulo: IArticulo) => { 73 let tempArticulos = result.filter((articulo: IArticulo) => {
74 return articulo.categoria_selfservice == categoria.id; 74 return articulo.categoria_selfservice == categoria.id;
75 }); 75 });
76 result = tempArticulos; 76 result = tempArticulos;
77 }); 77 });
78 } 78 }
79 localStorage.setItem('articulos', JSON.stringify(result)); 79 localStorage.setItem('articulos', JSON.stringify(result));
80 this.setProductos(); 80 this.setProductos();
81 }, (error) => { 81 }, (error) => {
82 this.showSpinner = false; 82 this.showSpinner = false;
83 console.error(error); 83 console.error(error);
84 }); 84 });
85 } 85 }
86 86
87 setProductos() { 87 setProductos() {
88 this.articulos = JSON.parse(localStorage.getItem('articulos')); 88 this.articulos = JSON.parse(localStorage.getItem('articulos'));
89 this.filterItems(); 89 this.filterItems();
90 } 90 }
91 91
92 filterItems() { 92 filterItems() {
93 if (this.categoriaActive == 0) { 93 if (this.categoriaActive == 0) {
94 this.auxArticulos = this.articulos; 94 this.auxArticulos = this.articulos;
95 return; 95 return;
96 } 96 }
97 this.auxArticulos = this.articulos.filter(x => { 97 this.auxArticulos = this.articulos.filter(x => {
98 return x.categoria_selfservice === this.categoriaActive; 98 return x.categoria_selfservice === this.categoriaActive;
99 }); 99 });
100 this.ordenar(); 100 this.ordenar();
101 } 101 }
102 102
103 ordenar() { 103 ordenar() {
104 if (this.ordenandoByVendidos) { 104 if (this.ordenandoByVendidos) {
105 this.auxArticulos.sort((a, b) => { 105 this.auxArticulos.sort((a, b) => {
106 return b.cantidadVendida - a.cantidadVendida; 106 return b.cantidadVendida - a.cantidadVendida;
107 }); 107 });
108 } 108 }
109 } 109 }
110 110
111 selectCategoria(index: number, idCategoria?: number) { 111 selectCategoria(index: number, idCategoria?: number) {
112 if (this.categoriaActive == idCategoria) return; 112 if (this.categoriaActive == idCategoria) return;
113 this.categoriaActive = idCategoria; 113 this.categoriaActive = idCategoria;
114 this.allActive = idCategoria === 0 ? true : false; 114 this.allActive = idCategoria === 0 ? true : false;
115 this.categorias.forEach((categoria, i) => { 115 this.categorias.forEach((categoria, i) => {
116 categoria.selected = index === i ? true : false; 116 categoria.selected = index === i ? true : false;
117 }); 117 });
118 this.filterItems(); 118 this.filterItems();
119 } 119 }
120 120
121 elegirArticulo(articulo: IArticulo) { 121 elegirArticulo(articulo: IArticulo) {
122 articulo.cantidad = 1; 122 this.articuloService.getById(articulo.id)
123 this.articuloService.setArticulo(articulo); 123 .subscribe((res: IArticulo) => {
124 res.cantidad = 1;
125 this.articuloService.setArticulo(res);
126 }, err => console.error(err));
124 } 127 }
125 128
126 increaseShow() { 129 increaseShow() {
127 this.showQuantity += 100; 130 this.showQuantity += 100;
128 } 131 }
129 132
130 mouseup() { 133 mouseup() {
131 if (!this.timeoutHandler) return; 134 if (!this.timeoutHandler) return;
132 clearInterval(this.timeoutHandler); 135 clearInterval(this.timeoutHandler);
133 } 136 }
134 137
135 scrollY(el: HTMLElement, value) { 138 scrollY(el: HTMLElement, value) {
136 el.scroll({ behavior: "smooth", top: value + el.scrollTop }); 139 el.scroll({ behavior: "smooth", top: value + el.scrollTop });
137 this.timeoutHandler = setInterval(() => { 140 this.timeoutHandler = setInterval(() => {
138 el.scroll({ behavior: "smooth", top: value + el.scrollTop }); 141 el.scroll({ behavior: "smooth", top: value + el.scrollTop });
139 }, 500); 142 }, 500);
140 } 143 }
141 144
142 scrollX(el: HTMLElement, value) { 145 scrollX(el: HTMLElement, value) {
143 el.scroll({ behavior: "smooth", left: value + el.scrollLeft }); 146 el.scroll({ behavior: "smooth", left: value + el.scrollLeft });
144 this.timeoutHandler = setInterval(() => { 147 this.timeoutHandler = setInterval(() => {
145 el.scroll({ behavior: "smooth", left: value + el.scrollLeft }); 148 el.scroll({ behavior: "smooth", left: value + el.scrollLeft });
146 }, 500); 149 }, 500);
147 } 150 }
148 } 151 }
149 152
src/app/services/articulo/articulo.service.ts
1 import { Injectable } from '@angular/core'; 1 import { Injectable } from '@angular/core';
2 import { HttpClient } from '@angular/common/http'; 2 import { HttpClient } from '@angular/common/http';
3 import { APP_SETTINGS } from '../../../etc/AppSettings'; 3 import { APP_SETTINGS } from '../../../etc/AppSettings';
4 import { IArticulo } from '../../interfaces/IArticulo'; 4 import { IArticulo } from '../../interfaces/IArticulo';
5 import { ClienteService } from '../cliente/cliente.service'; 5 import { ClienteService } from '../cliente/cliente.service';
6 import { Observable } from 'rxjs'; 6 import { Observable } from 'rxjs';
7 7
8 @Injectable() 8 @Injectable()
9 export class ArticuloService { 9 export class ArticuloService {
10 carrito: IArticulo[] = []; 10 carrito: IArticulo[] = [];
11 articuloAcargar: IArticulo; 11 articuloAcargar: IArticulo;
12 promoAcargar: IArticulo; 12 promoAcargar: IArticulo;
13 mostrar: string; 13 mostrar: string;
14 esPromoPersonalizada: boolean = false; 14 esPromoPersonalizada: boolean = false;
15 urlDeboSuite = APP_SETTINGS.apiDeboSuite; 15 urlDeboSuite = APP_SETTINGS.apiDeboSuite;
16 medioPago: number;
17 idComanda: number;
16 18
17 constructor( 19 constructor(
18 private http: HttpClient, 20 private http: HttpClient,
19 private clienteService: ClienteService, 21 private clienteService: ClienteService,
20 ) { } 22 ) { }
21 23
22 getById(id) { 24 getById(id) {
23 return this.http.get(`${this.urlDeboSuite}/articulos/${id}`); 25 return this.http.get(`${this.urlDeboSuite}/articulos/${id}`);
24 } 26 }
25 27
26 getAll() { 28 getAll() {
27 return this.http.get(`${this.urlDeboSuite}/articulos/`); 29 return this.http.get(`${this.urlDeboSuite}/articulos/`);
28 } 30 }
29 31
30 getAllWithPaginator(page: number = 1) { 32 getAllWithPaginator(page: number = 1) {
31 return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); 33 return this.http.get(`${this.urlDeboSuite}/articulos/${page}`);
32 } 34 }
33 35
34 setArticulo(articulo: IArticulo) { 36 setArticulo(articulo: IArticulo) {
35 for (let i = 0; i < this.carrito.length; i++) { 37 for (let i = 0; i < this.carrito.length; i++) {
36 if (this.carrito[i].id === articulo.id) { 38 if (this.carrito[i].id === articulo.id) {
37 if (articulo.PRO) break; 39 if (articulo.PRO) break;
38 this.carrito[i].cantidad++; 40 this.carrito[i].cantidad++;
39 return; 41 return;
40 } 42 }
41 } 43 }
42 this.carrito.unshift(articulo); 44 this.carrito.unshift(articulo);
43 } 45 }
44 46
45 pay(dataPago: any) { 47 pay(dataPago: any) {
46 return new Observable((observer) => { 48 return new Observable((observer) => {
47 this.clienteService.getById(-1) 49 this.clienteService.getById(-1)
48 .subscribe(cliente => { 50 .subscribe(cliente => {
49 let puntoVenta = parseInt(localStorage.getItem('impresoraPVE')); 51 let puntoVenta = 9998;
50 this.markArticuloInPromoAsRemoved(); 52 this.markArticuloInPromoAsRemoved();
51 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${dataPago.medioPago}`, { 53 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, {
52 productos: this.carrito, 54 productos: this.carrito,
53 cliente: cliente, 55 cliente: cliente,
54 origen: 'autoservicio', 56 origen: 'autoservicio',
55 codigoVendedor: 5, 57 codigoVendedor: 5,
56 puntoVenta: dataPago.medioPago === 9 ? -1 * puntoVenta : puntoVenta, 58 puntoVenta: this.medioPago === 9 ? -1 * puntoVenta : puntoVenta,
57 pedidoAnombreDe: dataPago.pedidoAnombreDe, 59 pedidoAnombreDe: dataPago.pedidoAnombreDe,
58 numeroPlanilla: '11111', 60 numeroPlanilla: '11111',
59 }) 61 })
60 .subscribe((data) => { 62 .subscribe((data) => {
61 observer.next(data); 63 observer.next(data);
62 observer.complete(); 64 observer.complete();
63 }); 65 });
64 }); 66 });
65 }); 67 });
66 } 68 }
67 69
68 cleanShoppingCar() { 70 cleanShoppingCar() {
69 this.articuloAcargar = undefined; 71 this.articuloAcargar = undefined;
70 this.promoAcargar = undefined; 72 this.promoAcargar = undefined;
71 this.carrito = []; 73 this.carrito = [];
72 } 74 }
73 75
74 setArticulosSinImagen(articulos: IArticulo[]) { 76 setArticulosSinImagen(articulos: IArticulo[]) {
75 articulos.forEach((articulo: IArticulo) => { 77 articulos.forEach((articulo: IArticulo) => {
76 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : 78 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] :
77 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; 79 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes;
78 }); 80 });
79 } 81 }
80 82
81 markArticuloInPromoAsRemoved() { 83 markArticuloInPromoAsRemoved() {
82 this.carrito.forEach((articulo: IArticulo) => { 84 this.carrito.forEach((articulo: IArticulo) => {
83 if (articulo.PRO) { 85 if (articulo.PRO) {
84 articulo.productos.forEach((articulo: IArticulo) => { 86 articulo.productos.forEach((articulo: IArticulo) => {
85 if (articulo.cantidadAdicionada === 0) { 87 if (articulo.cantidadAdicionada === 0) {
86 articulo.cantidad = 0; 88 articulo.cantidad = 0;
87 articulo.importeValorExtra = 0; 89 articulo.importeValorExtra = 0;
88 } 90 }
89 }); 91 });
90 } 92 }
91 }); 93 });
92 } 94 }
93 } 95 }
94 96