import { Component, OnInit } from '@angular/core';
import { DataService } from '../data.service';
import { Title } from '@angular/platform-browser';

@Component({
  selector: 'app-tab14',
  templateUrl: './tab14.page.html',
  styleUrls: ['./tab14.page.scss'],
})
export class Tab14Page implements OnInit {

  replyContent: string = " ";
  activityItems: any[] = [];

  constructor(private dataService: DataService,private titleService: Title) {}

  ngOnInit() {
    this.activityItems = this.dataService.getActivityItems();
    // 假设helpItems是从DataService中获取的求助信息数组，确保数据已经被加载
    if (this.activityItems.length > 0) {
      this.titleService.setTitle(this.activityItems[0].title);
    }
  }

  submitReply(item: any) {
    if (this.replyContent.trim() !== '') {
      const reply = { content: this.replyContent, sender:"小序", floor: "" }; // 可以根据实际情况设置回复人,初始化楼层号
      this.dataService.addReplyActivityItems(item.id, reply);
      this.replyContent = ''; // 清空回复框
    }
  }

}
