<!-- points.wxml - 积点页 -->
<view class="container">
  <!-- 余额展示 -->
  <view class="card balance-card">
    <view class="text-center">
      <view class="text-hint" style="color: rgba(255,255,255,0.8);">可用积点</view>
      <view class="balance-value">{{balance.availablePoints || 0}}</view>
    </view>
    <view class="flex-between mt-32">
      <view class="text-center flex-1">
        <view class="text-bold" style="font-size: 36rpx; color: #fff;">{{balance.totalEarnedPoints || 0}}</view>
        <view style="font-size: 24rpx; color: rgba(255,255,255,0.8);">累计获得</view>
      </view>
      <view class="divider-vertical"></view>
      <view class="text-center flex-1">
        <view class="text-bold" style="font-size: 36rpx; color: #fff;">{{balance.totalRedeemedPoints || 0}}</view>
        <view style="font-size: 24rpx; color: rgba(255,255,255,0.8);">累计兑换</view>
      </view>
    </view>
    <view class="mt-24 text-center">
      <button class="btn btn-sm" style="background: rgba(255,255,255,0.2); color: #fff; display: inline-flex;" bindtap="goToCoupons">
        去兑换优惠券 →
      </button>
    </view>
  </view>

  <!-- 筛选标签 -->
  <view class="filter-tabs mt-24">
    <view
      class="filter-tab {{currentType === '' ? 'active' : ''}}"
      bindtap="filterByType"
      data-type=""
    >全部</view>
    <view
      class="filter-tab {{currentType === 'earn' ? 'active' : ''}}"
      bindtap="filterByType"
      data-type="earn"
    >邀请奖励</view>
    <view
      class="filter-tab {{currentType === 'redeem' ? 'active' : ''}}"
      bindtap="filterByType"
      data-type="redeem"
    >兑换记录</view>
    <view
      class="filter-tab {{currentType === 'commission' ? 'active' : ''}}"
      bindtap="filterByType"
      data-type="commission"
    >停车佣金</view>
  </view>

  <!-- 流水列表 -->
  <view class="transactions mt-24">
    <view
      class="tx-item card"
      wx:for="{{transactions}}"
      wx:key="id"
    >
      <view class="flex-between">
        <view class="flex-1">
          <view class="text-bold">{{item.description}}</view>
          <view class="text-hint mt-8" style="font-size: 24rpx;">{{item.created_at}}</view>
        </view>
        <view class="tx-amount {{item.points > 0 ? 'text-success' : 'text-danger'}}">
          {{item.points > 0 ? '+' : ''}}{{item.points}}
        </view>
      </view>
      <view class="text-hint mt-8" style="font-size: 24rpx;">
        余额：{{item.balance_after}} 积点
      </view>
    </view>

    <view class="empty" wx:if="{{transactions.length === 0 && !loading}}">
      <view class="empty-icon">📋</view>
      <view>暂无记录</view>
    </view>

    <view class="text-center mt-24" wx:if="{{hasMore}}">
      <button class="btn btn-outline btn-sm" bindtap="loadMore" loading="{{loadingMore}}">
        加载更多
      </button>
    </view>
  </view>
</view>
