|
@@ -1,8 +1,15 @@
|
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
-import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
|
|
+import { Component, ElementRef, OnInit, ViewChild,ChangeDetectorRef } from '@angular/core';
|
|
|
|
|
|
import Swiper from 'swiper';
|
|
|
+import Parse from 'parse';
|
|
|
+import { FilmService } from 'src/modules/server/firm.serve';
|
|
|
+import { BookService } from 'src/modules/server/book.serve';
|
|
|
+import { MusicService } from 'src/modules/server/music.serve';
|
|
|
+import { GameService } from 'src/modules/server/game.serve';
|
|
|
+import { OutdoorService } from 'src/modules/server/outdoor.serve';
|
|
|
+
|
|
|
@Component({
|
|
|
selector: 'app-tab1',
|
|
|
templateUrl: 'tab1.page.html',
|
|
@@ -12,8 +19,20 @@ import Swiper from 'swiper';
|
|
|
|
|
|
export class Tab1Page implements OnInit {
|
|
|
|
|
|
+
|
|
|
@ViewChild("slide1Comp") slide1Comp:ElementRef |undefined
|
|
|
- constructor() { }
|
|
|
+
|
|
|
+
|
|
|
+ constructor(private cdr: ChangeDetectorRef,
|
|
|
+ private filmService: FilmService,
|
|
|
+ private router: Router,
|
|
|
+ private bookService: BookService,
|
|
|
+ private musicService: MusicService,
|
|
|
+ private gameService: GameService,
|
|
|
+ private outdoorService: OutdoorService,
|
|
|
+ ) { }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
ngOnInit() {
|
|
|
// 延迟500毫秒加载
|
|
@@ -45,7 +64,121 @@ export class Tab1Page implements OnInit {
|
|
|
},1000)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ filmsearchResults: any[] = [];
|
|
|
+ booksearchResults: any[] = [];
|
|
|
+ gamesearchResults: any[] = [];
|
|
|
+ musicsearchResults: any[] = [];
|
|
|
+ outdoorsearchResults: any[] = [];
|
|
|
+ searchTerm: string = '';
|
|
|
+ searchName: string = '';
|
|
|
+
|
|
|
+ async search(){
|
|
|
+ const queryParams = {
|
|
|
+ name: this.searchTerm
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ this.filmsearchResults=await this.filmService.searchFilm(queryParams);
|
|
|
+ this.booksearchResults=await this.bookService.getBooks(queryParams);
|
|
|
+ this.musicsearchResults=await this.musicService.getMusics(queryParams);
|
|
|
+ this.gamesearchResults=await this.gameService.getGames(queryParams);
|
|
|
+ this.outdoorsearchResults=await this.outdoorService.getOutdoors(queryParams);
|
|
|
+
|
|
|
+ const keywords = ['影', '视', '影片']; // 定义多个关键词
|
|
|
+ if (keywords.some(keyword => this.searchTerm.toLowerCase().includes(keyword))) {
|
|
|
+ this.router.navigate(['/feiwu/fiml']); // 如果包含任何一个关键词,则跳转到“影视”界面
|
|
|
+ }
|
|
|
+ const keywords2 = ['书', '小说']; // 定义多个关键词
|
|
|
+ if (keywords2.some(keyword2 => this.searchTerm.toLowerCase().includes(keyword2))) {
|
|
|
+ this.router.navigate(['/feiwu/book']); // 如果包含任何一个关键词,则跳转到“影视”界面
|
|
|
+ }
|
|
|
+ const keywords3 = ['音乐', '歌', '曲','听']; // 定义多个关键词
|
|
|
+ if (keywords3.some(keyword3 => this.searchTerm.toLowerCase().includes(keyword3))) {
|
|
|
+ this.router.navigate(['/feiwu/music']); // 如果包含任何一个关键词,则跳转到“影视”界面
|
|
|
+ }
|
|
|
+ const keywords4 = ['游戏', '玩']; // 定义多个关键词
|
|
|
+ if (keywords4.some(keyword4 => this.searchTerm.toLowerCase().includes(keyword4))) {
|
|
|
+ this.router.navigate(['/feiwu/game']); // 如果包含任何一个关键词,则跳转到“影视”界面
|
|
|
+ }
|
|
|
+ const keywords5 = ['运动', '户外', '锻炼','健']; // 定义多个关键词
|
|
|
+ if (keywords5.some(keyword5=> this.searchTerm.toLowerCase().includes(keyword5))) {
|
|
|
+ this.router.navigate(['/feiwu/outdoor']); // 如果包含任何一个关键词,则跳转到“影视”界面
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(!this.searchTerm)
|
|
|
+ {
|
|
|
+ this.filmsearchResults = []
|
|
|
+ this.booksearchResults = []
|
|
|
+ this.gamesearchResults = []
|
|
|
+ this.musicsearchResults = []
|
|
|
+ this.outdoorsearchResults =[]
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // async search(keyword: string) {
|
|
|
+ // const Film = Parse.Object.extend('Film');
|
|
|
+ // const LQLBook = Parse.Object.extend('LQLBook');
|
|
|
+ // const LQLGame = Parse.Object.extend('LQLGame');
|
|
|
+ // const LQLMusic = Parse.Object.extend('LQLMusic');
|
|
|
+ // const LQLOutdoor = Parse.Object.extend('LQLOutdoor');
|
|
|
+
|
|
|
+ // const filmQuery = new Parse.Query(Film);
|
|
|
+ // const bookQuery = new Parse.Query(LQLBook);
|
|
|
+ // const gameQuery = new Parse.Query(LQLGame);
|
|
|
+ // const musicQuery = new Parse.Query(LQLMusic);
|
|
|
+ // const outdoorQuery = new Parse.Query(LQLOutdoor);
|
|
|
+
|
|
|
+ // filmQuery.startsWith('name', keyword);
|
|
|
+ // bookQuery.startsWith('name', keyword);
|
|
|
+ // gameQuery.startsWith('name', keyword);
|
|
|
+ // musicQuery.startsWith('name', keyword);
|
|
|
+ // outdoorQuery.startsWith('name', keyword);
|
|
|
+
|
|
|
+ // const filmresults = await filmQuery.find();
|
|
|
+ // const bookresults = await bookQuery.find();
|
|
|
+ // const gameresults = await gameQuery.find();
|
|
|
+ // const musicresults = await musicQuery.find();
|
|
|
+ // const outdoorresults = await outdoorQuery.find();
|
|
|
+
|
|
|
+ // this.filmsearchResults = filmresults.map(filmresult => filmresult.toJSON());
|
|
|
+ // this.booksearchResults = bookresults.map(bookresult => bookresult.toJSON());
|
|
|
+ // this.gamesearchResults = gameresults.map(gameresult => gameresult.toJSON());
|
|
|
+ // this.musicsearchResults = musicresults.map(musicresult => musicresult.toJSON());
|
|
|
+ // this.outdoorsearchResults = outdoorresults.map(outdoorresult => outdoorresult.toJSON());
|
|
|
+
|
|
|
+
|
|
|
+ // if(!this.searchTerm)
|
|
|
+ // {
|
|
|
+ // this.filmsearchResults = []
|
|
|
+ // this.booksearchResults = []
|
|
|
+ // this.gamesearchResults = []
|
|
|
+ // this.musicsearchResults = []
|
|
|
+ // this.outdoorsearchResults =[]
|
|
|
+ // }
|
|
|
+ // this.cdr.detectChanges();
|
|
|
+ // }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function searchContent(event: Event | undefined, CustomEvent: { new <T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>; prototype: CustomEvent; }) {
|
|
|
+ throw new Error('Function not implemented.');
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|