Browse Source

跳转电影筛选界面

Breeze 4 months ago
parent
commit
71399a9543

+ 42 - 0
serve/case/promise.js

@@ -0,0 +1,42 @@
+
+async function main(){
+    // setTimeout(() => {
+    //     console.log(1)
+    // }, 500);
+    // setTimeout(() => {
+    //     console.log(2)
+    // }, 200);
+    // setTimeout(() => {
+    //     console.log(3)
+    // }, 100);
+    // setTimeout(() => {
+    //     console.log(4)
+    // }, 1000);
+    // return
+
+    // waitSeconds(500,()=>{console.log(1)}) // 500
+    // waitSeconds(200,()=>{console.log(2)}) // 700
+    // waitSeconds(100,()=>{console.log(3)}) // 800
+    // waitSeconds(1000,()=>{console.log(4)}) // 1800
+    // return
+    
+    let res1 = await waitSeconds(500,()=>{console.log(1)}) // 500
+    console.log(res1)
+    let res2 = await waitSeconds(200,()=>{console.log(2)}) // 700
+    console.log(res2)
+    let res3 = await waitSeconds(100,()=>{console.log(3)}) // 800
+    console.log(res3)
+    let res4 = await waitSeconds(1000,()=>{console.log(4)}) // 1800
+    console.log(res4)
+}
+
+function waitSeconds(duration,handle) {
+    return new Promise((resolve, reject) => {
+        setTimeout(() => {
+            handle()
+            resolve(`等待了${duration}ms`);
+        }, duration);
+    });
+}
+
+main()

+ 110 - 0
serve/fmode-pares.js

@@ -0,0 +1,110 @@
+class ParseObject{
+    className
+    id
+    serverURL = "http://web2023.fmode.cn:9999/parse"
+    data = {}
+    toJSON(){
+        return this.data
+    }
+    constructor(className){
+        this.className = className
+    }
+    async get(id){
+        let response = await fetch(this.serverURL+"/classes/"+this.className+"/"+id, {
+            "headers": {
+                "x-parse-application-id": "dev"
+              },
+            "body": null,
+            "method": "GET",
+            "mode": "cors",
+            "credentials": "omit"
+          });
+          if(response?.status=="200"){
+            let json = await response.json()
+            this.id = json?.objectId;
+            delete json.objectId
+            delete json.createdAt
+            delete json.updatedAt
+            this.data = json;
+            return this
+          }else{
+            return []
+          }
+    }
+    async findAll(){
+        let response = await fetch(this.serverURL+"/classes/"+this.className, {
+            "headers": {
+                "x-parse-application-id": "dev"
+              },
+            "body": null,
+            "method": "GET",
+            "mode": "cors",
+            "credentials": "omit"
+          });
+          // console.log(response)
+          // return []
+          if(response?.status=="200"){
+            let json = await response.json()
+            // console.log(json)
+            return json?.results || []
+          }else{
+            return []
+          }
+    }
+    set(data){
+        this.data = data
+    }
+    async save(){
+        let body = JSON.stringify(this.data)
+        let url = this.serverURL+"/classes/"+this.className // 创建URL
+        let method = "POST"
+        if(this.id){
+            url = url + "/" + this.id // 更新URL
+            method = "PUT"
+        }
+        console.log(url,method,body)
+        let response = await fetch(url, {
+            "headers": {
+                // "content-type": "text/plain;charset=UTF-8",
+                "x-parse-application-id": "dev"
+            },
+            "body": body,
+            "method": method,
+            "mode": "cors",
+            "credentials": "omit"
+        });
+        console.log(body)
+        let text = await response?.text();
+        console.log(text)
+        let json = await response?.json();
+        if(json?.objectId){
+            console.log(json)
+            this.id = json?.objectId
+            return this
+        }else{
+            return null
+        }
+    }
+    async delete(){
+        let response = await fetch(this.serverURL+"/classes/"+this.className+"/"+id, {
+            "headers": {
+                "x-parse-application-id": "dev"
+              },
+            "body": null,
+            "method": "DELETE",
+            "mode": "cors",
+            "credentials": "omit"
+          });
+          if(response?.status=="200"){
+            let json = await response.json()
+            return json
+          }else{
+            return []
+          }
+    }
+}
+module.exports.ParseObject = ParseObject
+
+class ParseQuery{
+    
+}

+ 112 - 0
serve/rest.js

