|
@@ -1,14 +1,12 @@
|
|
|
import { Component, AfterViewInit } from '@angular/core';
|
|
|
import { Router } from '@angular/router';
|
|
|
import { ModalController, NavController, ToastController } from '@ionic/angular';
|
|
|
-import { Observable } from 'rxjs';
|
|
|
-import { map, catchError,tap } from 'rxjs/operators';
|
|
|
-import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
|
-import { throwError } from 'rxjs';
|
|
|
+import { SplashService } from '../services/splash.service';
|
|
|
+import { HttpClient,} from '@angular/common/http';
|
|
|
import { Subscription } from 'rxjs';
|
|
|
import { UserService } from '../services/user.service';
|
|
|
-import {ElementRef, OnInit, Renderer2 } from '@angular/core';
|
|
|
-import { environment } from 'src/environments/environment';
|
|
|
+import {ElementRef, Renderer2 } from '@angular/core';
|
|
|
+
|
|
|
|
|
|
interface User {
|
|
|
username: string;
|
|
@@ -24,36 +22,36 @@ export class Tab1Page implements AfterViewInit {
|
|
|
|
|
|
doctors = [
|
|
|
{
|
|
|
- avatar: '../../assets/images/医生1.jpg',
|
|
|
+ avatar: '../../assets/images/doctor1.jpg',
|
|
|
name: '张医生',
|
|
|
specialty: '心血管科'
|
|
|
},
|
|
|
{
|
|
|
- avatar: '../../assets/images/医生2.jpg',
|
|
|
+ avatar: '../../assets/images/doctor2.jpg',
|
|
|
name: '李医生',
|
|
|
specialty: '神经科'
|
|
|
},
|
|
|
{
|
|
|
- avatar: '../../assets/images/医生3.jpg',
|
|
|
+ avatar: '../../assets/images/doctor3.jpg',
|
|
|
name: '王医生',
|
|
|
specialty: '儿科'
|
|
|
},
|
|
|
{
|
|
|
- avatar: '../../assets/images/医生4.jpg',
|
|
|
+ avatar: '../../assets/images/doctor4.jpg',
|
|
|
name: '赵医生',
|
|
|
specialty: '外科'
|
|
|
},
|
|
|
{
|
|
|
- avatar: '../../assets/images/医生5.jpg',
|
|
|
+ avatar: '../../assets/images/doctor5.jpg',
|
|
|
name: '陈医生',
|
|
|
specialty: '内科'
|
|
|
}
|
|
|
];
|
|
|
|
|
|
images = [
|
|
|
- '../../assets/images/背景图1.jpg',
|
|
|
- '../../assets/images/背景图2.jpg',
|
|
|
- '../../assets/images/背景图3.jpeg'
|
|
|
+ '../../assets/images/brackground1.jpg',
|
|
|
+ '../../assets/images/brackground2.jpg',
|
|
|
+ '../../assets/images/brackground3.jpeg'
|
|
|
];
|
|
|
|
|
|
// 功能按钮数据
|
|
@@ -72,7 +70,7 @@ export class Tab1Page implements AfterViewInit {
|
|
|
{ label: '健康社区', icon: 'people', route: '/health-community' }
|
|
|
];
|
|
|
|
|
|
- userAvatar: string = '../../assets/images/user-avatar.png'; // 默认头像
|
|
|
+ userAvatar: string = '../../assets/images/user.png'; // 默认头像
|
|
|
private userInfoSubscription!: Subscription;
|
|
|
|
|
|
currentIndex = 0;
|
|
@@ -86,6 +84,8 @@ export class Tab1Page implements AfterViewInit {
|
|
|
isLoginModalOpen = false;
|
|
|
user: User = { username: '', password: '' };
|
|
|
fileToUpload: File | null = null;
|
|
|
+ private splashSubscription!: Subscription;
|
|
|
+ isLoggedIn: boolean = false;
|
|
|
|
|
|
|
|
|
constructor(
|
|
@@ -96,7 +96,8 @@ export class Tab1Page implements AfterViewInit {
|
|
|
private toastController: ToastController,// 添加 ToastController 注入
|
|
|
private userService: UserService ,
|
|
|
private el: ElementRef,
|
|
|
- private renderer: Renderer2
|
|
|
+ private renderer: Renderer2,
|
|
|
+ private splashService: SplashService
|
|
|
) {}
|
|
|
|
|
|
ngOnInit() {
|
|
@@ -104,6 +105,11 @@ export class Tab1Page implements AfterViewInit {
|
|
|
this.startImageRotation();
|
|
|
// 初始化时设置第一张图片
|
|
|
this.updateBackgroundImage();
|
|
|
+ this.splashSubscription = this.splashService.openLoginModal$.subscribe(async (shouldOpen) => {
|
|
|
+ if (shouldOpen) {
|
|
|
+ await this.openLoginModal();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
ionViewWillEnter() {
|
|
@@ -114,6 +120,9 @@ export class Tab1Page implements AfterViewInit {
|
|
|
if (this.userInfoSubscription) {
|
|
|
this.userInfoSubscription.unsubscribe();
|
|
|
}
|
|
|
+ if (this.splashSubscription) {
|
|
|
+ this.splashSubscription.unsubscribe();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 实现 AfterViewInit 接口的 ngAfterViewInit 方法
|
|
@@ -245,7 +254,6 @@ export class Tab1Page implements AfterViewInit {
|
|
|
this.router.navigate([route]);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
openLoginModal() {
|
|
|
this.isLoginModalOpen = true;
|
|
|
console.log('打开登录/注册模态框');
|
|
@@ -280,6 +288,7 @@ export class Tab1Page implements AfterViewInit {
|
|
|
async (response) => {
|
|
|
console.log('登录成功:', response);
|
|
|
await this.presentToast('登录成功', 'success');
|
|
|
+ this.isLoggedIn = true;
|
|
|
this.closeLoginModal();
|
|
|
},
|
|
|
async (error) => {
|
|
@@ -312,6 +321,7 @@ export class Tab1Page implements AfterViewInit {
|
|
|
async (response) => {
|
|
|
console.log('注册成功:', response);
|
|
|
await this.presentToast('注册成功', 'success');
|
|
|
+ this.isLoggedIn = true;
|
|
|
this.closeLoginModal();
|
|
|
},
|
|
|
async (error) => {
|