tab2.page.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { Component, NgModule } from '@angular/core';
  2. import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonAvatar, IonButton, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView, IonCardContent, IonCardTitle, IonCardHeader, IonCard } 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 { IonicModule, 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. import { FormsModule } from '@angular/forms';
  11. import { NavigationLanComponent } from '../component/navigation-lan/navigation-lan.component';
  12. addIcons({ airplane, bluetooth, call, wifi });
  13. interface Article {
  14. image: string;
  15. title: string;
  16. category: string;
  17. date: string;
  18. views: number;
  19. likes: number;
  20. }
  21. @Component({
  22. selector: 'app-tab2',
  23. templateUrl: 'tab2.page.html',
  24. styleUrls: ['tab2.page.scss'],
  25. standalone: true,
  26. imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
  27. IonLabel,IonItem,IonList,IonAvatar,ArticleCardComponent,CommonModule,IonButton,
  28. IonSegment, IonSegmentButton,NavigationLanComponent,
  29. IonSegmentContent,IonSegmentView,IonCardContent, IonCardTitle, IonCardHeader,IonCard
  30. ]
  31. })
  32. export class Tab2Page {
  33. type:"hotdot"|"export"|"sleep"|"lift"|"male"|"female" = "hotdot"
  34. typeChange(ev:any){
  35. this.type = ev?.detail?.value || ev?.value || 'hotdot'
  36. console.log(this.type)
  37. }
  38. // constructor(private modalCtrl:ModalController) { }
  39. constructor() { }
  40. cards: Array<CloudObject> = [];
  41. async loadCards() {
  42. let query = new CloudQuery('HotDot');
  43. // query.equalTo('category', 'HotDot');
  44. // query.greaterThan('views', 1000); // 查询 views 大于 1000 的文章
  45. if (this.type == 'hotdot') {
  46. }
  47. if (this.type == 'hotdot') {
  48. }
  49. if (this.type == 'hotdot') {
  50. }
  51. if (this.type == 'male') {
  52. query.equalTo('category', 'MaleHealth')
  53. }
  54. if (this.type == 'female') {
  55. query.equalTo("category", "FemaleHealth")
  56. }
  57. // query.greaterThan('views', 1000); // 查询 views 大于 1000 的文章
  58. this.cards = await query.find();
  59. console.log(this.cards);
  60. }
  61. ngOnInit() {
  62. this.loadCards();
  63. }
  64. }