@@ -0,0 +1,112 @@
+
+// Pet GET 获取全部宠物
+async function getPet(){
+    let response = await fetch("http://web2023.fmode.cn:9999/parse/classes/Pet?", {
+      "headers": {
+        "accept": "*/*",
+        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+        "if-none-match": "W/\"19f-gvNjdCzTNrgDv/sckM9+BRABBVY\"",
+        "x-parse-application-id": "dev"
+      },
+      "referrer": "http://127.0.0.1:4040/",
+      "referrerPolicy": "strict-origin-when-cross-origin",
+      "body": null,
+      "method": "GET",
+      "mode": "cors",
+      "credentials": "omit"
+    });
+    // console.log(response)
+    // return []
+    if(response?.status=="200"){
+      let json = await response.json()
+      // console.log(json)
+      return json?.results || []
+    }else{
+      return []
+    }
+  }
+  
+  async function main(){
+    // let petList = await getPet()
+    // console.log(petList)
+    // let list = await ClassesGet("Pet")
+    // console.log(list)
+  
+    let list = await ClassesGet("Student")
+    console.log(list)
+  }
+  main()
+  
+  // 通过函数封装,实现多个表的查询
+  async function ClassesGet(className){
+    let response = await fetch("http://web2023.fmode.cn:9999/parse/classes/"+className, {
+      "headers": {
+        "accept": "*/*",
+        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+        "if-none-match": "W/\"19f-gvNjdCzTNrgDv/sckM9+BRABBVY\"",
+        "x-parse-application-id": "dev"
+      },
+      "referrer": "http://127.0.0.1:4040/",
+      "referrerPolicy": "strict-origin-when-cross-origin",
+      "body": null,
+      "method": "GET",
+      "mode": "cors",
+      "credentials": "omit"
+    });
+    // console.log(response)
+    // return []
+    if(response?.status=="200"){
+      let json = await response.json()
+      // console.log(json)
+      return json?.results || []
+    }else{
+      return []
+    }
+  }
+  
+  // // Pet POST 创建宠物
+  // fetch("http://web2023.fmode.cn:9999/parse/classes/Pet", {
+  //   "headers": {
+  //     "accept": "*/*",
+  //     "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+  //     "content-type": "text/plain;charset=UTF-8",
+  //     "x-parse-application-id": "dev"
+  //   },
+  //   "referrer": "http://127.0.0.1:4040/",
+  //   "referrerPolicy": "strict-origin-when-cross-origin",
+  //   "body": '{"name":"小强","type":"蟑螂","price":0.2}',
+  //   "method": "POST",
+  //   "mode": "cors",
+  //   "credentials": "omit"
+  // });
+  
+  // // Pet PUT 修改
+  // fetch("http://web2023.fmode.cn:9999/parse/classes/Pet/bl34OtuBYm", {
+  //   "headers": {
+  //     "accept": "*/*",
+  //     "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+  //     "content-type": "text/plain;charset=UTF-8",
+  //     "x-parse-application-id": "dev"
+  //   },
+  //   "referrer": "http://127.0.0.1:4040/",
+  //   "referrerPolicy": "strict-origin-when-cross-origin",
+  //   "body": "{\"price\":0.09}",
+  //   "method": "PUT",
+  //   "mode": "cors",
+  //   "credentials": "omit"
+  // });
+  
+  // // Pet DELETE 删除
+  // fetch("http://web2023.fmode.cn:9999/parse/classes/Pet/bl34OtuBYm", {
+  //   "headers": {
+  //     "accept": "*/*",
+  //     "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+  //     "x-parse-application-id": "dev"
+  //   },
+  //   "referrer": "http://127.0.0.1:4040/",
+  //   "referrerPolicy": "strict-origin-when-cross-origin",
+  //   "body": null,
+  //   "method": "DELETE",
+  //   "mode": "cors",
+  //   "credentials": "omit"
+  // });

+ 3 - 0
src/app/app-routing.module.ts

@@ -9,6 +9,9 @@ const routes: Routes = [
   {
   {
     path: 'setting',
     path: 'setting',
     loadChildren: () => import('./setting/setting.module').then(m => m.SettingPageModule)
     loadChildren: () => import('./setting/setting.module').then(m => m.SettingPageModule)
+  },{
+    path: 'smovies',
+    loadChildren: () => import('./tab2/smovies/smovies.module').then( m => m.SMoviesPageModule)
   }
   }
 ];
 ];
 @NgModule({
 @NgModule({

+ 17 - 0
src/app/tab2/smovies/smovies-routing.module.ts

@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+
+import { SMoviesPage } from './smovies.page';
+
+const routes: Routes = [
+  {
+    path: '',
+    component: SMoviesPage
+  }
+];
+
+@NgModule({
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule],
+})
+export class SMoviesPageRoutingModule {}

+ 20 - 0
src/app/tab2/smovies/smovies.module.ts

@@ -0,0 +1,20 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+
+import { IonicModule } from '@ionic/angular';
+
+import { SMoviesPageRoutingModule } from './smovies-routing.module';
+
+import { SMoviesPage } from './smovies.page';
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    SMoviesPageRoutingModule
+  ],
+  declarations: [SMoviesPage]
+})
+export class SMoviesPageModule {}

+ 13 - 0
src/app/tab2/smovies/smovies.page.html

@@ -0,0 +1,13 @@
+<ion-header [translucent]="true">
+  <ion-toolbar>
+    <ion-title>SMovies</ion-title>
+  </ion-toolbar>
+</ion-header>
+
+<ion-content [fullscreen]="true">
+  <ion-header collapse="condense">
+    <ion-toolbar>
+      <ion-title size="large">SMovies</ion-title>
+    </ion-toolbar>
+  </ion-header>
+</ion-content>

+ 0 - 0
src/app/tab2/smovies/smovies.page.scss


+ 17 - 0
src/app/tab2/smovies/smovies.page.spec.ts

