Project: Mall App Client: Maiora
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

mall-details.page.ts 1.8 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { Component, OnInit } from '@angular/core';
  2. import { ActivatedRoute, Router } from '@angular/router';
  3. import { Location } from '@angular/common';
  4. @Component({
  5. selector: 'app-mall-details',
  6. templateUrl: './mall-details.page.html',
  7. styleUrls: ['./mall-details.page.scss'],
  8. })
  9. export class MallDetailsPage implements OnInit {
  10. mallDetails: any;
  11. selected_tab: string = 'food';
  12. show_top_bar: boolean = false;
  13. show_sort_popup: boolean = false;
  14. selected_sort: string = null;
  15. constructor(
  16. private route: ActivatedRoute,
  17. private router: Router,
  18. private location: Location
  19. ) { }
  20. ngOnInit() {
  21. this.mallDetails = JSON.parse(this.route.snapshot.paramMap.get('mall'));
  22. }
  23. back() {
  24. this.location.back();
  25. }
  26. onScroll(event: any) {
  27. if (event.detail.scrollTop > 100) {
  28. this.show_top_bar = true;
  29. } else {
  30. this.show_top_bar = false;
  31. }
  32. }
  33. outletDetails(outlet: any) {
  34. this.router.navigate(['/outlet-details', {
  35. outlet: JSON.stringify(outlet),
  36. mallId: this.mallDetails.mall.mall_id
  37. }]);
  38. }
  39. sortBy(type: string) {
  40. this.selected_sort = type;
  41. switch(this.selected_sort) {
  42. case 'name': this.mallDetails.mall.outlet.sort(function(a: any, b: any){
  43. if(a.outlet_name < b.outlet_name) { return -1; }
  44. if(a.outlet_name > b.outlet_name) { return 1; }
  45. return 0;
  46. });
  47. break;
  48. case 'rating': this.mallDetails.mall.outlet.sort(function(a: any, b: any){
  49. if(a.rating < b.rating) { return -1; }
  50. if(a.rating > b.rating) { return 1; }
  51. return 0;
  52. }).reverse();
  53. break;
  54. }
  55. }
  56. togglePopup() {
  57. this.show_sort_popup = !this.show_sort_popup;
  58. }
  59. }