|
@@ -1,7 +1,8 @@
|
|
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { FormsModule } from '@angular/forms';
|
|
-import { IonicModule } from '@ionic/angular';
|
|
|
|
|
|
+import { IonicModule, AlertController } from '@ionic/angular';
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
+import { Router } from '@angular/router';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-tab1',
|
|
selector: 'app-tab1',
|
|
@@ -18,20 +19,14 @@ import { CommonModule } from '@angular/common';
|
|
export class Tab1Page {
|
|
export class Tab1Page {
|
|
selectedTab: string = 'recommend';
|
|
selectedTab: string = 'recommend';
|
|
|
|
|
|
- slides = [
|
|
|
|
- { image: 'assets/1.png' },
|
|
|
|
- { image: 'assets/2.png' },
|
|
|
|
- { image: 'assets/3.png' },
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
recommendations = [
|
|
recommendations = [
|
|
- { title: '智能跑步机', subtitle: '最新款', description: '适合家庭使用的智能跑步机,享受便捷运动体验。', image: 'https://example.com/running-machine.jpg' },
|
|
|
|
- { title: '瑜伽垫', subtitle: '舒适型', description: '采用高质量材料,给你最舒适的瑜伽体验。', image: 'https://example.com/yoga-mat.jpg' },
|
|
|
|
|
|
+ { title: '智能跑步机', subtitle: '最新款', description: '适合家庭使用的智能跑步机,享受便捷运动体验。', image: 'assets/4.png' },
|
|
|
|
+ { title: '瑜伽垫', subtitle: '舒适型', description: '采用高质量材料,给你最舒适的瑜伽体验。', image: 'assets/5.png' },
|
|
];
|
|
];
|
|
|
|
|
|
activities = [
|
|
activities = [
|
|
- { title: '冬季滑雪大赛', date: '2024-12-10', description: '加入我们,挑战滑雪极限!' },
|
|
|
|
- { title: '夏季自行车比赛', date: '2024-06-15', description: '感受骑行的乐趣,挑战极限!' },
|
|
|
|
|
|
+ { title: '冬季滑雪大赛', date: '2024-12-30', description: '加入我们,挑战滑雪极限!' },
|
|
|
|
+ { title: '夏季自行车比赛', date: '2025-06-15', description: '感受骑行的乐趣,挑战极限!' },
|
|
];
|
|
];
|
|
|
|
|
|
courses = [
|
|
courses = [
|
|
@@ -39,18 +34,117 @@ export class Tab1Page {
|
|
{ title: '马拉松训练营', instructor: '李教练', description: '为马拉松爱好者提供专业的训练课程,帮助提升跑步成绩。' },
|
|
{ title: '马拉松训练营', instructor: '李教练', description: '为马拉松爱好者提供专业的训练课程,帮助提升跑步成绩。' },
|
|
];
|
|
];
|
|
|
|
|
|
- // 立即购买操作
|
|
|
|
- buyNow(): void {
|
|
|
|
- console.log('立即购买');
|
|
|
|
|
|
+ constructor(private router: Router, private alertController: AlertController) {}
|
|
|
|
+
|
|
|
|
+ // 弹出输入地址和手机号的弹窗
|
|
|
|
+ async promptAddress(): Promise<void> {
|
|
|
|
+ const alert = await this.alertController.create({
|
|
|
|
+ header: '输入地址和手机号',
|
|
|
|
+ inputs: [
|
|
|
|
+ {
|
|
|
|
+ name: 'address',
|
|
|
|
+ type: 'text',
|
|
|
|
+ placeholder: '请输入地址'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: 'phone',
|
|
|
|
+ type: 'tel',
|
|
|
|
+ placeholder: '请输入手机号'
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ buttons: [
|
|
|
|
+ {
|
|
|
|
+ text: '取消',
|
|
|
|
+ role: 'cancel'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ text: '确认',
|
|
|
|
+ handler: (data) => {
|
|
|
|
+ console.log('地址:', data.address);
|
|
|
|
+ console.log('手机号:', data.phone);
|
|
|
|
+ this.showAlert('购买成功', '您的订单已提交!');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ });
|
|
|
|
+ await alert.present();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 弹出输入姓名和手机号的弹窗
|
|
|
|
+ async promptRegistration(activity: any): Promise<void> {
|
|
|
|
+ const alert = await this.alertController.create({
|
|
|
|
+ header: '输入姓名和手机号',
|
|
|
|
+ inputs: [
|
|
|
|
+ {
|
|
|
|
+ name: 'name',
|
|
|
|
+ type: 'text',
|
|
|
|
+ placeholder: '请输入姓名'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: 'phone',
|
|
|
|
+ type: 'tel',
|
|
|
|
+ placeholder: '请输入手机号'
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ buttons: [
|
|
|
|
+ {
|
|
|
|
+ text: '取消',
|
|
|
|
+ role: 'cancel'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ text: '确认',
|
|
|
|
+ handler: (data) => {
|
|
|
|
+ console.log('姓名:', data.name);
|
|
|
|
+ console.log('手机号:', data.phone);
|
|
|
|
+ this.showAlert('报名成功', '您已成功报名活动!');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ });
|
|
|
|
+ await alert.present();
|
|
}
|
|
}
|
|
|
|
|
|
- // 注册活动
|
|
|
|
- register(activity: { title: string; date: string; description: string }): void {
|
|
|
|
- console.log('注册活动:', activity);
|
|
|
|
|
|
+ // 弹出输入上课时间和手机号的弹窗
|
|
|
|
+ async promptCourseEnrollment(course: any): Promise<void> {
|
|
|
|
+ const alert = await this.alertController.create({
|
|
|
|
+ header: '输入上课时间和手机号',
|
|
|
|
+ inputs: [
|
|
|
|
+ {
|
|
|
|
+ name: 'classTime',
|
|
|
|
+ type: 'text',
|
|
|
|
+ placeholder: '请输入上课时间'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: 'phone',
|
|
|
|
+ type: 'tel',
|
|
|
|
+ placeholder: '请输入手机号'
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ buttons: [
|
|
|
|
+ {
|
|
|
|
+ text: '取消',
|
|
|
|
+ role: 'cancel'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ text: '确认',
|
|
|
|
+ handler: (data) => {
|
|
|
|
+ console.log('上课时间:', data.classTime);
|
|
|
|
+ console.log('手机号:', data.phone);
|
|
|
|
+ this.showAlert('报名成功', '您已成功报名课程!');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ });
|
|
|
|
+ await alert.present();
|
|
}
|
|
}
|
|
|
|
|
|
- // 注册课程
|
|
|
|
- enroll(course: { title: string; instructor: string; description: string }): void {
|
|
|
|
- console.log('注册课程:', course);
|
|
|
|
|
|
+ // 显示成功提示
|
|
|
|
+ async showAlert(header: string, message: string): Promise<void> {
|
|
|
|
+ const alert = await this.alertController.create({
|
|
|
|
+ header: header,
|
|
|
|
+ message: message,
|
|
|
|
+ buttons: ['确定']
|
|
|
|
+ });
|
|
|
|
+ await alert.present();
|
|
}
|
|
}
|
|
}
|
|
}
|