<!-- pages/order-pool/order-pool.wxml 抢单池（逍遥梦布局） -->
<view class="qiangdan-page">
  <view class="unauthorized-container" wx:if="{{showUnauthorized}}">
    <view class="unauthorized-card">
      <view class="card-glow"></view>
      <view class="card-content-unauth">
        <view class="icon-lock"></view>
        <text class="title">功能未开启</text>
        <text class="message">{{unauthorizedMsg}}</text>
        <text class="description">请先注册为服务者，即可使用抢单功能</text>
        <view class="btn-register" bindtap="goToDashouRegister">
          <text class="btn-text">立即注册</text>
          <view class="btn-shine"></view>
        </view>
      </view>
    </view>
  </view>

  <block wx:else>
    <view class="refresh-float" wx:if="{{xuanzhongLeixingId}}" bindtap="onTapRefresh">
      <image class="refresh-float-ico" src="{{iconRefresh}}" mode="aspectFit"/>
    </view>

    <scroll-view
      class="page-main-scroll"
      scroll-y
      enhanced
      show-scrollbar="{{false}}"
      refresher-enabled="{{xuanzhongLeixingId != null}}"
      refresher-threshold="80"
      refresher-default-style="black"
      refresher-background="#fff8e1"
      refresher-triggered="{{scrollViewRefreshing}}"
      bindrefresherrefresh="onPullDownRefresh"
      bindscrolltolower="onReachBottom"
    >
      <view class="refresher-container" slot="refresher">
        <text wx:if="{{scrollViewRefreshing}}" class="refreshing-text">正在刷新...</text>
        <text wx:else class="pull-down-text">下拉刷新订单</text>
      </view>

      <!-- 公告置顶（逍遥梦：轮播之上） -->
      <view class="xym-gonggao-bar" wx:if="{{gonggao}}">
        <image class="xym-gonggao-ico" src="/images/notice.png" mode="aspectFit"/>
        <text class="xym-gonggao-txt">{{gonggao}}</text>
      </view>

      <!-- 轮播 -->
      <view class="xym-lunbo-container" wx:if="{{lunboList.length > 0}}">
        <swiper
          class="xym-lunbo-swiper"
          indicator-dots="{{lunboList.length > 1}}"
          indicator-color="rgba(255,255,255,0.6)"
          indicator-active-color="#ffd061"
          autoplay="{{lunboList.length > 1}}"
          interval="4000"
          circular
        >
          <block wx:for="{{lunboList}}" wx:key="index">
            <swiper-item>
              <image class="xym-lunbo-image" src="{{item}}" mode="aspectFill"/>
            </swiper-item>
          </block>
        </swiper>
      </view>

      <!-- 商品类型 -->
      <view class="leixing-quyu">
        <scroll-view class="leixing-scroll" scroll-x enhanced show-scrollbar="{{false}}">
          <view class="leixing-container">
            <block wx:for="{{shangpinleixing}}" wx:key="id">
              <view
                class="leixing-item {{xuanzhongLeixingId == item.id ? 'leixing-active' : ''}}"
                data-id="{{item.id}}"
                bindtap="selectLeixing"
              >
                <view wx:if="{{xuanzhongLeixingId == item.id}}" class="guangyun-effect"></view>
                <image class="leixing-tupian" src="{{item.full_tupian_url}}" mode="aspectFill"/>
                <text class="leixing-jieshao">{{item.jieshao}}</text>
              </view>
            </block>
          </view>
        </scroll-view>
      </view>

      <!-- 标签筛选 -->
      <view class="biaoqian-quyu" wx:if="{{bankuaiBiaoqian.length > 0}}">
        <scroll-view class="biaoqian-scroll" scroll-x enhanced show-scrollbar="{{false}}">
          <view class="biaoqian-container">
            <view class="biaoqian-item {{xuanzhongBiaoqianId == 0 ? 'biaoqian-active' : ''}}" data-id="0" bindtap="selectBiaoqian">
              <text class="quanbu-text">全部</text>
            </view>
            <block wx:for="{{bankuaiBiaoqian}}" wx:key="id">
              <view class="biaoqian-item {{xuanzhongBiaoqianId == item.id ? 'biaoqian-active' : ''}}" data-id="{{item.id}}" bindtap="selectBiaoqian">
                <chenghao-tag mingcheng="{{item.mingcheng}}" texiaoJson="{{item.texiao_json}}" />
              </view>
            </block>
          </view>
        </scroll-view>
      </view>

      <view class="fenge-xian"></view>

      <!-- 订单列表 -->
      <view class="dingdan-list">
        <view wx:if="{{!xuanzhongLeixingId}}" class="empty-tip">
          <image src="/images/icon_select.png" class="tip-icon"></image>
          <text class="tip-text">请先选择上方订单类型</text>
        </view>
        <view wx:elif="{{dingdanList.length === 0 && !isLoading}}" class="empty-tip">
          <image src="/images/icon_empty_order.png" class="tip-icon"></image>
          <text class="tip-text">当前类型暂无待抢订单</text>
        </view>

        <block wx:for="{{dingdanList}}" wx:key="dingdan_id">
          <!-- 平台订单 -->
          <view wx:if="{{item.isPingtai}}" class="xym-order-item xym-pingtai-order" data-item="{{item}}">
            <view class="xym-pingtai-head flexb">
              <text class="xym-head-time">{{item.creat_time}}</text>
              <view class="xym-head-tag">平台订单</view>
            </view>
            <view class="xym-pingtai-body">
              <view class="order-con">
                <block wx:if="{{item.isZhiding}}">
                  <view class="zhiding-strip light">
                    <view class="zhiding-strip-top myflex">
                      <text class="zhiding-label">指定</text>
                      <image wx:if="{{item.zhiding_avatar_full}}" class="zhiding-avatar" src="{{item.zhiding_avatar_full}}" mode="aspectFill"/>
                      <text class="zhiding-name">{{item.zhiding_nicheng || '指定接单员'}}</text>
                    </view>
                    <view wx:if="{{item.dashou_biaoqian.length > 0 || item.zhiding_identity_biaoqian.length > 0}}" class="zhiding-strip-tags">
                      <chenghao-tag wx:for="{{item.dashou_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                      <chenghao-tag wx:for="{{item.zhiding_identity_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </view>
                </block>
                <view class="order-row myflex">
                  <image class="o-logo" src="{{item.full_tupian_url}}" mode="aspectFill"/>
                  <view class="o-col">
                    <view class="o-goods light line2" data-type="jieshao" data-content="{{item.jieshao}}" bindtap="onViewDetail">{{item.jieshao || '暂无介绍'}}</view>
                  </view>
                </view>
                <view class="reward-badge platform-reward" wx:if="{{item.hasRequiredMember}}">
                  <text class="reward-yen sm">￥</text>
                  <text class="reward-num">{{item.dashou_fencheng || 0}}</text>
                </view>
                <view class="reward-badge member-tip" wx:else>
                  <text class="reward-tip">未开通会员</text>
                </view>
                <view class="remark-block gold" data-type="beizhu" data-content="{{item.beizhu}}" bindtap="onViewDetail">
                  <text class="remark-label">备注：</text>{{item.beizhu || '暂无'}}
                </view>
                <view wx:if="{{item.xuqiu_biaoqian.length > 0}}" class="xuqiu-tags-row">
                  <text class="xuqiu-label">需求标签</text>
                  <scroll-view class="biaoqian-inline-scroll" scroll-x enable-flex>
                    <view class="biaoqian-inline-inner">
                      <chenghao-tag wx:for="{{item.xuqiu_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </scroll-view>
                </view>
                <view class="o-foot flexb">
                  <text class="o-amt light">平台派单</text>
                  <view class="qiangdan flexa btn-bg btn-qiang btn-qiang-brown" data-item="{{item}}" bindtap="onQiangdanTap">抢单</view>
                </view>
              </view>
            </view>
          </view>

          <!-- 优质商家金牌卡 -->
          <view wx:elif="{{item.isShangjia && item.shangjia_youzhi}}" class="xym-order-item gold-card" data-item="{{item}}">
            <view class="gold-head flexb">
              <view class="kehuduan-banner-wrap">
                <image class="gold-banner" src="{{goldBannerUrl}}" mode="widthFix"/>
              </view>
            </view>
            <view class="gold-body-wrap">
              <view class="order-con gold-inner">
                <block wx:if="{{item.isZhiding}}">
                  <view class="zhiding-strip">
                    <view class="zhiding-strip-top myflex">
                      <text class="zhiding-label">指定</text>
                      <image wx:if="{{item.zhiding_avatar_full}}" class="zhiding-avatar" src="{{item.zhiding_avatar_full}}" mode="aspectFill"/>
                      <text class="zhiding-name">{{item.zhiding_nicheng || '指定接单员'}}</text>
                    </view>
                    <view wx:if="{{item.dashou_biaoqian.length > 0 || item.zhiding_identity_biaoqian.length > 0}}" class="zhiding-strip-tags">
                      <chenghao-tag wx:for="{{item.dashou_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                      <chenghao-tag wx:for="{{item.zhiding_identity_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </view>
                </block>
                <view class="order-row myflex">
                  <image class="o-logo" src="{{item.leixing_icon_url}}" mode="aspectFill"/>
                  <view class="o-col">
                    <view class="o-goods line2" data-type="jieshao" data-content="{{item.jieshao}}" bindtap="onViewDetail">{{item.jieshao || '暂无介绍'}}</view>
                    <view class="tag-row myflex">
                      <text class="tag-pill tag-youzhi">优质商家</text>
                    </view>
                  </view>
                </view>
                <view class="reward-badge normal-reward" wx:if="{{item.hasRequiredMember}}">
                  <text class="reward-yen sm">￥</text>
                  <text class="reward-num dark">{{item.dashou_fencheng || 0}}</text>
                </view>
                <view class="reward-badge member-tip" wx:else>
                  <text class="reward-tip">未开通会员</text>
                </view>
                <view class="remark-block dark" data-type="beizhu" data-content="{{item.beizhu}}" bindtap="onViewDetail">
                  <text class="remark-label">商家备注：</text>{{item.beizhu || '暂无'}}
                </view>
                <view wx:if="{{item.shangjia_biaoqian.length > 0 || item.shangjia_identity_biaoqian.length > 0 || item.xuqiu_biaoqian.length > 0}}" class="xuqiu-tags-row">
                  <scroll-view wx:if="{{item.shangjia_biaoqian.length > 0}}" class="biaoqian-inline-scroll" scroll-x enable-flex>
                    <view class="biaoqian-inline-inner">
                      <chenghao-tag wx:for="{{item.shangjia_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </scroll-view>
                  <scroll-view wx:if="{{item.shangjia_identity_biaoqian.length > 0}}" class="biaoqian-inline-scroll" scroll-x enable-flex style="margin-top:8rpx">
                    <view class="biaoqian-inline-inner">
                      <chenghao-tag wx:for="{{item.shangjia_identity_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </scroll-view>
                  <scroll-view wx:if="{{item.xuqiu_biaoqian.length > 0}}" class="biaoqian-inline-scroll" scroll-x enable-flex style="margin-top:8rpx">
                    <view class="biaoqian-inline-inner">
                      <chenghao-tag wx:for="{{item.xuqiu_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </scroll-view>
                </view>
                <view class="merchant-plain flexb">
                  <view class="merchant-user myflex">
                    <image class="m-avatar-sm" src="{{item.shangjia_avatar_full}}" mode="aspectFill"/>
                    <view class="m-info">
                      <text class="m-name-sm">{{item.sjnicheng || '未知商家'}}</text>
                      <text class="m-sn-light">发布于 {{item.creat_time}}</text>
                    </view>
                  </view>
                  <view class="qiangdan flexa btn-bg btn-qiang" data-item="{{item}}" bindtap="onQiangdanTap">抢单</view>
                </view>
                <view class="o-foot flexb gold-foot-text-only">
                  <text class="o-amt">商家派单</text>
                </view>
              </view>
            </view>
          </view>

          <!-- 普通商家订单 -->
          <view wx:elif="{{item.isShangjia}}" class="xym-order-item xym-shangjia-order" data-item="{{item}}">
            <view class="xym-shangjia-head flexb">
              <text class="xym-head-time">{{item.creat_time}}</text>
              <view class="xym-head-tag">商家发单</view>
            </view>
            <view class="xym-shangjia-body">
              <view class="order-con">
                <block wx:if="{{item.isZhiding}}">
                  <view class="zhiding-strip">
                    <view class="zhiding-strip-top myflex">
                      <text class="zhiding-label">指定</text>
                      <image wx:if="{{item.zhiding_avatar_full}}" class="zhiding-avatar" src="{{item.zhiding_avatar_full}}" mode="aspectFill"/>
                      <text class="zhiding-name">{{item.zhiding_nicheng || '指定接单员'}}</text>
                    </view>
                    <view wx:if="{{item.dashou_biaoqian.length > 0 || item.zhiding_identity_biaoqian.length > 0}}" class="zhiding-strip-tags">
                      <chenghao-tag wx:for="{{item.dashou_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                      <chenghao-tag wx:for="{{item.zhiding_identity_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </view>
                </block>
                <view class="order-row myflex">
                  <view class="o-col">
                    <view class="o-goods line2" data-type="jieshao" data-content="{{item.jieshao}}" bindtap="onViewDetail">{{item.jieshao || '暂无介绍'}}</view>
                  </view>
                </view>
                <view class="reward-badge normal-reward" wx:if="{{item.hasRequiredMember}}">
                  <text class="reward-yen sm">￥</text>
                  <text class="reward-num dark">{{item.dashou_fencheng || 0}}</text>
                </view>
                <view class="reward-badge member-tip" wx:else>
                  <text class="reward-tip">未开通会员</text>
                </view>
                <view class="remark-block dark" data-type="beizhu" data-content="{{item.beizhu}}" bindtap="onViewDetail">
                  <text class="remark-label">商家备注：</text>{{item.beizhu || '暂无'}}
                </view>
                <view wx:if="{{item.shangjia_biaoqian.length > 0 || item.shangjia_identity_biaoqian.length > 0 || item.xuqiu_biaoqian.length > 0}}" class="xuqiu-tags-row">
                  <scroll-view wx:if="{{item.shangjia_biaoqian.length > 0}}" class="biaoqian-inline-scroll" scroll-x enable-flex>
                    <view class="biaoqian-inline-inner">
                      <chenghao-tag wx:for="{{item.shangjia_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </scroll-view>
                  <scroll-view wx:if="{{item.shangjia_identity_biaoqian.length > 0}}" class="biaoqian-inline-scroll" scroll-x enable-flex style="margin-top:8rpx">
                    <view class="biaoqian-inline-inner">
                      <chenghao-tag wx:for="{{item.shangjia_identity_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </scroll-view>
                  <scroll-view wx:if="{{item.xuqiu_biaoqian.length > 0}}" class="biaoqian-inline-scroll" scroll-x enable-flex style="margin-top:8rpx">
                    <view class="biaoqian-inline-inner">
                      <chenghao-tag wx:for="{{item.xuqiu_biaoqian}}" wx:for-item="tag" wx:key="id" mingcheng="{{tag.mingcheng}}" texiaoJson="{{tag.texiao_json}}" />
                    </view>
                  </scroll-view>
                </view>
                <view class="o-foot flexb">
                  <text class="o-amt">商家派单</text>
                  <view class="qiangdan flexa btn-bg btn-qiang" data-item="{{item}}" bindtap="onQiangdanTap">抢单</view>
                </view>
              </view>
            </view>
          </view>
        </block>

        <view wx:if="{{isLoadingMore && dingdanList.length > 0}}" class="loading-more">
          <text class="loading-text">加载更多订单中...</text>
        </view>
        <view wx:if="{{!hasMore && dingdanList.length > 0}}" class="no-more">
          <text class="no-more-text">—— 没有更多订单了 ——</text>
        </view>
      </view>

      <view class="scroll-bottom-spacer"></view>
    </scroll-view>

    <view wx:if="{{isLoading && dingdanList.length === 0 && xuanzhongLeixingId}}" class="loading-mask">
      <view class="loading-spinner"></view>
      <text class="loading-mask-text">订单加载中...</text>
    </view>
  </block>

  <global-notification id="global-notification" />
  <popup-notice id="popupNotice" />
</view>
