123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import { Component } from '@angular/core';
- import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonAvatar, IonButton } from '@ionic/angular/standalone';
- import { ExploreContainerComponent } from '../explore-container/explore-container.component';
- import { addIcons } from 'ionicons';
- import { airplane, bluetooth, call, wifi } from 'ionicons/icons';
- import { ModalController } from '@ionic/angular';
- import { ArticleCardComponent } from '../component/article-card/article-card.component';
- import { CommonModule } from '@angular/common';
- import { CloudObject, CloudQuery } from 'src/lib/ncloud';
- addIcons({ airplane, bluetooth, call, wifi });
- interface Article {
- image: string;
- title: string;
- category: string;
- date: string;
- views: number;
- likes: number;
- }
- @Component({
- selector: 'app-tab2',
- templateUrl: 'tab2.page.html',
- styleUrls: ['tab2.page.scss'],
- standalone: true,
- imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
- IonLabel,IonItem,IonList,IonAvatar,ArticleCardComponent,CommonModule,IonButton,
- ]
- })
- export class Tab2Page {
- constructor() {
- }
- hotDot: Number = 0;
- changeTab0() {
- this.hotDot = 0;
- this.loadCards();
- }
- changeTab1() {
- this.hotDot = 1;
- this.loadCards();
- }
- changeTab2() {
- this.hotDot = 2;
- this.loadCards();
- }
- changeTab3() {
- this.hotDot = 3;
- this.loadCards();
- }
- changeTab4() {
- this.hotDot = 4;
- this.loadCards();
- }
- changeTab5() {
- this.hotDot = 5;
- this.loadCards();
- }
- cards: Array<CloudObject> = [];
- async loadCards() {
- let query = new CloudQuery('HotDot');
- query.equalTo('category', 'HotDot');
- // query.greaterThan('views', 1000); // 查询 views 大于 1000 的文章
- if (this.hotDot == 1) {
- }
- if (this.hotDot == 2) {
- }
- if (this.hotDot == 3) {
- }
- if (this.hotDot == 4) {
- query.equalTo('category', 'MaleHealth')
- }
- if (this.hotDot == 5) {
- query.equalTo("category", "FemaleHealth")
- }
- // query.greaterThan('views', 1000); // 查询 views 大于 1000 的文章
-
- this.cards = await query.find();
- console.log(this.cards);
- }
- ngOnInit() {
- this.loadCards();
- }
- }
|