import { Component, OnInit } from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {PublicService} from '../PublicService'; import {LoadingController, NavController} from '@ionic/angular'; import {Constants} from '../Constant'; @Component({ selector: 'app-search', templateUrl: './search.page.html', styleUrls: ['./search.page.scss'], }) export class SearchPage implements OnInit { private searchKey = this.route.snapshot.queryParams.searchKey; private searchResult = []; constructor(private readonly route: ActivatedRoute, public readonly router: Router, private readonly navController: NavController, private readonly loadingCtrl: LoadingController, private readonly publicService: PublicService) { } ngOnInit() { this.toSearch(); } async toSearch() { const load = await this.publicService.showLoading(this.loadingCtrl, '数据加载中...'); const param = { pageNum: 1, pageSize: 10, param: { keyWord: this.searchKey } }; this.publicService.queryAppPublish(param).then(res => { load.dismiss(); if (res.code === Constants.SUCCESS){ this.searchResult = res.data.result; }else{ this.publicService.presentToast(res.msg); } }, err => { load.dismiss(); this.publicService.checkNetworkToast(err); }); } selectItem(item){ this.router.navigate(['/detail'], { queryParams: item }); } back(){ this.navController.back(); } }