Przeglądaj źródła

上传文件至 ''

0225221 4 miesięcy temu
rodzic
commit
b6d40f7a82
5 zmienionych plików z 96 dodań i 0 usunięć
  1. 20 0
      register.module.ts
  2. 33 0
      register.page.html
  3. BIN
      register.page.scss
  4. 17 0
      register.page.spec.ts
  5. 26 0
      register.page.ts

+ 20 - 0
register.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 { RegisterPageRoutingModule } from './register-routing.module';
+
+import { RegisterPage } from './register.page';
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    RegisterPageRoutingModule
+  ],
+  declarations: [RegisterPage]
+})
+export class RegisterPageModule {}

+ 33 - 0
register.page.html

@@ -0,0 +1,33 @@
+<ion-header [translucent]="true">
+    <ion-toolbar>
+      <ion-title>register</ion-title>
+    </ion-toolbar>
+  </ion-header>
+  
+  
+  
+  <ion-content class="ion-text-center">
+    <ion-card>
+      <ion-card-header>
+        注册
+      </ion-card-header>
+      <ion-card-content>
+        <ion-item>
+          <ion-label position="floating">用户名</ion-label>
+          <ion-input type="text" [(ngModel)]="username"></ion-input>
+        </ion-item>
+        <ion-item>
+          <ion-label position="floating">密码</ion-label>
+          <ion-input type="password" [(ngModel)]="password"></ion-input>
+        </ion-item>
+        <ion-item>
+          <ion-label position="floating">确认密码</ion-label>
+          <ion-input type="password" [(ngModel)]="confirmPassword"></ion-input>
+        </ion-item>
+        <ion-button expand="full" (click)="register()">确认注册</ion-button>
+        <ion-button expand="full" (click)="goToLogin()">返回登录</ion-button>
+        <ion-text *ngIf="registerFailed" color="danger">注册失败</ion-text>
+      </ion-card-content>
+    </ion-card>
+  </ion-content>
+  

BIN
register.page.scss


+ 17 - 0
register.page.spec.ts

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

+ 26 - 0
register.page.ts

@@ -0,0 +1,26 @@
+import { Component } from '@angular/core';
+import { Router } from '@angular/router';
+
+@Component({
+  selector: 'app-register',
+  templateUrl: 'register.page.html',
+  styleUrls: ['register.page.scss']
+})
+export class RegisterPage {
+  username: string='';
+  password: string='';
+  confirmPassword: string='';
+  registerFailed: boolean = false;
+
+  constructor(private router: Router) {}
+
+  register() {
+    // 真实项目中应该调用后端API进行用户注册
+    // 这里简单模拟注册成功
+    this.router.navigate(['/login']);
+  }
+
+  goToLogin() {
+    this.router.navigate(['/login']);
+  }
+}