<view class="exchanges-container">
  <view wx:if="{{exchanges.length > 0}}" class="exchanges-list">
    <view wx:for="{{exchanges}}" wx:key="id" class="exchange-card">
      <view class="card-header">
        <text class="order-number">订单号：{{item.order_number}}</text>
        <text class="status {{item.status}}">{{formatStatus(item.status)}}</text>
      </view>

      <view class="card-body">
        <image src="{{item.gift_image}}" class="gift-image" mode="aspectFill"></image>
        <view class="gift-info">
          <text class="gift-name">{{item.gift_name}}</text>
          <view class="gift-cost">
            <image src="/images/icon-heart.png" class="heart-icon" mode="aspectFit"></image>
            <text class="cost-text">{{item.love_cost}}</text>
          </view>
        </view>
      </view>

      <view class="card-footer">
        <view class="shipping-info">
          <text class="info-label">收货人：</text>
          <text class="info-value">{{item.shipping_name}}</text>
        </view>
        <view class="shipping-info">
          <text class="info-label">联系电话：</text>
          <text class="info-value">{{item.shipping_phone}}</text>
        </view>
        <view class="shipping-info">
          <text class="info-label">收货地址：</text>
          <text class="info-value">{{item.shipping_address}}</text>
        </view>
        <view wx:if="{{item.tracking_number}}" class="shipping-info">
          <text class="info-label">物流单号：</text>
          <text 
            class="info-value tracking" 
            data-tracking="{{item.tracking_number}}"
            bindtap="viewTracking"
          >
            {{item.tracking_number}}
          </text>
        </view>
        <view class="exchange-time">
          <text class="time-text">兑换时间：{{formatTime(item.created_at)}}</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 空状态 -->
  <view wx:else class="empty-state">
    <image src="/images/empty-exchanges.png" class="empty-icon" mode="aspectFit"></image>
    <text class="empty-text">暂无兑换记录</text>
    <button class="goto-shop-btn" bindtap="gotoShop">去兑换礼品</button>
  </view>

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