<!-- 首页：搜索 + 分类 + 两列商品瀑布 -->
<view class="home">

  <!-- 搜索框 -->
  <view class="search-bar">
    <view class="search-box">
      <text class="search-ico">🔍</text>
      <input class="search-input" placeholder="搜索二手衣物、品牌" value="{{keyword}}" bindinput="onSearchInput" confirm-type="search" bindconfirm="onSearch" />
      <text wx:if="{{keyword}}" class="search-clear" bindtap="clearSearch">✕</text>
    </view>
    <text class="search-btn" bindtap="onSearch">搜索</text>
  </view>

  <!-- 分类横向滚动 -->
  <scroll-view scroll-x class="cat-scroll" wx:if="{{categories.length}}">
    <view class="cat-item {{activeCat==0?'active':''}}" bindtap="switchCat" data-id="0">全部</view>
    <view class="cat-item {{activeCat==item.id?'active':''}}" wx:for="{{categories}}" wx:key="id" bindtap="switchCat" data-id="{{item.id}}">{{item.name}}</view>
  </scroll-view>

  <!-- 商品两列 -->
  <view class="goods-grid" wx:if="{{goods.length}}">
    <view class="grid-col">
      <block wx:for="{{leftList}}" wx:key="id">
        <view class="goods-card" bindtap="goDetail" data-id="{{item.id}}">
          <view class="goods-thumb">
            <image src="{{item.images[0] || '/images/empty.png'}}" mode="aspectFill" />
            <view class="ribbon">{{item.degree}}</view>
            <view wx:if="{{item.is_sold}}" class="sold-mask">已卖出</view>
          </view>
          <view class="goods-info">
            <view class="goods-title">【{{item.degree}}】{{item.title}}</view>
            <view class="goods-meta">
              <text class="goods-price">¥{{item.price}}</text>
              <text class="goods-origin">¥{{item.origin_price}}</text>
            </view>
          </view>
        </view>
      </block>
    </view>
    <view class="grid-col">
      <block wx:for="{{rightList}}" wx:key="id">
        <view class="goods-card" bindtap="goDetail" data-id="{{item.id}}">
          <view class="goods-thumb">
            <image src="{{item.images[0] || '/images/empty.png'}}" mode="aspectFill" />
            <view class="ribbon">{{item.degree}}</view>
            <view wx:if="{{item.is_sold}}" class="sold-mask">已卖出</view>
          </view>
          <view class="goods-info">
            <view class="goods-title">【{{item.degree}}】{{item.title}}</view>
            <view class="goods-meta">
              <text class="goods-price">¥{{item.price}}</text>
              <text class="goods-origin">¥{{item.origin_price}}</text>
            </view>
          </view>
        </view>
      </block>
    </view>
  </view>

  <view wx:if="{{!goods.length && !loading}}" class="empty">暂无商品，下拉刷新试试~</view>
  <view wx:if="{{loading}}" class="empty">加载中...</view>
</view>
