tab2.page.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { Component } from '@angular/core';
  2. import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonAvatar, IonButton } from '@ionic/angular/standalone';
  3. import { ExploreContainerComponent } from '../explore-container/explore-container.component';
  4. import { addIcons } from 'ionicons';
  5. import { airplane, bluetooth, call, wifi } from 'ionicons/icons';
  6. import { ModalController } from '@ionic/angular';
  7. import { ArticleCardComponent } from '../component/article-card/article-card.component';
  8. import { CommonModule } from '@angular/common';
  9. import { CloudObject, CloudQuery } from 'src/lib/ncloud';
  10. addIcons({ airplane, bluetooth, call, wifi });
  11. interface Article {
  12. image: string;
  13. title: string;
  14. category: string;
  15. date: string;
  16. views: number;
  17. likes: number;
  18. }
  19. @Component({
  20. selector: 'app-tab2',
  21. templateUrl: 'tab2.page.html',
  22. styleUrls: ['tab2.page.scss'],
  23. standalone: true,
  24. imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
  25. IonLabel,IonItem,IonList,IonAvatar,ArticleCardComponent,CommonModule,IonButton,
  26. ]
  27. })
  28. export class Tab2Page {
  29. constructor() {
  30. }
  31. hotDot: Number = 0;
  32. changeTab0() {
  33. this.hotDot = 0;
  34. this.loadCards();
  35. }
  36. changeTab1() {
  37. this.hotDot = 1;
  38. this.loadCards();
  39. }
  40. changeTab2() {
  41. this.hotDot = 2;
  42. this.loadCards();
  43. }
  44. changeTab3() {
  45. this.hotDot = 3;
  46. this.loadCards();
  47. }
  48. changeTab4() {
  49. this.hotDot = 4;
  50. this.loadCards();
  51. }
  52. changeTab5() {
  53. this.hotDot = 5;
  54. this.loadCards();
  55. }
  56. cards: Array<CloudObject> = [];
  57. async loadCards() {
  58. let query = new CloudQuery('HotDot');
  59. query.equalTo('category', 'HotDot');
  60. // query.greaterThan('views', 1000); // 查询 views 大于 1000 的文章
  61. if (this.hotDot == 1) {
  62. }
  63. if (this.hotDot == 2) {
  64. }
  65. if (this.hotDot == 3) {
  66. }
  67. if (this.hotDot == 4) {
  68. query.equalTo('category', 'MaleHealth')
  69. }
  70. if (this.hotDot == 5) {
  71. query.equalTo("category", "FemaleHealth")
  72. }
  73. // query.greaterThan('views', 1000); // 查询 views 大于 1000 的文章
  74. this.cards = await query.find();
  75. console.log(this.cards);
  76. }
  77. ngOnInit() {
  78. this.loadCards();
  79. }
  80. }