<!--pages/farmer/detail/detail.wxml-->
<view class="container">
  <!-- 状态栏 -->
  <view class="status-bar" style="height: {{statusBarHeight}}px;"></view>
  
  <!-- 加载状态 -->
  <view wx:if="{{loading}}" class="loading-container">
    <view class="loading-spinner"></view>
    <text class="loading-text">加载中...</text>
  </view>
  
  <!-- 详情内容 -->
  <view wx:else class="detail-content">
    <!-- 基本信息卡片 -->
    <view class="info-card">
      <view class="card-header">
        <view class="farmer-name">{{farmerInfo.name}}</view>
        <view class="status-badge status-{{farmerInfo.status}}">
          {{farmerInfo.status === 'normal' ? '正常' : farmerInfo.status === 'error' ? '异常' : '待检查'}}
        </view>
      </view>
      
      <view class="info-grid">
        <view class="info-item">
          <view class="info-label">联系电话</view>
          <view class="info-value">{{farmerInfo.phone}}</view>
        </view>
        <view class="info-item">
          <view class="info-label">身份证号</view>
          <view class="info-value">{{farmerInfo.idCard}}</view>
        </view>
        <view class="info-item">
          <view class="info-label">所属区域</view>
          <view class="info-value">{{farmerInfo.area}}</view>
        </view>
        <view class="info-item">
          <view class="info-label">注册时间</view>
          <view class="info-value">{{farmerInfo.registerTime}}</view>
        </view>
      </view>
    </view>
    
    <!-- 养殖场信息 -->
    <view class="info-card">
      <view class="card-title">养殖场信息</view>
      <view class="info-grid">
        <view class="info-item">
          <view class="info-label">养殖场名称</view>
          <view class="info-value">{{farmerInfo.farmName}}</view>
        </view>
        <view class="info-item">
          <view class="info-label">养殖场地址</view>
          <view class="info-value">{{farmerInfo.farmAddress}}</view>
        </view>
        <view class="info-item">
          <view class="info-label">牲畜数量</view>
          <view class="info-value">{{farmerInfo.animalCount}}头</view>
        </view>
        <view class="info-item">
          <view class="info-label">牲畜类型</view>
          <view class="info-value">{{farmerInfo.animalType}}</view>
        </view>
      </view>
    </view>
    
    <!-- 联系信息 -->
    <view class="info-card">
      <view class="card-title">联系信息</view>
      <view class="info-grid">
        <view class="info-item">
          <view class="info-label">邮箱地址</view>
          <view class="info-value">{{farmerInfo.email || '未填写'}}</view>
        </view>
        <view class="info-item">
          <view class="info-label">紧急联系人</view>
          <view class="info-value">{{farmerInfo.emergencyContact || '未填写'}}</view>
        </view>
      </view>
    </view>
    
    <!-- 检查记录 -->
    <view class="info-card">
      <view class="card-title">
        <text>检查记录</text>
        <text class="record-count">({{checkRecords.length}}条)</text>
      </view>
      
      <view wx:if="{{checkRecords.length === 0}}" class="empty-records">
        <text>暂无检查记录</text>
      </view>
      
      <view wx:else class="records-list">
        <view 
          wx:for="{{checkRecords}}" 
          wx:key="id" 
          class="record-item"
        >
          <view class="record-header">
            <view class="record-time">{{item.checkTime}}</view>
            <view class="record-status status-{{item.result}}">
              {{item.result === 'normal' ? '正常' : item.result === 'warning' ? '警告' : '异常'}}
            </view>
          </view>
          <view class="record-content">
            <view class="record-inspector">检查员：{{item.inspector}}</view>
            <view class="record-desc">{{item.description}}</view>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 备注信息 -->
    <view wx:if="{{farmerInfo.remarks}}" class="info-card">
      <view class="card-title">备注信息</view>
      <view class="remarks-content">{{farmerInfo.remarks}}</view>
    </view>
  </view>
  
  <!-- 底部操作栏 -->
  <view class="bottom-bar">
    <button class="action-btn edit-btn" bindtap="onEdit">编辑信息</button>
    <button class="action-btn call-btn" bindtap="onCall">拨打电话</button>
    <button class="action-btn check-btn" bindtap="onAddCheck">添加检查</button>
  </view>
</view>