|
@@ -1,4 +1,4 @@
|
|
-import { Component } from '@angular/core';
|
|
|
|
|
|
+import { Component, AfterViewInit } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
@@ -6,38 +6,70 @@ import { Router } from '@angular/router';
|
|
templateUrl: 'tab1.page.html',
|
|
templateUrl: 'tab1.page.html',
|
|
styleUrls: ['tab1.page.scss']
|
|
styleUrls: ['tab1.page.scss']
|
|
})
|
|
})
|
|
-export class Tab1Page {
|
|
|
|
|
|
+export class Tab1Page implements AfterViewInit {
|
|
|
|
|
|
doctors = [
|
|
doctors = [
|
|
{
|
|
{
|
|
- avatar: '../../assets/icon/favicon.png',
|
|
|
|
|
|
+ avatar: '../../assets/images/doctor.png',
|
|
name: '张医生',
|
|
name: '张医生',
|
|
specialty: '心血管科'
|
|
specialty: '心血管科'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- avatar: '../../assets/icon/favicon.png',
|
|
|
|
|
|
+ avatar: '../../assets/images/doctor.png',
|
|
name: '李医生',
|
|
name: '李医生',
|
|
specialty: '神经科'
|
|
specialty: '神经科'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- avatar: '../../assets/icon/favicon.png',
|
|
|
|
|
|
+ avatar: '../../assets/images/doctor.png',
|
|
name: '王医生',
|
|
name: '王医生',
|
|
specialty: '儿科'
|
|
specialty: '儿科'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- avatar: '../../assets/icon/favicon.png',
|
|
|
|
|
|
+ avatar: '../../assets/images/doctor.png',
|
|
name: '赵医生',
|
|
name: '赵医生',
|
|
specialty: '外科'
|
|
specialty: '外科'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- avatar: '../../assets/icon/favicon.png',
|
|
|
|
|
|
+ avatar: '../../assets/images/doctor.png',
|
|
name: '陈医生',
|
|
name: '陈医生',
|
|
specialty: '内科'
|
|
specialty: '内科'
|
|
}
|
|
}
|
|
];
|
|
];
|
|
|
|
|
|
-
|
|
|
|
|
|
+ currentIndex = 0;
|
|
|
|
+
|
|
constructor(private router: Router) {}
|
|
constructor(private router: Router) {}
|
|
|
|
|
|
|
|
+ ngAfterViewInit() {
|
|
|
|
+ // 初始化时调用一次以确保初始状态正确
|
|
|
|
+ this.updateCarousel();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 上一张
|
|
|
|
+ prevSlide() {
|
|
|
|
+ if (this.currentIndex > 0) {
|
|
|
|
+ this.currentIndex--;
|
|
|
|
+ } else {
|
|
|
|
+ this.currentIndex = this.doctors.length - 1;
|
|
|
|
+ }
|
|
|
|
+ this.updateCarousel();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 下一张
|
|
|
|
+ nextSlide() {
|
|
|
|
+ if (this.currentIndex < this.doctors.length - 1) {
|
|
|
|
+ this.currentIndex++;
|
|
|
|
+ } else {
|
|
|
|
+ this.currentIndex = 0;
|
|
|
|
+ }
|
|
|
|
+ this.updateCarousel();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新轮播位置
|
|
|
|
+ updateCarousel() {
|
|
|
|
+ // 这里不需要获取 DOM 元素,因为我们在模板中直接使用了 [ngStyle]
|
|
|
|
+ // 每个卡片的 transform 属性会根据当前索引自动更新
|
|
|
|
+ }
|
|
|
|
+
|
|
// 模拟数据或其他逻辑可以在这里添加
|
|
// 模拟数据或其他逻辑可以在这里添加
|
|
}
|
|
}
|