|
|
@@ -1,29 +1,71 @@
|
|
|
import { Component,OnInit } from '@angular/core';
|
|
|
-import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton, IonList, IonItem, IonAvatar, IonLabel, IonCardHeader,
|
|
|
- IonCardContent, IonInput, IonFooter, IonButtons, IonCard, IonCardTitle } from '@ionic/angular/standalone';
|
|
|
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
|
import { EditRatingStarComponent } from '../edit-rating-star/edit-rating-star.component';
|
|
|
-
|
|
|
+import { IonicModule } from '@ionic/angular';
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
+import { FormsModule } from '@angular/forms'; // 导入 FormsModule
|
|
|
+import { Router } from '@angular/router';
|
|
|
+import { CloudUser,CloudObject } from 'src/lib/ncloud';
|
|
|
@Component({
|
|
|
selector: 'app-review',
|
|
|
templateUrl: './review.component.html',
|
|
|
styleUrls: ['./review.component.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [IonHeader,IonToolbar, IonTitle, IonContent,IonList,IonItem,IonAvatar,IonLabel,IonCard,IonCardHeader,IonCardContent,
|
|
|
- IonCardTitle,IonInput,IonFooter,IonButtons,IonButton,ExploreContainerComponent,EditRatingStarComponent,]
|
|
|
+ imports: [ExploreContainerComponent,EditRatingStarComponent,IonicModule,CommonModule,FormsModule]
|
|
|
})
|
|
|
export class ReviewComponent implements OnInit {
|
|
|
+ userInput: string = '';
|
|
|
+submittedFeedback: string | null = null;
|
|
|
+currentScore: number = 0; // 初始分值
|
|
|
+
|
|
|
+handleScoreChange(newScore: number) {
|
|
|
+ this.currentScore = newScore;
|
|
|
+ console.log('新分值:', newScore); // 处理分值变化
|
|
|
+}
|
|
|
+
|
|
|
+submitFeedback() {
|
|
|
+ this.submittedFeedback = this.userInput;
|
|
|
+ console.log(this.userInput); // 打印输入框的数据
|
|
|
+
|
|
|
+ let consult = new CloudObject("Review");
|
|
|
+ // 设置聊天记录的基本信息
|
|
|
+ let now = new Date();
|
|
|
+ let currentUser = new CloudUser();
|
|
|
+ let dateStr = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
|
|
|
+
|
|
|
+ // 对象权限的精确制定
|
|
|
+ let ACL: any = {
|
|
|
+ "*": { read: true, write: true }
|
|
|
+ };
|
|
|
+
|
|
|
+ consult.set({
|
|
|
+ user: currentUser.toPointer(),
|
|
|
+ feedbackContent: this.userInput,
|
|
|
+ createdAt: dateStr, // 可以加上创建时间
|
|
|
+ star: this.currentScore,
|
|
|
+
|
|
|
+
|
|
|
+ // ACL: ACL
|
|
|
+ });
|
|
|
+
|
|
|
+ // 调用 save 方法来保存数据
|
|
|
+ consult.save().then(() => {
|
|
|
+ console.log('反馈保存成功');
|
|
|
+ this.userInput = ''; // 清空输入框
|
|
|
+ this.router.navigate(['/tabs/review-display']); // 跳转到显示页面
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('保存反馈时出错:', error);
|
|
|
+ });
|
|
|
+
|
|
|
+ this.userInput = ''; // 清空输入框
|
|
|
+ this.router.navigate(['/tabs/review-display']);
|
|
|
+}
|
|
|
|
|
|
- currentScore: number = 0; // 初始分值
|
|
|
|
|
|
- handleScoreChange(newScore: number) {
|
|
|
- this.currentScore = newScore;
|
|
|
- console.log('新分值:', newScore); // 处理分值变化
|
|
|
- }
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
|
- constructor() {}
|
|
|
+ constructor(private router: Router) {}
|
|
|
|
|
|
|
|
|
}
|