|
@@ -1,43 +1,72 @@
|
|
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
-import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonButton, IonBackButton, IonAlert,IonMenuToggle, IonSelect, IonSelectOption, IonLabel, IonTextarea, IonIcon, IonInput,IonCard,} from '@ionic/angular/standalone';
|
|
|
+import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonButton, IonBackButton, IonAlert, IonMenuToggle, IonSelect, IonSelectOption, IonLabel, IonTextarea, IonIcon, IonInput, IonCard } from '@ionic/angular/standalone';
|
|
|
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
|
import { FormBuilder } from '@angular/forms';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
+import { CloudObject } from 'src/lib/ncloud';
|
|
|
+import { AlertController } from '@ionic/angular';
|
|
|
+
|
|
|
@Component({
|
|
|
- selector: 'app-feedback',
|
|
|
+ selector: 'app - feedback',
|
|
|
templateUrl: './feedback.component.html',
|
|
|
styleUrls: ['./feedback.component.scss'],
|
|
|
standalone: true,
|
|
|
imports: [
|
|
|
IonHeader, IonContent, IonToolbar, IonTitle, ExploreContainerComponent,
|
|
|
IonButton, IonBackButton, IonMenuToggle, IonSelect, IonSelectOption, IonLabel,
|
|
|
- IonTextarea, IonIcon,IonInput,IonCard,
|
|
|
- IonList, IonItem,IonAlert,
|
|
|
+ IonTextarea, IonIcon, IonInput, IonCard,
|
|
|
+ IonList, IonItem, IonAlert,
|
|
|
FormsModule,
|
|
|
- ReactiveFormsModule,CommonModule
|
|
|
+ ReactiveFormsModule, CommonModule
|
|
|
]
|
|
|
})
|
|
|
export class FeedbackComponent implements OnInit {
|
|
|
- isAlertOpen = false;
|
|
|
- alertButtons = ['Action'];
|
|
|
-
|
|
|
- setOpen(isOpen: boolean) {
|
|
|
- this.isAlertOpen = isOpen;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
selectedCategory = '';
|
|
|
feedbackText = '';
|
|
|
categories = ['功能问题', '经济纠纷问题', '用户体验', '其他'];
|
|
|
+ fileObject: File | null = null;
|
|
|
+ userPointer: string | null = null;
|
|
|
+
|
|
|
+ constructor(private fb: FormBuilder, private alertController: AlertController) { }
|
|
|
|
|
|
- constructor(private fb: FormBuilder) { }
|
|
|
- onFileChange(event: any) {
|
|
|
+ onFileChange(event: Event) {
|
|
|
+ // 实现文件选择逻辑,并更新fileObject
|
|
|
}
|
|
|
|
|
|
submitFeedback() {
|
|
|
- console.log('Submitting feedback:', this.selectedCategory, this.feedbackText);
|
|
|
+ this.showSuccessAlert();
|
|
|
+ }
|
|
|
+
|
|
|
+ private showSuccessAlert() {
|
|
|
+ this.alertController.create({
|
|
|
+ header: '提交成功!',
|
|
|
+ buttons: [{
|
|
|
+ text: '确定',
|
|
|
+ handler: () => {
|
|
|
+ this.uploadDataToDatabase();
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }).then(alert => alert.present());
|
|
|
+ }
|
|
|
+
|
|
|
+ private uploadDataToDatabase() {
|
|
|
+ const feedback = new CloudObject('TravelFeedback');
|
|
|
+ feedback.set({
|
|
|
+ classfy: this.selectedCategory,
|
|
|
+ problem: this.feedbackText,
|
|
|
+ file: this.fileObject,
|
|
|
+ username: this.userPointer
|
|
|
+ });
|
|
|
+
|
|
|
+ feedback.save().then(() => {
|
|
|
+ console.log('Feedback submitted successfully');
|
|
|
+ // 处理保存成功后的逻辑
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('Error submitting feedback:', error);
|
|
|
+ // 处理保存失败后的逻辑
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- ngOnInit() {}
|
|
|
-}
|
|
|
+ ngOnInit() { }
|
|
|
+}
|