Przeglądaj źródła

0210348_commit02

未来全栈 4 miesięcy temu
rodzic
commit
20c37703f2

+ 4 - 0
app/app-routing.module.ts

@@ -15,6 +15,10 @@ const routes: Routes = [
     path: 'user',
     loadChildren: () => import('../modules/user/user.module').then(m => m.UserModule)
   },
+  {
+    path: "tree",
+    loadChildren: () => import('../modules/tab/tree/tree.module').then(m => m.TreePageModule)
+  },
 ];
 @NgModule({
   imports: [

+ 11 - 6
app/tab1/tab1.page.html

@@ -33,15 +33,20 @@
       </ion-grid>
     </ion-card-content>
   </ion-card>
-
-  <!-- 3D效果的圆 -->
-  <div class="wave-container">
-    <div class="wave-circle">
-      <div class="wave">
-        <div class="wave-inner"></div>
+  
+<!-- 3D效果的圆 -->
+<div class="wave-container" (click)="navigateToTreePage()">
+  <div class="wave-circle">
+    <div class="wave">
+      <div class="wave-inner">
+        <span class="start-self-discipline">开始自律</span>
       </div>
     </div>
   </div>
+</div>
+
+
+
 
   <!-- 每日小习惯 -->
   <div class="daily-habit">

+ 22 - 5
app/tab1/tab1.page.scss

@@ -45,18 +45,35 @@ ion-searchbar {
   top: -75%;
   left: -50%;
   background: rgba(255, 255, 255, 0.4);
-  border-radius: 45%;
+  border-radius: 50%;
   animation: wave 4s infinite linear;
 }
 
-@keyframes wave {
+.wave-inner {
+  width: 120px;
+  height: 120px;
+  background-color: #3f51b5;
+  border-radius: 50%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  cursor: pointer;
+  transition: transform 0.3s ease-in-out;
+  color: #ffffff;
+  font-size: 1.2rem;
+  font-weight: bold;
+  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
+}
+
+/* @keyframes wave {
   0% {
-    transform: rotate(0deg);
+    transform: translateX(-50%) translateY(-50%) rotate(0deg);
   }
   100% {
-    transform: rotate(360deg);
+    transform: translateX(-50%) translateY(-50%) rotate(360deg);
   }
-}
+} */
+
 
 // 每日小习惯
 .daily-habit {

+ 8 - 1
app/tab1/tab1.page.ts

@@ -1,5 +1,7 @@
 import { Component } from '@angular/core';
 import { AlertController } from '@ionic/angular';
+import { Router } from '@angular/router';
+
 @Component({
   selector: 'app-tab1',
   templateUrl: 'tab1.page.html',
@@ -7,7 +9,7 @@ import { AlertController } from '@ionic/angular';
 })
 export class Tab1Page {
 
-  constructor(private alertController: AlertController) {}
+  constructor(private alertController: AlertController,private router: Router) {}
 
   async openModal() {
     const alert = await this.alertController.create({
@@ -21,5 +23,10 @@ export class Tab1Page {
   toggleButtonColor(habit:string){
     this.blueColor=!this.blueColor;
   }
+
+  //3d圆点击事件
+  navigateToTreePage() {
+    this.router.navigate(['/tabs/tree']);
+  }
 }
 

+ 7 - 2
app/tab3/tab3.page.html

@@ -2,11 +2,11 @@
 </ion-header>
 
 <ion-content [fullscreen]="true">
-  <ion-header collapse="condense">
+  <!-- <ion-header collapse="condense">
     <ion-toolbar>
       <ion-title size="large">Tab 3</ion-title>
     </ion-toolbar>
-  </ion-header>
+  </ion-header> -->
   
   <!-- 个人信息板块 -->
   <ion-card>
@@ -74,6 +74,11 @@
       <ion-icon name="download" slot="start"></ion-icon>
       数据下载
     </ion-item>
+    <!-- 登出按钮 -->
+    <ion-item button (click)="logout()">
+      <ion-icon name="log-out" slot="start"></ion-icon>
+      登出
+    </ion-item>
   </ion-list>
   
 </ion-content>

+ 18 - 4
app/tab3/tab3.page.ts

@@ -1,14 +1,15 @@
 import { Component } from '@angular/core';
-import { ToastController } from '@ionic/angular';
+import { NavController, ToastController } from '@ionic/angular';
+import * as Parse from "parse";
 
 @Component({
   selector: 'app-tab3',
-  templateUrl: 'tab3.page.html',
-  styleUrls: ['tab3.page.scss']
+  templateUrl: './tab3.page.html',
+  styleUrls: ['./tab3.page.scss']
 })
 export class Tab3Page {
 
-  constructor(private toastController: ToastController) {}
+  constructor(private navCtrl: NavController, private toastController: ToastController) {}
 
   async onItemClick(item: string) {
     const toast = await this.toastController.create({
@@ -18,4 +19,17 @@ export class Tab3Page {
     toast.present();
   }
 
+  async logout() {
+    try {
+      await Parse.User.logOut();
+      this.navCtrl.navigateRoot('/tabs/calendar'); // 登出后跳转到登录界面
+    } catch (error: any) {
+      console.error("Logout failed:", error);
+      const toast = await this.toastController.create({
+        message: `登出失败: ${error.message}`,
+        duration: 2000,
+      });
+      toast.present();
+    }
+  }
 }

+ 4 - 0
app/tabs/tabs-routing.module.ts

@@ -23,6 +23,10 @@ const routes: Routes = [
         path: 'calendar',
         loadChildren: () => import('../../modules/user/mine/mine.module').then(mod => mod.MinePageModule)
       },
+      {
+        path: "tree",
+        loadChildren: () => import('../../modules/tab/tree/tree.module').then(mod => mod.TreePageModule)
+      },
       {
         path: '',
         redirectTo: '/tabs/tab1',

+ 3 - 5
app/tabs/tabs.page.html

@@ -1,5 +1,4 @@
 <ion-tabs>
-
   <ion-tab-bar slot="bottom">
     <ion-tab-button tab="tab1" href="/tabs/tab1">
       <ion-icon aria-hidden="true" name="home"></ion-icon>
@@ -11,15 +10,14 @@
       <ion-label>记录一下</ion-label>
     </ion-tab-button>
 
-    <ion-tab-button tab="tab3" href="/tabs/tab3">
+    <ion-tab-button (click)="checkLogin()">
       <ion-icon aria-hidden="true" name="person"></ion-icon>
       <ion-label>我的</ion-label>
     </ion-tab-button>
     
-    <ion-tab-button tab="calendar" href="/tabs/calendar">
+    <!-- <ion-tab-button tab="calendar" href="/tabs/calendar">
       <ion-icon aria-hidden="true" name="calendar"></ion-icon>
       <ion-label>日历</ion-label>
-    </ion-tab-button>
+    </ion-tab-button> -->
   </ion-tab-bar>
-
 </ion-tabs>

+ 13 - 1
app/tabs/tabs.page.ts

@@ -1,4 +1,6 @@
 import { Component } from '@angular/core';
+import { NavController } from '@ionic/angular';
+import * as Parse from "parse";
 
 @Component({
   selector: 'app-tabs',
@@ -7,6 +9,16 @@ import { Component } from '@angular/core';
 })
 export class TabsPage {
 
-  constructor() {}
+  constructor(private navCtrl: NavController) {}
 
+  async checkLogin() {
+    const currentUser = Parse.User.current();
+    if (currentUser) {
+      // 如果已登录,跳转到“我的”界面
+      this.navCtrl.navigateForward('/tabs/tab3');
+    } else {
+      // 如果未登录,跳转到“登录”界面
+      this.navCtrl.navigateForward('/tabs/calendar');
+    }
+  }
 }

BIN
assets/img/tree.png


BIN
assets/img/zilv.jpg


+ 1 - 1
modules/tab/tree/tree.page.html

@@ -5,7 +5,7 @@
 <ion-content [fullscreen]="true">
   <!-- Tree image -->
   <div class="image-container">
-    <img src="assets/tab1/tree.png" alt="Tree">
+    <img src="../../../assets/img/tree.png" alt="Tree">
   </div>
 
   <!-- Title and time display -->

+ 2 - 2
modules/tab/tree/tree.page.scss

@@ -42,8 +42,8 @@ ion-app {
   color: black;
   border: 2px solid #c2c2c2;
   border-radius: 10%;
-  width: fit-content;
-  height: fit-content;
+  width: 60%;
+  height: 50%;
   padding: 5px 5px 0px 5px;
 }
 

+ 2 - 3
modules/tab/tree/tree.page.spec.ts

@@ -1,10 +1,9 @@
 import { ComponentFixture, TestBed } from '@angular/core/testing';
 import { IonicModule } from '@ionic/angular';
-
-import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
-
 import { TreePage } from './tree.page';
 
+import { ExploreContainerComponentModule } from 'src/app/explore-container/explore-container.module';
+
 describe('TreePage', () => {
   let component: TreePage;
   let fixture: ComponentFixture<TreePage>;

+ 37 - 36
modules/user/login/login.page.html

@@ -1,38 +1,39 @@
-<ion-header [translucent]="true">
-  <ion-toolbar>
-    <ion-title>登录/注册</ion-title>
-  </ion-toolbar>
-</ion-header>
-
-<ion-content [fullscreen]="true">
-  <ion-header collapse="condense">
-    <ion-toolbar>
-      <ion-title size="large">登录/注册</ion-title>
-    </ion-toolbar>
-  </ion-header>
-
-  <ion-card>
-    <ion-card-header>
-      <ion-card-title>登录/注册</ion-card-title>
-    </ion-card-header>
+<ion-content [fullscreen]="true" class="ion-text-center">
+  <div class="login-container">
+    <ion-card class="login-card">
+      <ion-card-header>
+        <ion-card-title>登录/注册</ion-card-title>
+      </ion-card-header>
+    
+      <ion-card-content>
+        <ion-list>
+          <ion-item lines="none">
+            <ion-label position="floating" class="label-login">账号</ion-label>
+            <ion-input [(ngModel)]="username" placeholder="请输入用户名"></ion-input>
+          </ion-item>
+          <ion-item lines="none">
+            <ion-label position="floating" class="label-login">密码</ion-label>
+            <ion-input [(ngModel)]="password" type="password" placeholder="请输入密码"></ion-input>
+          </ion-item>
+        </ion-list>
+      </ion-card-content>
+    
+      <ion-row class="ion-login">
+        <ion-col size="6">
+          <ion-button expand="block" (click)="login()" color="primary">登录</ion-button>
+        </ion-col>
+        <ion-col size="6">
+          <ion-button expand="block" (click)="register()" color="primary">注册</ion-button>
+        </ion-col>
+      </ion-row>
   
-    <ion-card-content>
-
-      <ion-list [inset]="true">
-        <ion-item>
-          <ion-input [(ngModel)]="username" label="账号" placeholder="请输入用户名"></ion-input>
-        </ion-item>
-        <ion-item>
-          <ion-input [(ngModel)]="password" label="密码" type="password" placeholder="请输入密码"></ion-input>
-        </ion-item>
-      </ion-list>
-     
-    </ion-card-content>
-  
-    <ion-button (click)="login()" fill="clear">登录</ion-button>
-    <ion-button (click)="register()" fill="clear">注册</ion-button>
-  </ion-card>
-
-  <!-- 新增路由返回逻辑,执行back函数 -->
-  <ion-button expand="block" (click)="back()">返回</ion-button>
+      <!-- 返回按钮 -->
+      <ion-row class="ion-back">
+        <ion-col size="12">
+          <ion-button expand="block" (click)="back()" color="primary">返回</ion-button>
+        </ion-col>
+      </ion-row>
+      
+    </ion-card>
+  </div>
 </ion-content>

+ 31 - 0
modules/user/login/login.page.scss

@@ -0,0 +1,31 @@
+//窗口居中
+.login-container {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 90vh; /* 使用视窗高度,保证内容居中且不畸形 */
+  padding: 0px; /* 可根据需要调整内边距 */
+  box-sizing: border-box; /* 确保内边距不影响总宽度 */
+}
+
+.login-card {
+  max-width: 400px; /* 设置最大宽度,避免内容过于扩展 */
+  width: 100%; /* 宽度100%,确保内容在容器内部居中 */
+  text-align: center; /* 文本居中 */
+}
+
+//登录注册
+.label-login{
+  font-size:30px;
+}
+
+
+//返回按钮
+.ion-login{
+  margin:0px 30px 0px 30px;
+  padding: auto;
+}
+.ion-back{
+  margin:0px 30px 10px 30px;
+  padding: auto;
+}

+ 49 - 56
modules/user/login/login.page.ts

@@ -1,7 +1,7 @@
 import { Component, OnInit } from '@angular/core';
 import { AlertController, NavController } from '@ionic/angular';
 import * as Parse from "parse"
-// 引用Router服务
+
 @Component({
   selector: 'app-login',
   templateUrl: './login.page.html',
@@ -9,70 +9,67 @@ import * as Parse from "parse"
 })
 export class LoginPage implements OnInit {
 
-  username:string = ""
-  password:string = ""
+  username: string = ""
+  password: string = ""
+  
   constructor(
-    // 新增:Router服务,用于路由跳转
-    private navCtrl:NavController,
-    private alertController:AlertController
+    private navCtrl: NavController,
+    private alertController: AlertController
   ) { }
 
-  ngOnInit() {
-  }
+  ngOnInit() { }
 
-  async login(){
-    let user
+  async login() {
+    let user;
     try {
-      user = await Parse.User.logIn(this.username,this.password)
-    } catch (error:any) {
-      let message:string = ""
-      // 新增提示词详情,根据Parse.User.login方法返回的不同英文提示词,增加对应的中文内容转换
-      if(error?.message.indexOf("is required")>-1){
-        message = "必须输入账号或邮箱"
+      user = await Parse.User.logIn(this.username, this.password);
+    } catch (error: any) {
+      let message: string = "";
+      if (error?.message.indexOf("is required") > -1) {
+        message = "必须输入账号或邮箱";
       }
-      if(error?.message.indexOf("Invalid username")>-1){
-        message = "账号或密码错误,请检查"
+      if (error?.message.indexOf("Invalid username") > -1) {
+        message = "账号或密码错误,请检查";
       }
       this.presentAlert({
-        header:"登录失败",
-        subHeader:"状态码:"+error.code,
-        message:message || error.message
-      })
+        header: "登录失败",
+        subHeader: "状态码:" + error.code,
+        message: message || error.message
+      });
     }
-    console.log(user)
-    if(user?.id){
-      this.navCtrl.back()
+    console.log(user);
+    if (user?.id) {
+      this.navCtrl.navigateForward('/tabs/tab3'); // 修改这里
     }
   }
-  async register(){
-    let user = new Parse.User()
-    user.set("username",this.username)
-    user.set("password",this.password)
+
+  async register() {
+    let user = new Parse.User();
+    user.set("username", this.username);
+    user.set("password", this.password);
     try {
-        let result = await user.signUp();
-        console.log(result)
-        if(result?.id){
-          this.navCtrl.back()
-        }
-        // Hooray! Let them use the app now.
-    } catch (error:any) {
-        // 新增提示词详情,根据Parse.User.signUp方法返回的不同英文提示词,增加对应的中文内容转换
-        let message:string = ""
-        if(error?.message.indexOf("already exists")>-1){
-          message = "该账号已存在请修改后重试"
-        }
-        if(error?.message.indexOf("empty")>-1){
-          message = "账号不能为空请输入后重试"
-        }
-        this.presentAlert({
-          header:"注册失败",
-          subHeader:"状态码:"+error.code,
-          message:message || error.message
-        })
+      let result = await user.signUp();
+      console.log(result);
+      if (result?.id) {
+        this.navCtrl.navigateForward('/tabs/tab3'); // 修改这里
+      }
+    } catch (error: any) {
+      let message: string = "";
+      if (error?.message.indexOf("already exists") > -1) {
+        message = "该账号已存在请修改后重试";
+      }
+      if (error?.message.indexOf("empty") > -1) {
+        message = "账号不能为空请输入后重试";
+      }
+      this.presentAlert({
+        header: "注册失败",
+        subHeader: "状态码:" + error.code,
+        message: message || error.message
+      });
     }
   }
 
-  async presentAlert(options:{header:string,subHeader:string,message:string}) {
+  async presentAlert(options: { header: string, subHeader: string, message: string }) {
     const alert = await this.alertController.create({
       header: options?.header,
       subHeader: options?.subHeader,
@@ -83,11 +80,7 @@ export class LoginPage implements OnInit {
     await alert.present();
   }
 
-  /**
-   * 返回上级页面函数
-   * @desc
-   */
-  back(){
-    this.navCtrl.back()
+  back() {
+    this.navCtrl.back();
   }
 }

+ 13 - 26
modules/user/mine/mine.page.html

@@ -1,29 +1,16 @@
-<ion-header [translucent]="true">
-  <ion-toolbar>
-    <ion-title>我的</ion-title>
-  </ion-toolbar>
-</ion-header>
-
-<ion-content [fullscreen]="true">
-  <ion-header collapse="condense">
-    <ion-toolbar>
-      <ion-title size="large">我的</ion-title>
-    </ion-toolbar>
-  </ion-header>
-
-  <ion-card>
-    <img alt="" src="https://ionicframework.com/docs/img/demos/card-media.png" />
-    <ion-card-header>
-      <ion-card-title>{{user?.get("username") || '未登录'}}</ion-card-title>
-      <ion-card-subtitle *ngIf="!user?.id">请您登陆后继续使用</ion-card-subtitle>
-      <ion-card-subtitle *ngIf="user?.id">{{user?.get("name")}}-{{user?.get("gender")}}</ion-card-subtitle>
-    </ion-card-header>
- 
-    <!-- 新增:根据用户状态,显示登录/登出按钮,执行跳转或登出函数 -->
-    <ion-button *ngIf="!user?.id" fill="clear" routerLink="/user/login">登录</ion-button>
-    <ion-button *ngIf="user?.id" fill="clear" routerLink="/user/edit/info">编辑资料</ion-button>
-    <ion-button *ngIf="user?.id" fill="clear" (click)="logout()">登出</ion-button>
-  </ion-card>
+<ion-content [fullscreen]="true" class="ion-text-center ion-align-items-center">
+  <div class="login-container">
+    <img src="../../../assets/img/zilv.jpg" alt="Logo" class="app-logo">
 
+    <ion-card class="login-card">
+      <ion-card-header>
+        <ion-card-title>欢迎使用我们的App</ion-card-title>
+      </ion-card-header>
 
+      <ion-card-content class="ion-text-center">
+        <p>请登录或注册以继续使用我们的服务。</p>
+        <ion-button expand="block" color="primary" fill="solid" routerLink="/user/login">去登录</ion-button>
+      </ion-card-content>
+    </ion-card>
+  </div>
 </ion-content>

+ 27 - 0
modules/user/mine/mine.page.scss

@@ -0,0 +1,27 @@
+.ion-content {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 0vh; /* 使用视窗高度,确保内容垂直居中 */
+}
+
+.login-container {
+  text-align: center; /* 文本居中 */
+  //max-width: 400px; /* 设置最大宽度,避免内容过于扩展 */
+  width: 100%; /* 宽度100%,确保内容在容器内部居中 */
+  padding: 0 10px; /* 可根据需要调整内边距 */
+  box-sizing: border-box; /* 确保内边距不影响总宽度 */
+}
+
+.login-card {
+  margin:0px 10px;
+  //max-width: 500px; /* 设置最大宽度,避免内容过于扩展 */
+  text-align: center; /* 文本居中 */
+}
+
+.app-logo {
+  padding-top: 100px;
+  max-width: 95%; /* 图片宽度最大为容器宽度 */
+  height: auto; /* 自动高度 */
+  padding-bottom: 20px;
+}