Commit fc90983e6bb708c3c5cea10d3046af1bcdfb07ae

Authored by Marcelo Puebla

Merge branch 'master' into 'develop'

Master(benjamin)

See merge request !19
src/app/modules/carrito/carrito.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { Location } from '@angular/common'; 2 import { Location } from '@angular/common';
3 import { ArticuloService } from 'src/app/services/articulo/articulo.service'; 3 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
4 import { APP_SETTINGS } from 'src/etc/AppSettings'; 4 import { APP_SETTINGS } from 'src/etc/AppSettings';
5 import { trigger, state, style, transition, animate } from '@angular/animations'; 5 import { trigger, state, style, transition, animate } from '@angular/animations';
6 import { IArticulo } from 'src/app/interfaces/IArticulo'; 6 import { IArticulo } from 'src/app/interfaces/IArticulo';
7 import { Router } from '@angular/router'; 7 import { Router } from '@angular/router';
8 8
9 @Component({ 9 @Component({
10 selector: 'app-carrito', 10 selector: 'app-carrito',
11 templateUrl: './carrito.component.html', 11 templateUrl: './carrito.component.html',
12 styleUrls: ['./carrito.component.scss'], 12 styleUrls: ['./carrito.component.scss'],
13 animations: [ 13 animations: [
14 trigger('EnterLeave', [ 14 trigger('EnterLeave', [
15 state('flyIn', style({ transform: 'translateX(0)' })), 15 state('flyIn', style({ transform: 'translateX(0)' })),
16 transition(':enter', [ 16 transition(':enter', [
17 style({ transform: 'translateX(-100%)' }), 17 style({ transform: 'translateX(-100%)' }),
18 animate('1s ease-in') 18 animate('1s ease-in')
19 ]), 19 ]),
20 transition(':leave', [ 20 transition(':leave', [
21 animate('1s ease-out', style({ transform: 'translateX(-100%)' })) 21 animate('1s ease-out', style({ transform: 'translateX(-100%)' }))
22 ]) 22 ])
23 ]) 23 ])
24 ] 24 ]
25 }) 25 })
26 export class CarritoComponent implements OnInit { 26 export class CarritoComponent implements OnInit {
27 urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; 27 urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`;
28 maxCantidad = 50; 28 maxCantidad = 50;
29 29
30 constructor( 30 constructor(
31 public articuloService: ArticuloService, 31 public articuloService: ArticuloService,
32 private location: Location, 32 private location: Location,
33 private router: Router, 33 private router: Router,
34 ) { } 34 ) { }
35 35
36 ngOnInit() { 36 ngOnInit() {
37 if (!this.articuloService.carrito.length) { 37 if (!this.articuloService.carrito.length) {
38 this.router.navigate(['']); 38 this.router.navigate(['']);
39 return; 39 return;
40 } 40 }
41 } 41 }
42 42
43 deleteArticulo(index: number) { 43 deleteArticulo(index: number) {
44 this.articuloService.carrito.splice(index, 1); 44 this.articuloService.carrito.splice(index, 1);
45 this.articuloService.calcularTotal();
45 } 46 }
46 47
47 substractCant(articulo: IArticulo) { 48 substractCant(articulo: IArticulo) {
48 if (articulo.cantidad === 1) return; 49 if (articulo.cantidad === 1) return;
49 articulo.cantidad--; 50 articulo.cantidad--;
51 this.articuloService.calcularTotal();
50 } 52 }
51 53
52 addCant(articulo: IArticulo) { 54 addCant(articulo: IArticulo) {
53 if (articulo.cantidad >= this.maxCantidad) return; 55 if (articulo.cantidad >= this.maxCantidad) return;
54 articulo.cantidad++; 56 articulo.cantidad++;
57 this.articuloService.calcularTotal();
55 } 58 }
56 59
57 goBack() { 60 goBack() {
58 this.location.back(); 61 this.location.back();
59 } 62 }
60 63
61 } 64 }
62 65
src/app/modules/comanda/comanda.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda'; 2 import { IComanda, IComandaDetalle, IComponente } from 'src/app/interfaces/IComanda';
3 import { ComandaService } from 'src/app/services/comanda/comanda.service'; 3 import { ComandaService } from 'src/app/services/comanda/comanda.service';
4 import * as _ from 'lodash'; 4 import * as _ from 'lodash';
5 5
6 @Component({ 6 @Component({
7 selector: 'app-comanda', 7 selector: 'app-comanda',
8 templateUrl: './comanda.component.html', 8 templateUrl: './comanda.component.html',
9 styleUrls: ['./comanda.component.scss'] 9 styleUrls: ['./comanda.component.scss']
10 }) 10 })
11 export class ComandaComponent implements OnInit { 11 export class ComandaComponent implements OnInit {
12 comandas: IComanda[] = []; 12 comandas: IComanda[] = [];
13 cicloTime: any; 13 cicloTime: any;
14 14
15 constructor( 15 constructor(
16 private comandaService: ComandaService, 16 private comandaService: ComandaService,
17 ) { } 17 ) { }
18 18
19 ngOnInit() { 19 ngOnInit() {
20 this.getComandas(); 20 this.getComandas();
21 this.timerGetComandas(); 21 this.timerGetComandas();
22 } 22 }
23 23
24 ngOnDestroy() { 24 ngOnDestroy() {
25 clearInterval(this.cicloTime); 25 clearInterval(this.cicloTime);
26 } 26 }
27 27
28 timerGetComandas() { 28 timerGetComandas() {
29 this.cicloTime = setInterval(() => { 29 this.cicloTime = setInterval(() => {
30 this.getComandas(); 30 this.getComandas();
31 }, 5000); 31 }, 5000);
32 } 32 }
33 33
34 getComandas() { 34 getComandas() {
35 this.comandaService.getAll() 35 this.comandaService.getAll()
36 .subscribe((resComandas: IComanda[]) => { 36 .subscribe((resComandas: IComanda[]) => {
37 this.addNewComandas(resComandas); 37 this.addNewComandas(resComandas);
38 }, e => console.error(e)); 38 }, e => console.error(e));
39 } 39 }
40 40
41 addNewComandas(resComandas: IComanda[]) { 41 addNewComandas(resComandas: IComanda[]) {
42 for (let j = 0; j < resComandas.length; j++) { 42 for (let j = 0; j < resComandas.length; j++) {
43 for (let i = 0; i < this.comandas.length; i++) { 43 for (let i = 0; i < this.comandas.length; i++) {
44 if (this.comandas[i].id === resComandas[j].id) { 44 if (this.comandas[i].id === resComandas[j].id) {
45 resComandas.splice(j, 1); 45 resComandas.splice(j, 1);
46 } 46 }
47 } 47 }
48 } 48 }
49 if (!resComandas.length) return; 49 if (!resComandas.length) return;
50 Array.prototype.push.apply(this.comandas, resComandas); 50 Array.prototype.push.apply(this.comandas, resComandas);
51 this.startTimersPedido(resComandas); 51 this.startTimersPedido(resComandas);
52 } 52 }
53 53
54 updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) { 54 updateComanda(comanda: IComanda, estadoNuevo: number, observacionNueva: string) {
55 let data = { 55 let data = {
56 idComanda: comanda.id, 56 idComanda: comanda.id,
57 estado: estadoNuevo, 57 estado: estadoNuevo,
58 observacion: observacionNueva, 58 observacion: observacionNueva,
59 tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`, 59 tiempoEspera: `${comanda.hoursPedido}:${comanda.secondsPedido}:${comanda.secondsPedido}`,
60 tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`, 60 tiempoElaboracion: `${comanda.hoursElaboracion}:${comanda.secondsElaboracion}:${comanda.secondsElaboracion}`,
61 } 61 };
62 if (data.estado == 3) { 62 if (data.estado === 3) {
63 this.comandaService.imprimirComandaCocina(parseInt(data.idComanda)) 63 this.comandaService.imprimirComandaCocina(parseInt(data.idComanda))
64 .subscribe(res => { }, err => console.error(err) 64 .subscribe(res => { }, err => console.error(err)
65 ); 65 );
66 } 66 }
67 67
68 if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false); 68 if (estadoNuevo !== 2) comanda.detalles.forEach(d => d.seeDetalle = false);
69 69
70 this.comandaService.update(data) 70 this.comandaService.update(data)
71 .subscribe((res: any) => { 71 .subscribe((res: any) => {
72 if (res.data) { 72 if (res.data) {
73 comanda.estado = estadoNuevo; 73 comanda.estado = estadoNuevo;
74 comanda.observacion = observacionNueva; 74 comanda.observacion = observacionNueva;
75 if (estadoNuevo == 2) { 75 if (estadoNuevo === 2) {
76 this.startTimerElaboracion(comanda); 76 this.startTimerElaboracion(comanda);
77 } else if (comanda.timerElaboracion) { 77 } else if (comanda.timerElaboracion) {
78 clearInterval(comanda.timerElaboracion) 78 clearInterval(comanda.timerElaboracion);
79 } 79 }
80 } 80 }
81 }, e => console.error(e)); 81 }, e => console.error(e));
82 } 82 }
83 83
84 rellenar(relleno, longitud) { 84 rellenar(relleno, longitud) {
85 relleno = '' + relleno; 85 relleno = '' + relleno;
86 while (relleno.length < longitud) { 86 while (relleno.length < longitud) {
87 relleno = '0' + relleno; 87 relleno = '0' + relleno;
88 } 88 }
89 return relleno; 89 return relleno;
90 } 90 }
91 91
92 toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) { 92 toggleVerComponentes(detalle: IComandaDetalle, comanda: IComanda) {
93 detalle.seeDetalle = !detalle.seeDetalle; 93 detalle.seeDetalle = !detalle.seeDetalle;
94 } 94 }
95 95
96 hasTipo(componentes: IComponente[]) { 96 hasTipo(componentes: IComponente[]) {
97 return componentes.some(c => c.tipoArticulo === 6); 97 return componentes.some(c => c.tipoArticulo === 6);
98 } 98 }
99 99
100 //#region TIMERS 100 //#region TIMERS
101 startTimersPedido(comandas) { 101 startTimersPedido(comandas) {
102 comandas.forEach((comanda: IComanda) => { 102 comandas.forEach((comanda: IComanda) => {
103 this.comandaService.startTimerComanda(comanda, 'Pedido'); 103 this.comandaService.startTimerComanda(comanda, 'Pedido');
104 if (comanda.estado === 2) { 104 if (comanda.estado === 2) {
105 this.startTimerElaboracion(comanda); 105 this.startTimerElaboracion(comanda);
106 } 106 }
107 }); 107 });
108 } 108 }
109 109
110 startTimerElaboracion(comanda: IComanda) { 110 startTimerElaboracion(comanda: IComanda) {
111 this.comandaService.startTimerComanda(comanda, 'Elaboracion'); 111 this.comandaService.startTimerComanda(comanda, 'Elaboracion');
112 } 112 }
113 //#endregion 113 //#endregion
114 114
115 } 115 }
116 116
src/app/modules/opcion-pedido/opcion-pedido.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"> 14 <div class="col-12 px-0 py-2 align-self-center">
15 <p class="h6 text-truncate text-center">TÚ PEDIDO ES PARA</p> 15 <p class="h6 text-truncate text-center">TU PEDIDO ES PARA</p>
16 </div> 16 </div>
17 </div> 17 </div>
18 <div class="row mt-5 h-auto justify-content-center mx-0"> 18 <div class="row mt-5 h-auto justify-content-center mx-0">
19 <div class="col-auto px-0 h-auto align-self-start"> 19 <div class="col-auto px-0 h-auto align-self-start">
20 <div 20 <div
21 class="btn-effect col-auto align-self-center px-0 bg-white" 21 class="btn-effect col-auto align-self-center px-0 bg-white"
22 (click)="goTo('/seleccion-articulos'); seleccionPedido('comer aca')"> 22 (click)="goTo('/seleccion-articulos'); seleccionPedido('comer aca')">
23 <div class="row mx-0 bg-primary badge-pill"> 23 <div class="row mx-0 bg-primary badge-pill">
24 <div class="col-auto p-0"> 24 <div class="col-auto p-0">
25 <img 25 <img
26 draggable="false" 26 draggable="false"
27 ondragstart="return false;" 27 ondragstart="return false;"
28 (contextmenu)="false" 28 (contextmenu)="false"
29 class="p-1 icon-50" 29 class="p-1 icon-50"
30 src="assets/img/icono-plato.svg"> 30 src="assets/img/icono-plato.svg">
31 </div> 31 </div>
32 <div class="col-auto align-self-center text-white">comer acá</div> 32 <div class="col-auto align-self-center text-white">comer acá</div>
33 <div class="col-auto align-self-center p-0"> 33 <div class="col-auto align-self-center p-0">
34 <img 34 <img
35 draggable="false" 35 draggable="false"
36 ondragstart="return false;" 36 ondragstart="return false;"
37 (contextmenu)="false" 37 (contextmenu)="false"
38 class="p-1 icon-30" 38 class="p-1 icon-30"
39 src="assets/img/ir.svg"> 39 src="assets/img/ir.svg">
40 </div> 40 </div>
41 </div> 41 </div>
42 </div> 42 </div>
43 </div> 43 </div>
44 </div> 44 </div>
45 <div class="row mt-4 h-auto justify-content-center mx-0"> 45 <div class="row mt-4 h-auto justify-content-center mx-0">
46 <div class="col-auto px-0 h-auto align-self-start"> 46 <div class="col-auto px-0 h-auto align-self-start">
47 <div 47 <div
48 class="btn-effect col-auto align-self-center px-0 bg-white" 48 class="btn-effect col-auto align-self-center px-0 bg-white"
49 (click)="goTo('/seleccion-articulos'); seleccionPedido('para llevar')"> 49 (click)="goTo('/seleccion-articulos'); seleccionPedido('para llevar')">
50 <div class="row mx-0 bg-primary badge-pill"> 50 <div class="row mx-0 bg-primary badge-pill">
51 <div class="col-auto p-0"> 51 <div class="col-auto p-0">
52 <img 52 <img
53 draggable="false" 53 draggable="false"
54 ondragstart="return false;" 54 ondragstart="return false;"
55 (contextmenu)="false" 55 (contextmenu)="false"
56 class="p-1 icon-50" 56 class="p-1 icon-50"
57 src="assets/img/icono-take-away.svg"> 57 src="assets/img/icono-take-away.svg">
58 </div> 58 </div>
59 <div class="col-auto align-self-center text-white">para llevar</div> 59 <div class="col-auto align-self-center text-white">para llevar</div>
60 <div class="col-auto align-self-center p-0"> 60 <div class="col-auto align-self-center p-0">
61 <img 61 <img
62 draggable="false" 62 draggable="false"
63 ondragstart="return false;" 63 ondragstart="return false;"
64 (contextmenu)="false" 64 (contextmenu)="false"
65 class="p-1 icon-30" 65 class="p-1 icon-30"
66 src="assets/img/ir.svg"> 66 src="assets/img/ir.svg">
67 </div> 67 </div>
68 </div> 68 </div>
69 </div> 69 </div>
70 </div> 70 </div>
71 </div> 71 </div>
72 </div> 72 </div>
73 </div> 73 </div>
74 74
src/app/modules/pago-tarjeta/pago-tarjeta.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 h-50 mx-0 justify-content-center text-center"> 13 <div class="row h-50 mx-0 justify-content-center text-center">
14 <div class="col-7 p-5 h-auto align-self-end border border-secondary rounded"> 14 <div class="col-7 p-5 h-auto align-self-end border border-secondary rounded">
15 <img 15 <img
16 draggable="false" 16 draggable="false"
17 ondragstart="return false;" 17 ondragstart="return false;"
18 (contextmenu)="false" 18 (contextmenu)="false"
19 class="img-in-top px-4 bg-white" 19 class="img-in-top px-4 bg-white"
20 src="assets/img/icono-tarjetas.svg"> 20 src="assets/img/icono-tarjetas.svg">
21 <p class="h6 m-0">AHORA</p> 21 <p class="h6 m-0">AHORA</p>
22 <p class="h2 mb-3 text-secondary"> 22 <p class="h2 mb-3 text-secondary">
23 introducí o insertá tú tarjeta 23 introducí o insertá tu tarjeta
24 </p> 24 </p>
25 <p class="h6 m-0">Y SEGUÍ LAS INSTRUCCIONES DEL LECTOR</p> 25 <p class="h6 m-0">Y SEGUÍ LAS INSTRUCCIONES DEL LECTOR</p>
26 </div> 26 </div>
27 </div> 27 </div>
28 <div class="row mt-5 justify-content-center arrow-slide arrow-delay-1"> 28 <div class="row mt-5 justify-content-center arrow-slide arrow-delay-1">
29 <div class="col-1"> 29 <div class="col-1">
30 <img 30 <img
31 draggable="false" 31 draggable="false"
32 ondragstart="return false;" 32 ondragstart="return false;"
33 (contextmenu)="false" 33 (contextmenu)="false"
34 class="img-fluid" 34 class="img-fluid"
35 src="assets/img/down-chevron.svg"> 35 src="assets/img/down-chevron.svg">
36 </div> 36 </div>
37 </div> 37 </div>
38 <div class="row justify-content-center arrow-slide arrow-delay-2"> 38 <div class="row justify-content-center arrow-slide arrow-delay-2">
39 <div class="col-1"> 39 <div class="col-1">
40 <img 40 <img
41 draggable="false" 41 draggable="false"
42 ondragstart="return false;" 42 ondragstart="return false;"
43 (contextmenu)="false" 43 (contextmenu)="false"
44 class="img-fluid" 44 class="img-fluid"
45 src="assets/img/down-chevron.svg"> 45 src="assets/img/down-chevron.svg">
46 </div> 46 </div>
47 </div> 47 </div>
48 <div class="row justify-content-center arrow-slide arrow-delay-3"> 48 <div class="row justify-content-center arrow-slide arrow-delay-3">
49 <div class="col-1"> 49 <div class="col-1">
50 <img 50 <img
51 draggable="false" 51 draggable="false"
52 ondragstart="return false;" 52 ondragstart="return false;"
53 (contextmenu)="false" 53 (contextmenu)="false"
54 class="img-fluid" 54 class="img-fluid"
55 src="assets/img/down-chevron.svg"> 55 src="assets/img/down-chevron.svg">
56 </div> 56 </div>
57 </div> 57 </div>
58 </div> 58 </div>
59 </div> 59 </div>
60 60
src/app/modules/seleccion-articulos/seleccion-articulos.component.html
1 <div class="h-92 bg-white fade-in-left"> 1 <div class="h-92 bg-white fade-in-left">
2 <!-- PUBLICIDADES --> 2 <!-- PUBLICIDADES -->
3 <app-header-publicidad></app-header-publicidad> 3 <app-header-publicidad></app-header-publicidad>
4 4
5 <div class="row mx-0 h-80 align-items-end"> 5 <div class="row mx-0 h-80 align-items-end">
6 <!-- CABECERA --> 6 <!-- CABECERA -->
7 <div class="row w-100 mx-3 h-auto border border-primary rounded-sm"> 7 <div class="row w-100 mx-3 h-auto border border-primary rounded-sm">
8 <div class="col-12 p-2 align-self-center"> 8 <div class="col-12 p-2 align-self-center">
9 <div class="px-3"> 9 <div class="px-3">
10 <p class="h6 text-truncate">SELECCIONÁ TÚ COMIDA Y/O BEBIDA</p> 10 <p class="h6 text-truncate">SELECCIONÁ TÚ COMIDA Y/O BEBIDA</p>
11 </div> 11 </div>
12 </div> 12 </div>
13 </div> 13 </div>
14 <!-- CUERPO --> 14 <!-- CUERPO -->
15 <div class="row w-100 mr-4 h-70"> 15 <div class="row w-100 mr-4 h-70">
16 <div class="col-12 h-100 px-0 py-3"> 16 <div class="col-12 h-100 px-0 py-3">
17 <div class="row mx-0 h-100"> 17 <div class="row mx-0 h-100">
18 <!-- FILTRO CATEGORIAS --> 18 <!-- FILTRO CATEGORIAS -->
19 <div class="col-5 col-sm-3 col-xl-2 h-100"> 19 <div class="col-5 col-sm-3 col-xl-2 h-100">
20 <p class="h6 h-6 m-0 text-center"><small>CATEGORÍAS</small></p> 20 <p class="h6 h-6 m-0 text-center"><small>CATEGORÍAS</small></p>
21 <div class="row mx-0 h-94 justify-content-center align-items-center"> 21 <div class="row mx-0 h-94 justify-content-center align-items-center">
22 <div class="col-auto btn-effect h-5"> 22 <div class="col-auto btn-effect h-5">
23 <img 23 <img
24 draggable="false" 24 draggable="false"
25 ondragstart="return false;" 25 ondragstart="return false;"
26 (contextmenu)="false" 26 (contextmenu)="false"
27 class="h-100 d-block mx-auto rotate-90-neg" 27 class="h-100 d-block mx-auto rotate-90-neg"
28 src="assets/img/ir-color.svg" 28 src="assets/img/ir-color.svg"
29 (mousedown)="scrollY(templateCategorias, -100)" 29 (mousedown)="scrollY(templateCategorias, -100)"
30 (mouseup)="mouseup()" 30 (mouseup)="mouseup()"
31 (mouseleave)="mouseup()"> 31 (mouseleave)="mouseup()">
32 </div> 32 </div>
33 <!-- CATEGORIAS --> 33 <!-- CATEGORIAS -->
34 <div 34 <div
35 #templateCategorias 35 #templateCategorias
36 class="col-12 px-0 box-categorias border border-primary border-left-0 rounded-right scroll-y"> 36 class="col-12 px-0 box-categorias border border-primary border-left-0 rounded-right scroll-y">
37 <div 37 <div
38 class="row mx-4 mb-2 h-32 justify-content-center tab" 38 class="row mx-4 mb-2 h-32 justify-content-center tab"
39 [ngClass]="{ 'active': allActive, 'border-bottom-effect': !allActive }" 39 [ngClass]="{ 'active': allActive, 'border-bottom-effect': !allActive }"
40 (click)="selectCategoria(-1, 0)"> 40 (click)="selectCategoria(-1, 0)">
41 <img 41 <img
42 draggable="false" 42 draggable="false"
43 ondragstart="return false;" 43 ondragstart="return false;"
44 (contextmenu)="false" 44 (contextmenu)="false"
45 class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle" 45 class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle"
46 src="assets/img/ir-color.svg"> 46 src="assets/img/ir-color.svg">
47 <small class="col-12 px-0 my-1 h-25 align-self-end text-center text-truncate">Todos</small> 47 <small class="col-12 px-0 my-1 h-25 align-self-end text-center text-truncate">Todos</small>
48 </div> 48 </div>
49 <div 49 <div
50 class="row mx-4 mb-2 h-32 justify-content-center tab" 50 class="row mx-4 mb-2 h-32 justify-content-center tab"
51 [ngClass]="{ 'active': categoria.selected, 'border-bottom-effect': !categoria.selected }" 51 [ngClass]="{ 'active': categoria.selected, 'border-bottom-effect': !categoria.selected }"
52 (click)="selectCategoria(i, categoria.id)" 52 (click)="selectCategoria(i, categoria.id)"
53 *ngFor="let categoria of categorias; let i = index;"> 53 *ngFor="let categoria of categorias; let i = index;">
54 <img 54 <img
55 draggable="false" 55 draggable="false"
56 ondragstart="return false;" 56 ondragstart="return false;"
57 (contextmenu)="false" 57 (contextmenu)="false"
58 class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle" 58 class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle"
59 src="assets/img/ir-color.svg"> 59 src="assets/img/ir-color.svg">
60 <small class="col-12 px-0 my-1 h-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small> 60 <small class="col-12 px-0 my-1 h-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small>
61 </div> 61 </div>
62 </div> 62 </div>
63 <div class="col-auto btn-effect h-5"> 63 <div class="col-auto btn-effect h-5">
64 <img 64 <img
65 draggable="false" 65 draggable="false"
66 ondragstart="return false;" 66 ondragstart="return false;"
67 (contextmenu)="false" 67 (contextmenu)="false"
68 class="h-100 d-block mx-auto rotate-90" 68 class="h-100 d-block mx-auto rotate-90"
69 src="assets/img/ir-color.svg" 69 src="assets/img/ir-color.svg"
70 (mousedown)="scrollY(templateCategorias, 100)" 70 (mousedown)="scrollY(templateCategorias, 100)"
71 (mouseup)="mouseup()" 71 (mouseup)="mouseup()"
72 (mouseleave)="mouseup()"> 72 (mouseleave)="mouseup()">
73 </div> 73 </div>
74 </div> 74 </div>
75 </div> 75 </div>
76 <!-- LISTA DE ARTICULOS --> 76 <!-- LISTA DE ARTICULOS -->
77 <div class="col-7 col-sm-9 col-xl-10 pb-3 h-80 align-self-center scroll-y-visible"> 77 <div class="col-7 col-sm-9 col-xl-10 pb-3 h-80 align-self-center scroll-y-visible">
78 <div class="row row-cols-1 row-cols-sm-3 row-cols-xl-6"> 78 <div class="row row-cols-1 row-cols-sm-3 row-cols-xl-6">
79 <!-- ARTICULO --> 79 <!-- ARTICULO -->
80 <div 80 <div
81 class="col px-2 my-1 my-md-3 h-auto" 81 class="col px-2 my-1 my-md-3 h-auto"
82 *ngFor="let articulo of auxArticulos | slice:0:showQuantity;"> 82 *ngFor="let articulo of auxArticulos | slice:0:showQuantity;">
83 <div class="swing-in-top-fwd card h-auto"> 83 <div class="swing-in-top-fwd card h-auto">
84 <img 84 <img
85 draggable="false" 85 draggable="false"
86 ondragstart="return false;" 86 ondragstart="return false;"
87 (contextmenu)="false" 87 (contextmenu)="false"
88 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" 88 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}"
89 onerror="this.src='assets/img/image-not-found.jpg'" 89 onerror="this.src='assets/img/image-not-found.jpg'"
90 class="card-img-top h-55 rounded-sm"> 90 class="card-img-top h-55 rounded-sm">
91 <div class="row mx-0 py-1 h-auto justify-content-center"> 91 <div class="row mx-0 py-1 h-auto justify-content-center">
92 <p class="col-12 px-1 h6 h-auto text-primary text-center">{{articulo.DetArt}}</p> 92 <p class="col-12 px-1 h6 h-auto text-primary text-center">{{articulo.DetArt}}</p>
93 <p class="col-12 px-1 h-auto text-center line-height-sm"> 93 <p class="col-12 px-1 h-auto text-center line-height-sm">
94 <small>{{articulo.DET_LAR}}</small> 94 <small>{{articulo.DET_LAR}}</small>
95 </p> 95 </p>
96 <div class="col-12 px-1 align-self-end btn-effect h-auto"> 96 <div class="col-12 px-1 align-self-end btn-effect h-auto">
97 <div 97 <div
98 [ngClass]="{'bg-secondary': articulo.promo}" 98 [ngClass]="{'bg-secondary': articulo.promo}"
99 class="row mx-0 justify-content-between bg-primary badge-pill" 99 class="row mx-0 justify-content-between bg-primary badge-pill"
100 (click)="elegirArticulo(articulo)"> 100 (click)="elegirArticulo(articulo)">
101 <div class="col px-0 align-self-center text-white text-right"> 101 <div class="col px-0 align-self-center text-white text-right">
102 {{articulo.PreVen | currency}} 102 {{articulo.PreVen | currency}}
103 </div> 103 </div>
104 <div class="col-5 px-0"> 104 <div class="col-5 px-0">
105 <img 105 <img
106 draggable="false" 106 draggable="false"
107 ondragstart="return false;" 107 ondragstart="return false;"
108 (contextmenu)="false" 108 (contextmenu)="false"
109 class="d-block ml-auto py-1 icon-30" 109 class="d-block ml-auto py-1 icon-30"
110 src="assets/img/ir.svg"> 110 src="assets/img/ir.svg">
111 </div> 111 </div>
112 </div> 112 </div>
113 </div> 113 </div>
114 </div> 114 </div>
115 </div> 115 </div>
116 </div> 116 </div>
117 </div> 117 </div>
118 <!-- BOTON VER MAS --> 118 <!-- BOTON VER MAS -->
119 <div class="row mx-0"> 119 <div class="row mx-0">
120 <div 120 <div
121 *ngIf="showQuantity <= auxArticulos.slice(0, showQuantity).length" 121 *ngIf="showQuantity <= auxArticulos.slice(0, showQuantity).length"
122 class="col-12 px-0 mb-2"> 122 class="col-12 px-0 mb-2">
123 <button 123 <button
124 (click)="increaseShow()" 124 (click)="increaseShow()"
125 class="btn btn-block btn-outline-primary"> 125 class="btn btn-block btn-outline-primary">
126 Ver Más 126 Ver Más
127 </button> 127 </button>
128 </div> 128 </div>
129 </div> 129 </div>
130 </div> 130 </div>
131 </div> 131 </div>
132 </div> 132 </div>
133 </div> 133 </div>
134 <!-- FOOTER CARRITO DE COMPRAS --> 134 <!-- FOOTER CARRITO DE COMPRAS -->
135 <div class="row w-90 mx-auto h-auto justify-content-center"> 135 <div class="row w-90 mx-auto h-auto justify-content-center">
136 <div class="col-12 h-75 px-0 border border-primary rounded"> 136 <div class="col-12 h-75 px-0 border border-primary rounded">
137 <!-- CABECERA --> 137 <!-- CABECERA -->
138 <div class="row mx-0 h-15 border-bottom border-primary"> 138 <div class="row mx-0 h-15 border-bottom border-primary">
139 <p class="col align-self-center text-truncate"><small>ARTÍCULOS EN TÚ CARRITO DE COMPRAS</small></p> 139 <p class="col align-self-center text-truncate"><small>ARTÍCULOS EN TÚ CARRITO DE COMPRAS</small></p>
140 </div> 140 </div>
141 <!-- CUERPO --> 141 <!-- CUERPO -->
142 <div class="row h-85 mx-0 justify-content-around"> 142 <div class="row h-85 mx-0 justify-content-around">
143 <!-- BOTON SCROLL IZQUIERDA --> 143 <!-- BOTON SCROLL IZQUIERDA -->
144 <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center"> 144 <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center">
145 <img 145 <img
146 draggable="false" 146 draggable="false"
147 ondragstart="return false;" 147 ondragstart="return false;"
148 (contextmenu)="false" 148 (contextmenu)="false"
149 class="icon-30 rotate-180-neg" 149 class="icon-30 rotate-180-neg"
150 src="assets/img/ir-fondo-color.svg" 150 src="assets/img/ir-fondo-color.svg"
151 (mousedown)="scrollX(templateCarrito, -100)" 151 (mousedown)="scrollX(templateCarrito, -100)"
152 (mouseup)="mouseup()" 152 (mouseup)="mouseup()"
153 (mouseleave)="mouseup()"> 153 (mouseleave)="mouseup()">
154 </div> 154 </div>
155 <!-- CARRITO --> 155 <!-- CARRITO -->
156 <div class="col-6 col-sm-8 col-md-9 col-lg-10 h-100"> 156 <div class="col-6 col-sm-8 col-md-9 col-lg-10 h-100">
157 <div #templateCarrito class="row flex-row flex-nowrap h-100 mx-0 my-2 scroll-x"> 157 <div #templateCarrito class="row flex-row flex-nowrap h-100 mx-0 my-2 scroll-x">
158 <!-- MENSAJE DE ADVERTENCIA --> 158 <!-- MENSAJE DE ADVERTENCIA -->
159 <div *ngIf="!articuloService.carrito.length" class="col h-100"> 159 <div *ngIf="!articuloService.carrito.length" class="col h-100">
160 <p class="text-center py-5">No hay articulos en el carrito</p> 160 <p class="text-center py-5">No hay articulos en el carrito</p>
161 </div> 161 </div>
162 <!-- ARTICULOS --> 162 <!-- ARTICULOS -->
163 <div 163 <div
164 class="col-10 col-sm-4 col-lg-2 px-2 px-xl-4 align-self-center border-right border-primary" 164 class="col-10 col-sm-4 col-lg-2 px-2 px-xl-4 align-self-center border-right border-primary"
165 *ngFor="let articulo of articuloService.carrito; let i = index;"> 165 *ngFor="let articulo of articuloService.carrito; let i = index;">
166 <div class="swing-in-top-fwd"> 166 <div class="swing-in-top-fwd">
167 <img 167 <img
168 draggable="false" 168 draggable="false"
169 ondragstart="return false;" 169 ondragstart="return false;"
170 (contextmenu)="false" 170 (contextmenu)="false"
171 class="d-block img-fluid p-2 mx-auto rounded" 171 class="d-block img-fluid p-2 mx-auto rounded"
172 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" 172 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}"
173 onerror="this.src='assets/img/image-not-found.jpg'"> 173 onerror="this.src='assets/img/image-not-found.jpg'">
174 <p class="d-block mt-auto text-center text-primary text-truncate"> 174 <p class="d-block mt-auto text-center text-primary text-truncate">
175 <small>{{articulo.DetArt}}</small> 175 <small>{{articulo.DetArt}}</small>
176 </p> 176 </p>
177 </div> 177 </div>
178 </div> 178 </div>
179 </div> 179 </div>
180 </div> 180 </div>
181 <!-- BOTON SCROLL DERECHA --> 181 <!-- BOTON SCROLL DERECHA -->
182 <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center"> 182 <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center">
183 <img 183 <img
184 draggable="false" 184 draggable="false"
185 ondragstart="return false;" 185 ondragstart="return false;"
186 (contextmenu)="false" 186 (contextmenu)="false"
187 class="icon-30" 187 class="icon-30"
188 src="assets/img/ir-fondo-color.svg" 188 src="assets/img/ir-fondo-color.svg"
189 (mousedown)="scrollX(templateCarrito, 100)" 189 (mousedown)="scrollX(templateCarrito, 100)"
190 (mouseup)="mouseup()" 190 (mouseup)="mouseup()"
191 (mouseleave)="mouseup()"> 191 (mouseleave)="mouseup()">
192 </div> 192 </div>
193 </div> 193 </div>
194 </div> 194 </div>
195 <!-- VER CARRITO --> 195 <!-- VER CARRITO Y TOTAL-->
196 <div 196 <div
197 class="col-auto p-0 mt-2 ml-auto h-20" 197 class="col-auto p-0 mt-2 ml-auto h-20"
198 *ngIf="articuloService.carrito.length"> 198 *ngIf="articuloService.carrito.length">
199 <div 199 <div
200 class="btn-effect col-auto align-self-center px-0 bg-white" 200 class="btn-effect col-auto align-self-center px-0 bg-white"
201 [routerLink]="['/carrito']"> 201 [routerLink]="['/carrito']">
202 <div class="row mx-0 bg-light"> 202 <div class="row justify-content-between mx-0">
203 <div class="col-auto align-self-center text-primary">VER CARRITO</div> 203 <div class="col-auto align-self-center text-primary">TOTAL</div>
204 <div class="col-auto p-0 bg-primary d-none d-sm-block total-background">
205 <p class="text-center text-white mt-1 py-1">{{articuloService.subTotal | currency}}</p>
206 </div>
207 <div class="col-auto align-self-center text-primary ml-2 bg-light">VER CARRITO</div>
204 <div class="col-auto p-0 bg-primary d-none d-sm-block"> 208 <div class="col-auto p-0 bg-primary d-none d-sm-block">
205 <img 209 <img
206 draggable="false" 210 draggable="false"
207 ondragstart="return false;" 211 ondragstart="return false;"
208 (contextmenu)="false" 212 (contextmenu)="false"
209 class="p-2 icon-40" 213 class="p-2 icon-40"
210 src="assets/img/carrito.svg"> 214 src="assets/img/carrito.svg">
211 </div> 215 </div>
212 </div> 216 </div>
213 </div> 217 </div>
214 </div> 218 </div>
215 219
216 </div> 220 </div>
217 </div> 221 </div>
218 222
219 </div> 223 </div>
220 224
src/app/modules/seleccion-articulos/seleccion-articulos.component.scss
1 $primary: #aa006b; 1 $primary: #aa006b;
2 2
3 .box-categorias { 3 .box-categorias {
4 height: calc(100% - 100px) !important; 4 height: calc(100% - 100px) !important;
5 } 5 }
6 6
7 .active { 7 .active {
8 background-color: white; 8 background-color: white;
9 border-bottom: 3px solid $primary !important; 9 border-bottom: 3px solid $primary !important;
10 } 10 }
11 11
12 .border-bottom-effect { 12 .border-bottom-effect {
13 border: none; 13 border: none;
14 position: relative; 14 position: relative;
15 &:hover { 15 &:hover {
16 border: none; 16 border: none;
17 } 17 }
18 &::after { 18 &::after {
19 content: ""; 19 content: "";
20 position: absolute; 20 position: absolute;
21 width: 0px; 21 width: 0px;
22 height: 3px; 22 height: 3px;
23 left: 50%; 23 left: 50%;
24 bottom: 0; 24 bottom: 0;
25 background-color: $primary; 25 background-color: $primary;
26 transition: all ease-in-out 0.2s; 26 transition: all ease-in-out 0.2s;
27 } 27 }
28 &:hover::after { 28 &:hover::after {
29 width: 100%; 29 width: 100%;
30 left: 0; 30 left: 0;
31 } 31 }
32 } 32 }
33 33
34 .card { 34 .card {
35 border: none; 35 border: none;
36 } 36 }
37 37
38 .line-height-sm { 38 .line-height-sm {
39 line-height: 1.2; 39 line-height: 1.2;
40 }
40 }
41
42 .total-background {
43 width: 110px;
44 border-radius: 1.5rem;
45 }
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 total: number = 0;
28 29
29 constructor( 30 constructor(
30 public articuloService: ArticuloService, 31 public articuloService: ArticuloService,
31 private categoriaService: CategoriaService, 32 private categoriaService: CategoriaService,
32 ) { } 33 ) { }
33 34
34 ngOnInit() { 35 ngOnInit() {
35 this.getCategorias(); 36 this.getCategorias();
36 } 37 }
37 38
38 getCategorias() { 39 getCategorias() {
39 this.categoriaService.getCategorias() 40 this.categoriaService.getCategorias()
40 .subscribe((categorias: ICategoria[]) => { 41 .subscribe((categorias: ICategoria[]) => {
41 switch (this.queMostrar) { 42 switch (this.queMostrar) {
42 case 'todos': 43 case 'todos':
43 this.categorias = categorias; 44 this.categorias = categorias;
44 this.categoriaActive = 0; 45 this.categoriaActive = 0;
45 break; 46 break;
46 case 'promociones': 47 case 'promociones':
47 this.categorias = categorias; 48 this.categorias = categorias;
48 this.categoriaActive = 19; 49 this.categoriaActive = 19;
49 break; 50 break;
50 case 'ordenar': 51 case 'ordenar':
51 this.categorias = categorias.filter((categoria: ICategoria) => { 52 this.categorias = categorias.filter((categoria: ICategoria) => {
52 return categoria.ES_PEDIDO; 53 return categoria.ES_PEDIDO;
53 }); 54 });
54 this.categoriaActive = 4; 55 this.categoriaActive = 4;
55 break; 56 break;
56 default: 57 default:
57 this.categorias = categorias; 58 this.categorias = categorias;
58 this.categoriaActive = 0; 59 this.categoriaActive = 0;
59 break; 60 break;
60 } 61 }
61 !localStorage.getItem('articulos') ? 62 !localStorage.getItem('articulos') ?
62 this.getProductos() : 63 this.getProductos() :
63 this.setProductos(); 64 this.setProductos();
64 }); 65 });
65 } 66 }
66 67
67 getProductos() { 68 getProductos() {
68 this.articuloService.getAll() 69 this.articuloService.getAll()
69 .subscribe((result: IArticulo[]) => { 70 .subscribe((result: IArticulo[]) => {
70 this.articuloService.setArticulosSinImagen(result); 71 this.articuloService.setArticulosSinImagen(result);
71 if (this.queMostrar === 'ordenar') { 72 if (this.queMostrar === 'ordenar') {
72 this.categorias.forEach((categoria: ICategoria) => { 73 this.categorias.forEach((categoria: ICategoria) => {
73 const tempArticulos = result.filter((articulo: IArticulo) => { 74 const tempArticulos = result.filter((articulo: IArticulo) => {
74 return articulo.categoria_selfservice === categoria.id; 75 return articulo.categoria_selfservice === categoria.id;
75 }); 76 });
76 result = tempArticulos; 77 result = tempArticulos;
77 }); 78 });
78 } 79 }
79 localStorage.setItem('articulos', JSON.stringify(result)); 80 localStorage.setItem('articulos', JSON.stringify(result));
80 this.setProductos(); 81 this.setProductos();
81 }, (error) => { 82 }, (error) => {
82 this.showSpinner = false; 83 this.showSpinner = false;
83 console.error(error); 84 console.error(error);
84 }); 85 });
85 } 86 }
86 87
87 setProductos() { 88 setProductos() {
88 this.articulos = JSON.parse(localStorage.getItem('articulos')); 89 this.articulos = JSON.parse(localStorage.getItem('articulos'));
89 this.filterItems(); 90 this.filterItems();
90 } 91 }
91 92
92 filterItems() { 93 filterItems() {
93 if (this.categoriaActive === 0) { 94 if (this.categoriaActive === 0) {
94 this.auxArticulos = this.articulos; 95 this.auxArticulos = this.articulos;
95 return; 96 return;
96 } 97 }
97 this.auxArticulos = this.articulos.filter(x => { 98 this.auxArticulos = this.articulos.filter(x => {
98 return x.categoria_selfservice === this.categoriaActive; 99 return x.categoria_selfservice === this.categoriaActive;
99 }); 100 });
100 this.ordenar(); 101 this.ordenar();
101 } 102 }
102 103
103 ordenar() { 104 ordenar() {
104 if (this.ordenandoByVendidos) { 105 if (this.ordenandoByVendidos) {
105 this.auxArticulos.sort((a, b) => { 106 this.auxArticulos.sort((a, b) => {
106 return b.cantidadVendida - a.cantidadVendida; 107 return b.cantidadVendida - a.cantidadVendida;
107 }); 108 });
108 } 109 }
109 } 110 }
110 111
111 selectCategoria(index: number, idCategoria?: number) { 112 selectCategoria(index: number, idCategoria?: number) {
112 if (this.categoriaActive === idCategoria) return; 113 if (this.categoriaActive === idCategoria) return;
113 this.categoriaActive = idCategoria; 114 this.categoriaActive = idCategoria;
114 this.allActive = idCategoria === 0 ? true : false; 115 this.allActive = idCategoria === 0 ? true : false;
115 this.categorias.forEach((categoria, i) => { 116 this.categorias.forEach((categoria, i) => {
116 categoria.selected = index === i ? true : false; 117 categoria.selected = index === i ? true : false;
117 }); 118 });
118 this.filterItems(); 119 this.filterItems();
119 } 120 }
120 121
121 elegirArticulo(articulo: IArticulo) { 122 elegirArticulo(articulo: IArticulo) {
122 this.articuloService.getById(articulo.id) 123 this.articuloService.getById(articulo.id)
123 .subscribe((res: IArticulo) => { 124 .subscribe((res: IArticulo) => {
124 res.cantidad = 1; 125 res.cantidad = 1;
125 this.articuloService.setArticulo(res); 126 this.articuloService.setArticulo(res);
126 }, err => console.error(err)); 127 }, err => console.error(err));
127 } 128 }
128 129
129 increaseShow() { 130 increaseShow() {
130 this.showQuantity += 100; 131 this.showQuantity += 100;
131 } 132 }
132 133
133 mouseup() { 134 mouseup() {
134 if (!this.timeoutHandler) return; 135 if (!this.timeoutHandler) return;
135 clearInterval(this.timeoutHandler); 136 clearInterval(this.timeoutHandler);
136 } 137 }
137 138
138 scrollY(el: HTMLElement, value) { 139 scrollY(el: HTMLElement, value) {
139 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 140 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
140 this.timeoutHandler = setInterval(() => { 141 this.timeoutHandler = setInterval(() => {
141 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 142 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
142 }, 500); 143 }, 500);
143 } 144 }
144 145
145 scrollX(el: HTMLElement, value) { 146 scrollX(el: HTMLElement, value) {
146 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 147 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
147 this.timeoutHandler = setInterval(() => { 148 this.timeoutHandler = setInterval(() => {
148 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 149 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
149 }, 500); 150 }, 500);
150 } 151 }
151 } 152 }
152 153
src/app/modules/splash-screen/splash-screen.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 2
3 @Component({ 3 @Component({
4 selector: 'app-splash-screen', 4 selector: 'app-splash-screen',
5 templateUrl: './splash-screen.component.html', 5 templateUrl: './splash-screen.component.html',
6 styleUrls: ['./splash-screen.component.scss'] 6 styleUrls: ['./splash-screen.component.scss']
7 }) 7 })
8 export class SplashScreenComponent implements OnInit { 8 export class SplashScreenComponent implements OnInit {
9 timerSplashScreen = 2000; 9 timerSplashScreen = 2000;
10 showSplashScreen = true; 10 showSplashScreen = true;
11 textWelcome = 'BIENVENIDO A SPOT!'; 11 textWelcome = 'BIENVENIDO A SPOT!';
12 textComoEstas = '¿cómo estás?'; 12 textComoEstas = '¿cómo estás?';
13 textInvitamos = 'TE INVITAMOS A HACER'; 13 textInvitamos = 'TE INVITAMOS A HACER';
14 textTuPedido = 'tú pedido acá'; 14 textTuPedido = 'tu pedido acá';
15 15
16 constructor() { } 16 constructor() { }
17 17
18 ngOnInit() { 18 ngOnInit() {
19 setTimeout(() => { 19 setTimeout(() => {
20 this.showSplashScreen = false; 20 this.showSplashScreen = false;
21 }, this.timerSplashScreen); 21 }, this.timerSplashScreen);
22 } 22 }
23 23
24 } 24 }
25 25
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 = false; 14 esPromoPersonalizada = false;
15 urlDeboSuite = APP_SETTINGS.apiDeboSuite; 15 urlDeboSuite = APP_SETTINGS.apiDeboSuite;
16 medioPago: number; 16 medioPago: number;
17 idComanda: number; 17 idComanda: number;
18 subTotal: number = 0;
18 19
19 constructor( 20 constructor(
20 private http: HttpClient, 21 private http: HttpClient,
21 private clienteService: ClienteService, 22 private clienteService: ClienteService,
22 ) { } 23 ) { }
23 24
24 getById(id) { 25 getById(id) {
25 return this.http.get(`${this.urlDeboSuite}/articulos/${id}`); 26 return this.http.get(`${this.urlDeboSuite}/articulos/${id}`);
26 } 27 }
27 28
28 getAll() { 29 getAll() {
29 return this.http.get(`${this.urlDeboSuite}/articulos/`); 30 return this.http.get(`${this.urlDeboSuite}/articulos/`);
30 } 31 }
31 32
32 getAllWithPaginator(page: number = 1) { 33 getAllWithPaginator(page: number = 1) {
33 return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); 34 return this.http.get(`${this.urlDeboSuite}/articulos/${page}`);
34 } 35 }
35 36
37 calcularTotal() {
38 this.subTotal=0
39 this.carrito.forEach(articulo => {
40 this.subTotal += (articulo.PreVen * articulo.cantidad);
41 });
42 }
43
36 setArticulo(articulo: IArticulo) { 44 setArticulo(articulo: IArticulo) {
37 for (const articuloCarrito of this.carrito) { 45 for (const articuloCarrito of this.carrito) {
38 if (articuloCarrito.id === articulo.id) { 46 if (articuloCarrito.id === articulo.id) {
39 if (articulo.PRO) break; 47 if (articulo.PRO) break;
40 articuloCarrito.cantidad++; 48 articuloCarrito.cantidad++;
41 return; 49 return;
42 } 50 }
43 } 51 }
44 this.setArticulosSinImagen([articulo]); 52 this.setArticulosSinImagen([articulo]);
45 this.carrito.unshift(articulo); 53 this.carrito.unshift(articulo);
54 this.calcularTotal();
46 } 55 }
47 56
48 pay(dataPago: any) { 57 pay(dataPago: any) {
49 return new Observable((observer) => { 58 return new Observable((observer) => {
50 this.clienteService.getById(-1) 59 this.clienteService.getById(-1)
51 .subscribe(cliente => { 60 .subscribe(cliente => {
52 this.markArticuloInPromoAsRemoved(); 61 this.markArticuloInPromoAsRemoved();
53 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { 62 this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, {
54 productos: this.carrito, 63 productos: this.carrito,
55 cliente, 64 cliente,
56 origen: 'autoservicio', 65 origen: 'autoservicio',
57 codigoVendedor: 5, 66 codigoVendedor: 5,
58 puntoVenta: APP_SETTINGS.puntoVenta, 67 puntoVenta: APP_SETTINGS.puntoVenta,
59 pedidoAnombreDe: dataPago.pedidoAnombreDe, 68 pedidoAnombreDe: dataPago.pedidoAnombreDe,
60 numeroPlanilla: APP_SETTINGS.numeroPlanilla, 69 numeroPlanilla: APP_SETTINGS.numeroPlanilla,
61 }) 70 })
62 .subscribe((data) => { 71 .subscribe((data) => {
63 observer.next(data); 72 observer.next(data);
64 observer.complete(); 73 observer.complete();
65 }); 74 });
66 }); 75 });
67 }); 76 });
68 } 77 }
69 78
70 cleanShoppingCar() { 79 cleanShoppingCar() {
71 this.articuloAcargar = undefined; 80 this.articuloAcargar = undefined;
72 this.promoAcargar = undefined; 81 this.promoAcargar = undefined;
73 this.carrito = []; 82 this.carrito = [];
74 } 83 }
75 84
76 setArticulosSinImagen(articulos: IArticulo[]) { 85 setArticulosSinImagen(articulos: IArticulo[]) {
77 articulos.forEach((articulo: IArticulo) => { 86 articulos.forEach((articulo: IArticulo) => {
78 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : 87 articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] :
79 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; 88 !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes;
80 }); 89 });
81 } 90 }
82 91
83 markArticuloInPromoAsRemoved() { 92 markArticuloInPromoAsRemoved() {
84 this.carrito.forEach((articuloCarrito: IArticulo) => { 93 this.carrito.forEach((articuloCarrito: IArticulo) => {
85 if (articuloCarrito.PRO) { 94 if (articuloCarrito.PRO) {
86 articuloCarrito.productos.forEach((articulo: IArticulo) => { 95 articuloCarrito.productos.forEach((articulo: IArticulo) => {
87 if (articulo.cantidadAdicionada === 0) { 96 if (articulo.cantidadAdicionada === 0) {
88 articulo.cantidad = 0; 97 articulo.cantidad = 0;
89 articulo.importeValorExtra = 0; 98 articulo.importeValorExtra = 0;
90 } 99 }
91 }); 100 });
92 } 101 }
93 }); 102 });
94 } 103 }
95 } 104 }
96 105