<view class="page-container">
  <view class="card pm-hero">
    <view class="pm-title">🎉 促销中心</view>
    <view class="pm-sub">秒杀 · 拼团 · 砍价 · 预售 · 领券 一站尽享</view>
  </view>

  <scroll-view class="pm-tabs" scroll-x enable-flex>
    <view
      class="pm-tab {{activeTab===item.v ? 'on' : ''}}"
      wx:for="{{tabs}}"
      wx:key="v"
      data-v="{{item.v}}"
      bindtap="switchTab"
    >{{item.label}}</view>
  </scroll-view>

  <view class="pm-list">
    <view
      class="card pm-item"
      wx:for="{{filtered}}"
      wx:key="index"
      data-type="{{item.type}}"
      data-pid="{{item.product_id || item.id}}"
      bindtap="goActivity"
      wx:if="{{item.type!=='coupon'}}"
    >
      <image class="pm-image" src="{{item.image}}" mode="aspectFill" wx:if="{{item.image}}" />
      <view class="pm-image pm-image-ph" wx:else>{{item.type==='seckill'?'⚡':item.type==='groupon'?'🤝':item.type==='bargain'?'🔪':'🚀'}}</view>
      <view class="pm-info">
        <view class="pm-name text-ellipsis-2">{{item.name}}</view>
        <view class="pm-tag-row">
          <view class="pm-tag pm-tag-{{item.type}}">{{item.type==='seckill'?'秒杀':item.type==='groupon'?'拼团':item.type==='bargain'?'砍价':'预售'}}</view>
          <view class="pm-stock" wx:if="{{item.stock!=null}}">剩余 {{item.stock}} 件</view>
        </view>
        <view class="pm-price-row">
          <view class="pm-price"><text class="price-symbol">¥</text>{{item.price_fmt}}</view>
          <view class="pm-orig" wx:if="{{item.origin_price}}">原价 ¥{{item.origin_fmt}}</view>
        </view>
      </view>
      <view class="pm-go">去抢</view>
    </view>

    <view class="card pm-coupon" wx:for="{{filtered}}" wx:key="index-{{item.id}}" wx:if="{{item.type==='coupon'}}">
      <view class="pm-coupon-left">🎫</view>
      <view class="pm-coupon-info">
        <view class="pm-coupon-name">{{item.name}}</view>
        <view class="pm-coupon-detail">{{item.min_amount?'满'+item.min_amount_fmt+'可用 ':'不限'}}{{item.value?'减'+item.value_fmt+'元':''}}</view>
      </view>
      <button
        class="pm-coupon-btn {{item.claimed?'done':''}}"
        size="mini"
        data-id="{{item.id}}"
        catchtap="receiveCoupon"
        disabled="{{item.claimed}}"
      >{{item.claimed?'已领取':'领取'}}</button>
    </view>

    <empty-state wx:if="{{!loading && filtered.length===0}}" text="该分类暂无活动" />
  </view>
</view>
