tab1.page.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { Component } from '@angular/core';
  2. import Swiper from 'swiper';
  3. @Component({
  4. selector: 'app-tab1',
  5. templateUrl: 'tab1.page.html',
  6. styleUrls: ['tab1.page.scss']
  7. })
  8. export class Tab1Page {
  9. // 上方轮播图
  10. public attractions = [
  11. { image: "https://tse3-mm.cn.bing.net/th/id/OIP-C.5HjektOIikSBU1vw0JVKwgHaE8?w=305&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7", name: '景点1' },
  12. { image: "https://tse3-mm.cn.bing.net/th/id/OIP-C.5HjektOIikSBU1vw0JVKwgHaE8?w=305&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7", name: '景点2' },
  13. { image: "https://tse3-mm.cn.bing.net/th/id/OIP-C.5HjektOIikSBU1vw0JVKwgHaE8?w=305&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7", name: '景点3' }
  14. ];
  15. //多图标卡片
  16. cards = [
  17. { icon: 'map-outline', title: '找攻略' },
  18. { icon: 'flame-outline', title: '当季热门' },
  19. { icon: 'newspaper-outline', title: '看游记' },
  20. { icon: 'people-outline', title: '找搭子' },
  21. { icon: 'bed-outline', title: '订酒店' },
  22. { icon: 'happy-outline', title: '亲子游' },
  23. { icon: 'car-outline', title: '自驾游' },
  24. { icon: 'flag-outline', title: '国内游' },
  25. { icon: 'airplane-outline', title: '海外游' },
  26. { icon: 'compass-outline', title: '周边游' }
  27. ];
  28. chunkedCards: any[] = [];
  29. constructor() {
  30. this.chunkSize(this.cards);
  31. }
  32. chunkSize(cards: any[]) {
  33. const chunkSize: number = 5;
  34. this.chunkedCards = [];
  35. for (let i: number = 0; i < cards.length; i += chunkSize) {
  36. this.chunkedCards.push(cards.slice(i, i + chunkSize));
  37. }
  38. }
  39. ngOnInit() {
  40. const swiper = new Swiper('.swiper-container', {
  41. navigation: {
  42. nextEl: '.swiper-button-next',
  43. prevEl: '.swiper-button-prev',
  44. },
  45. });
  46. }
  47. }