|
@@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common'; // 导入 CommonModule
|
|
|
|
|
|
import { IonHeader, IonButton, IonContent, IonIcon, IonItem, IonLabel, IonList,
|
|
|
IonListHeader, IonCardHeader, IonCardTitle, IonCardContent, IonTitle, IonCard, IonToolbar, IonInput, IonSearchbar } from '@ionic/angular/standalone';
|
|
|
-import { CloudQuery, CloudUser } from 'src/lib/ncloud';
|
|
|
+import { CloudQuery, CloudObject, CloudUser } from 'src/lib/ncloud';
|
|
|
import { UserService } from 'src/app/user.service'; // 假设这是你的用户服务
|
|
|
|
|
|
@Component({
|
|
@@ -22,11 +22,10 @@ import { UserService } from 'src/app/user.service'; // 假设这是你的用户
|
|
|
]
|
|
|
})
|
|
|
export class MyDriftBottleComponent implements OnInit {
|
|
|
- filteredDriftbottles2:any[]=[];
|
|
|
- Driftbottles: any[]=[];
|
|
|
- filteredDriftbottles: any[]=[];
|
|
|
- username: String='';
|
|
|
-
|
|
|
+ filteredDriftbottles2: any[] = [];
|
|
|
+ Driftbottles: any[] = [];
|
|
|
+ filteredDriftbottles: any[] = [];
|
|
|
+ username: string = '';
|
|
|
|
|
|
constructor(private router: Router, private userService: UserService) {}
|
|
|
|
|
@@ -35,32 +34,30 @@ export class MyDriftBottleComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
async getDriftbottles() {
|
|
|
- let query=new CloudQuery("Driftbottle");
|
|
|
- this.Driftbottles = await query.find();
|
|
|
- this.filterDriftbottles();
|
|
|
- this.filterDriftbottles2();
|
|
|
-
|
|
|
+ let query = new CloudQuery("Driftbottle");
|
|
|
+ this.Driftbottles = await query.find();
|
|
|
+ this.filterDriftbottles();
|
|
|
+ this.filterDriftbottles2();
|
|
|
}
|
|
|
|
|
|
filterDriftbottles() {
|
|
|
let user = new CloudUser();
|
|
|
- console.log(user)
|
|
|
+ console.log(user);
|
|
|
this.filteredDriftbottles = this.Driftbottles.filter(driftbottle => {
|
|
|
- console.log(driftbottle.get("username"), user.get("username"))
|
|
|
- return (driftbottle.get("username") === user.get("username") || driftbottle.get("username") === 'all');
|
|
|
+ console.log(driftbottle.get("username"), user.get("username"));
|
|
|
+ return driftbottle.get("username") === user.get("username") || driftbottle.get("username") === 'all';
|
|
|
});
|
|
|
}
|
|
|
- filterDriftbottles2(){
|
|
|
+
|
|
|
+ filterDriftbottles2() {
|
|
|
let user = new CloudUser();
|
|
|
- console.log(user)
|
|
|
+ console.log(user);
|
|
|
this.filteredDriftbottles2 = this.Driftbottles.filter(driftbottle => {
|
|
|
- console.log(driftbottle.get("catcher"), user.get("username"))
|
|
|
- return (driftbottle.get("catcher") === user.get("username") || driftbottle.get("catcher") === 'all');
|
|
|
+ console.log(driftbottle.get("catcher"), user.get("username"));
|
|
|
+ return driftbottle.get("catcher") === user.get("username") || driftbottle.get("catcher") === 'all';
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
goDriftbottle() {
|
|
|
this.router.navigate(['tabs/drift-bottle']);
|
|
|
}
|
|
@@ -68,4 +65,20 @@ export class MyDriftBottleComponent implements OnInit {
|
|
|
gothrowNewDriftbottle() {
|
|
|
this.router.navigate(['tabs/drift-bottle']); // 假设这是投掷新漂流瓶的路由
|
|
|
}
|
|
|
+
|
|
|
+ async rethrowBottle(bottle: CloudObject) {
|
|
|
+ try {
|
|
|
+ bottle.set({
|
|
|
+ status: "drifting",
|
|
|
+ catcher: null,
|
|
|
+ catchtime: null
|
|
|
+ });
|
|
|
+
|
|
|
+ await bottle.save();
|
|
|
+ this.getDriftbottles(); // 刷新漂流瓶列表
|
|
|
+ console.log('漂流瓶扔回成功');
|
|
|
+ } catch (err) {
|
|
|
+ console.error('扔回漂流瓶时出错:', err);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|