<ion-header>
  <ion-toolbar>
    <ion-title>我的需求</ion-title>
    <ion-buttons slot="end">
      <ion-button (click)="importTestData()">
        <ion-icon slot="icon-only" name="cloud-upload"></ion-icon>
        测
      </ion-button>
    </ion-buttons>
  </ion-toolbar>
</ion-header>

<ion-content class="ion-padding">
  <ion-segment value="inProgress">
    <ion-segment-button value="inProgress" (click)="navigateTo('inProgress')">
      <ion-label>进行中</ion-label>
    </ion-segment-button>
    <ion-segment-button value="completed" (click)="navigateTo('completed')">
      <ion-label>已完成</ion-label>
    </ion-segment-button>
    <ion-segment-button value="pending" (click)="navigateTo('pending')">
      <ion-label>待领取</ion-label>
    </ion-segment-button>
  </ion-segment>

  <!-- 进行中任务列表 -->
  <ion-list>
    <ion-item *ngFor="let item of taskList">
      <ion-avatar slot="start">
        <img [src]="item.userAvatar"> <!-- 使用固定头像 -->
      </ion-avatar>
      <ion-label>
        <h2>{{item.userName}}</h2>
        <p>{{item.description}}</p>
        <p *ngIf="currentStatus === 'inProgress'">开始时间: {{item.time | date:'yyyy-MM-dd HH:mm'}}</p>
        <p *ngIf="currentStatus === 'completed'">开始时间: {{item.startTime | date:'yyyy-MM-dd HH:mm'}}</p>
        <p *ngIf="currentStatus === 'pending'">发布时间: {{item.time | date:'yyyy-MM-dd HH:mm'}}</p>
        <p *ngIf="item.endTime">完成时间: {{item.endTime | date:'yyyy-MM-dd HH:mm'}}</p>
        <ion-badge [color]="item.type === 'urgent' ? 'danger' : 'primary'">
          {{item.type === 'urgent' ? '紧急' : '普通'}}
        </ion-badge>
      </ion-label>
      <ion-badge slot="end" color="primary">{{item.points}}积分</ion-badge>
      <ion-button *ngIf="currentStatus === 'inProgress'" slot="end" fill="clear" (click)="completeTask(item)">
        <ion-icon name="checkmark-circle" slot="icon-only"></ion-icon>
        结束
      </ion-button>
      <ion-button *ngIf="currentStatus === 'inProgress'" slot="end" fill="clear" (click)="startChat(item)">
        <ion-icon name="chatbubble" slot="icon-only"></ion-icon>
        联系
      </ion-button>
    </ion-item>
  </ion-list>
</ion-content>

<!-- 添加在页面底部 -->
<div class="add-button" (click)="navigateToCreate()">
  <ion-icon name="add"></ion-icon>
</div>
<!-- 已清空所有内容 -->