@@ -0,0 +1,17 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { SMoviesPage } from './smovies.page';
+
+describe('SMoviesPage', () => {
+  let component: SMoviesPage;
+  let fixture: ComponentFixture<SMoviesPage>;
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(SMoviesPage);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 18 - 0
src/app/tab2/smovies/smovies.page.ts

@@ -0,0 +1,18 @@
+import { Component, OnInit } from '@angular/core';
+import { NavController } from '@ionic/angular';
+
+@Component({
+  selector: 'app-smovies',
+  templateUrl: './smovies.page.html',
+  styleUrls: ['./smovies.page.scss'],
+})
+export class SMoviesPage implements OnInit {
+
+  constructor(private navCtrl: NavController) {}
+
+  goToBlankPage() {
+    // 导航到空白页面
+    console.log('Navigating to Blank page');
+  }
+  ngOnInit() {}
+}

+ 5 - 1
src/app/tab2/tab2-routing.module.ts

@@ -6,7 +6,11 @@ const routes: Routes = [
   {
   {
     path: '',
     path: '',
     component: Tab2Page,
     component: Tab2Page,
-  }
+  },
+  // {
+  //   path: 'smovies',
+  //   loadChildren: () => import('./smovies/smovies.module').then( m => m.SMoviesPageModule)
+  // }
 ];
 ];
 
 
 @NgModule({
 @NgModule({

+ 13 - 13
src/app/tab2/tab2.page.html

@@ -25,36 +25,36 @@
       <ion-row>
       <ion-row>
         <ion-col size="13">
         <ion-col size="13">
               <ion-row>
               <ion-row>
-                <ion-col (click)="goToBlankPage()">电影</ion-col>
-                <ion-col (click)="goToBlankPage()">电视</ion-col>
-                <ion-col (click)="goToBlankPage()">经典</ion-col>
-                <ion-col (click)="goToBlankPage()">新片</ion-col>
+                <ion-col (click)="goToSMovies()">电影</ion-col>
+                <ion-col (click)="goToSMovies()">电视</ion-col>
+                <ion-col (click)="goToSMovies()">经典</ion-col>
+                <ion-col (click)="goToSMovies()">新片</ion-col>
               </ion-row>
               </ion-row>
         </ion-col>
         </ion-col>
       </ion-row>
       </ion-row>
       <ion-row>
       <ion-row>
         <ion-col size="13">
         <ion-col size="13">
               <ion-row>
               <ion-row>
-                <ion-col (click)="goToBlankPage()">中国大陆</ion-col>
-                <ion-col (click)="goToBlankPage()">中国香港</ion-col>
-                <ion-col (click)="goToBlankPage()">美国</ion-col>
-                <ion-col (click)="goToBlankPage()">英国</ion-col>
+                <ion-col (click)="goToSMovies()">中国大陆</ion-col>
+                <ion-col (click)="goToSMovies()">中国香港</ion-col>
+                <ion-col (click)="goToSMovies()">美国</ion-col>
+                <ion-col (click)="goToSMovies()">英国</ion-col>
               </ion-row>
               </ion-row>
         </ion-col>
         </ion-col>
       </ion-row>
       </ion-row>
       <ion-row>
       <ion-row>
         <ion-col size="13">
         <ion-col size="13">
               <ion-row>
               <ion-row>
-                <ion-col (click)="goToBlankPage()">爱情</ion-col>
-                <ion-col (click)="goToBlankPage()">动作</ion-col>
-                <ion-col (click)="goToBlankPage()">喜剧</ion-col>
-                <ion-col (click)="goToBlankPage()">科幻</ion-col>
+                <ion-col (click)="goToSMovies()">爱情</ion-col>
+                <ion-col (click)="goToSMovies()">动作</ion-col>
+                <ion-col (click)="goToSMovies()">喜剧</ion-col>
+                <ion-col (click)="goToSMovies()">科幻</ion-col>
               </ion-row>
               </ion-row>
         </ion-col>
         </ion-col>
       </ion-row>
       </ion-row>
       <ion-row>
       <ion-row>
         <ion-col size="12">
         <ion-col size="12">
-          <ion-button expand="full" color="light" shape="round" (click)="goToBlankPage()">more ></ion-button>
+          <ion-button expand="full" color="light" shape="round" (click)="goToSMovies()">more ></ion-button>
         </ion-col>
         </ion-col>
       </ion-row>
       </ion-row>
     </ion-card-content>
     </ion-card-content>

+ 6 - 0
src/app/tab2/tab2.page.ts

@@ -17,6 +17,12 @@ export class Tab2Page {
     // 导航到空白页面
     // 导航到空白页面
     console.log('Navigating to Blank page');
     console.log('Navigating to Blank page');
   }
   }
+
+  goToSMovies() {
+    this.router.navigate(['/smovies']); // 替换成你的 setting 页面路由路径
+  }
+
+
   search() {
   search() {
     // this.router.navigate(['/blank-page']); // 替换成你的空白页面路由路径
     // this.router.navigate(['/blank-page']); // 替换成你的空白页面路由路径
     // 导航到空白页面
     // 导航到空白页面