Delancey 3 ヶ月 前
コミット
e0edd9ae9e

+ 15 - 0
travel-app/src/app/tab3/tab3.page.html

@@ -13,5 +13,20 @@
     </ion-toolbar>
   </ion-header>
 
+  <div class="chat-container">
+    <ion-list>
+      <ion-item *ngFor="let message of messages" class="chat-message">
+        <ion-label>{{ message.sender }}: {{ message.text }}</ion-label>
+      </ion-item>
+    </ion-list>
+  </div>
+
+  <ion-footer>
+    <ion-toolbar>
+      <ion-input [(ngModel)]="userMessage" placeholder="Type a message..."></ion-input>
+      <ion-button (click)="sendMessage()" fill="clear" color="primary">Send</ion-button>
+    </ion-toolbar>
+  </ion-footer>
+  
   <app-explore-container name="Tab 3 page"></app-explore-container>
 </ion-content>

+ 31 - 0
travel-app/src/app/tab3/tab3.page.scss

@@ -0,0 +1,31 @@
+.chat-container {
+    background-color: #e8f5e9; // Light green background
+    height: 100%;
+    padding: 16px;
+    ion-list {
+      background-color: #fff;
+      border-radius: 8px;
+      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+      margin-bottom: 16px;
+    }
+    .chat-message {
+      --background: #fff;
+      ion-label {
+        color: #212121; // Dark text color
+      }
+    }
+  }
+  
+  ion-footer {
+    ion-toolbar {
+      ion-input {
+        --background: #fff;
+        border-radius: 4px;
+        margin-right: 8px;
+      }
+      ion-button {
+        height: 100%;
+      }
+    }
+  }
+  

+ 24 - 2
travel-app/src/app/tab3/tab3.page.ts

@@ -1,5 +1,5 @@
 import { Component } from '@angular/core';
-import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
+import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonFooter, IonButton } from '@ionic/angular/standalone';
 import { ExploreContainerComponent } from '../explore-container/explore-container.component';
 
 @Component({
@@ -7,8 +7,30 @@ import { ExploreContainerComponent } from '../explore-container/explore-containe
   templateUrl: 'tab3.page.html',
   styleUrls: ['tab3.page.scss'],
   standalone: true,
-  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent],
+  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
+    IonList, IonItem, IonFooter,IonButton
+  ],
 })
 export class Tab3Page {
+  
+  userMessage: string = '';
+  messages: any[] = [];
+
   constructor() {}
+
+  sendMessage() {
+    if (this.userMessage.trim() !== '') {
+      this.messages.push({ sender: 'You', text: this.userMessage });
+      // Here you would typically send the message to the server and get a response
+      // For this example, we'll just simulate a response
+      this.simulateAIResponse(this.userMessage);
+      this.userMessage = '';
+    }
+  }
+
+  simulateAIResponse(message: string) {
+    setTimeout(() => {
+      this.messages.push({ sender: 'AI', text: `Received your message: ${message}` });
+    }, 1000);
+  }
 }

+ 20 - 0
travel-app/src/app/tab4/tab4.page.html

@@ -12,6 +12,26 @@
       <ion-title size="large">Tab 4</ion-title>
     </ion-toolbar>
   </ion-header>
+  <ion-list>
+    <ion-item>
+      <ion-avatar slot="start">
+        <img src="assets/img/头像.jpg">
+      </ion-avatar>
+      <ion-label>
+        <h2>{{ user.name }}</h2>
+        <p>{{ user.email }}</p>
+      </ion-label>
+    </ion-item>
+    <ion-item detail="true" (click)="editProfile()">
+      编辑个人资料
+    </ion-item>
+    <ion-item detail="true" (click)="viewSettings()">
+      设置
+    </ion-item>
+    <ion-item detail="true" (click)="logout()">
+      退出登录
+    </ion-item>
+  </ion-list>
 
   <app-explore-container name="Tab 4 page"></app-explore-container>
 </ion-content>

+ 13 - 0
travel-app/src/app/tab4/tab4.page.scss

@@ -0,0 +1,13 @@
+ion-content {
+    ion-list {
+      ion-item {
+        --ion-item-background: #f5f5f5;
+        --ion-item-border-color: #ddd;
+        
+        ion-avatar img {
+          border-radius: 50%;
+        }
+      }
+    }
+  }
+  

+ 1 - 1
travel-app/src/app/tab4/tab4.page.spec.ts

@@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { Tab4Page } from './tab4.page';
 
-describe('Tab3Page', () => {
+describe('Tab4Page', () => {
   let component: Tab4Page;
   let fixture: ComponentFixture<Tab4Page>;
 

+ 28 - 3
travel-app/src/app/tab4/tab4.page.ts

@@ -1,5 +1,5 @@
 import { Component } from '@angular/core';
-import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
+import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonAvatar, NavController } from '@ionic/angular/standalone';
 import { ExploreContainerComponent } from '../explore-container/explore-container.component';
 
 @Component({
@@ -7,8 +7,33 @@ import { ExploreContainerComponent } from '../explore-container/explore-containe
   templateUrl: 'tab4.page.html',
   styleUrls: ['tab4.page.scss'],
   standalone: true,
-  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent],
+  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
+    IonList, IonItem, IonLabel, IonAvatar],
 })
 export class Tab4Page {
-  constructor() {}
+  
+
+  user: any = {
+    name: '张三',
+    email: 'zhangsan@example.com'
+  };
+
+  constructor(private navCtrl: NavController) {}
+
+  editProfile() {
+    // Navigate to the edit profile page
+    this.navCtrl.navigateForward('/edit-profile');
+  }
+
+  viewSettings() {
+    // Navigate to the settings page
+    this.navCtrl.navigateForward('/settings');
+  }
+
+  logout() {
+    // Perform logout actions
+    // For example, clear user data and navigate to the login page
+    // localStorage.removeItem('user');
+    this.navCtrl.navigateRoot('/login');
+  }
 }

+ 5 - 0
travel-app/src/app/tabs/tabs.routes.ts

@@ -21,6 +21,11 @@ export const routes: Routes = [
         loadComponent: () =>
           import('../tab3/tab3.page').then((m) => m.Tab3Page),
       },
+      {
+        path: 'tab4',
+        loadComponent: () =>
+          import('../tab4/tab4.page').then((m) => m.Tab4Page),
+      },
       {
         path: '',
         redirectTo: '/tabs/tab1',

BIN
travel-app/src/assets/img/头像.jpg