<!--pages/business/loan-contracts/detail.wxml-->
<view class="contract-detail-container">
  <!-- 页面标题 -->
  <view class="page-header">
    <view class="header-title">合同详情</view>
  </view>

  <!-- 合同信息 -->
  <view class="contract-info" wx:if="{{contract}}">
    <view class="info-section">
      <view class="section-title">基本信息</view>
      
      <view class="info-item">
        <text class="info-label">合同编号：</text>
        <text class="info-value">{{contract.contractNumber}}</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">申请单号：</text>
        <text class="info-value">{{contract.applicationNumber || '暂无'}}</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">合同状态：</text>
        <view class="status-badge {{contract.status}}">
          <text>{{contract.statusText}}</text>
        </view>
      </view>
      
      <view class="info-item">
        <text class="info-label">合同类型：</text>
        <text class="info-value">{{contract.typeText}}</text>
      </view>
    </view>

    <view class="info-section">
      <view class="section-title">客户信息</view>
      
      <view class="info-item">
        <text class="info-label">客户姓名：</text>
        <text class="info-value">{{contract.customerName || '暂无'}}</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">客户ID：</text>
        <text class="info-value">{{contract.customerId || '暂无'}}</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">联系电话：</text>
        <text class="info-value">{{contract.phone || '暂无'}}</text>
      </view>
    </view>

    <view class="info-section">
      <view class="section-title">贷款信息</view>
      
      <view class="info-item">
        <text class="info-label">贷款金额：</text>
        <text class="info-value amount">{{contract.amount}}元</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">贷款期限：</text>
        <text class="info-value">{{contract.term}}个月</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">利率：</text>
        <text class="info-value">{{contract.interestRate}}%</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">产品名称：</text>
        <text class="info-value">{{contract.productName || '暂无'}}</text>
      </view>
    </view>

    <view class="info-section">
      <view class="section-title">时间信息</view>
      
      <view class="info-item">
        <text class="info-label">签订时间：</text>
        <text class="info-value">{{contract.signDate || '暂无'}}</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">到期时间：</text>
        <text class="info-value">{{contract.expiryDate || '暂无'}}</text>
      </view>
      
      <view class="info-item" wx:if="{{contract.completedTime}}">
        <text class="info-label">完成时间：</text>
        <text class="info-value">{{contract.completedTime}}</text>
      </view>
      
      <view class="info-item" wx:if="{{contract.disbursementTime}}">
        <text class="info-label">放款时间：</text>
        <text class="info-value">{{contract.disbursementTime}}</text>
      </view>
    </view>

    <view class="info-section">
      <view class="section-title">还款信息</view>
      
      <view class="info-item">
        <text class="info-label">已还金额：</text>
        <text class="info-value">{{contract.paidAmount || 0}}元</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">剩余金额：</text>
        <text class="info-value">{{contract.remainingAmount || 0}}元</text>
      </view>
      
      <view class="info-item">
        <text class="info-label">还款进度：</text>
        <view class="progress-container">
          <text class="progress-text">{{contract.repaymentProgress || 0}}%</text>
          <view class="progress-bar">
            <view class="progress-fill" style="width: {{contract.repaymentProgress || 0}}%"></view>
          </view>
        </view>
      </view>
    </view>

    <view class="info-section" wx:if="{{contract.assetType || contract.purpose || contract.remark}}">
      <view class="section-title">其他信息</view>
      
      <view class="info-item" wx:if="{{contract.assetType}}">
        <text class="info-label">资产类型：</text>
        <text class="info-value">{{contract.assetType}}</text>
      </view>
      
      <view class="info-item" wx:if="{{contract.purpose}}">
        <text class="info-label">申请用途：</text>
        <text class="info-value">{{contract.purpose}}</text>
      </view>
      
      <view class="info-item" wx:if="{{contract.remark}}">
        <text class="info-label">备注：</text>
        <text class="info-value">{{contract.remark}}</text>
      </view>
    </view>
  </view>

  <!-- 加载状态 -->
  <view class="loading" wx:if="{{loading}}">
    <text>加载中...</text>
  </view>

  <!-- 错误状态 -->
  <view class="error-state" wx:if="{{error}}">
    <text class="error-icon">❌</text>
    <text class="error-text">{{error}}</text>
    <button class="retry-btn" bindtap="retryLoadContractDetail">重试</button>
  </view>
</view>
