<!-- pages/qiangdan/qiangdan.wxml -->

<view class="qiangdan-page">

  <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="https://bintao.xmxym88.com/xcx/bintao/38.png" mode="aspectFit"/>
      <text class="xym-gonggao-txt">{{gonggao}}</text>
    </view>

    <!-- 被指定订单提醒 -->
    <view class="my-zhiding-banner" wx:if="{{myZhidingList.length > 0}}">
      <view class="my-zhiding-banner-head">
        <view class="my-zhiding-head-left">
          <text class="my-zhiding-badge">指定给您</text>
          <text class="my-zhiding-count-num">{{myZhidingCount || myZhidingList.length}}单</text>
        </view>
        <text class="my-zhiding-sub">请确认是否接待</text>
      </view>
      <view wx:for="{{myZhidingList}}" wx:key="dingdan_id" class="my-zhiding-card {{item.isHighlighted ? 'my-zhiding-card--highlight' : ''}}">
        <view class="my-zhiding-card-main" data-item="{{item}}" bindtap="openZhidingDetail">
          <view class="my-zhiding-card-top">
            <text class="my-zhiding-order-id">单号 {{item.dingdan_id}}</text>
            <text class="my-zhiding-reward">¥{{item.dashou_fencheng || 0}}</text>
          </view>
          <text class="my-zhiding-desc line2">{{item.jieshao || '暂无介绍'}}</text>
          <text class="my-zhiding-status" wx:if="{{item.zhiding_hf_text}}">您的回复：{{item.zhiding_hf_text}}{{item.zhiding_dhj_sm ? ' · ' + item.zhiding_dhj_sm : ''}}</text>
        </view>
        <view class="my-zhiding-actions">
          <view class="zhiding-act zhiding-act--ghost" data-item="{{item}}" catchtap="onZhidingReject">不想接</view>
          <view class="zhiding-act zhiding-act--ghost" data-item="{{item}}" catchtap="onZhidingLater">等会接</view>
          <view class="zhiding-act zhiding-act--primary" data-item="{{item}}" catchtap="onZhidingAccept">立即接待</view>
        </view>
      </view>
    </view>

    <!-- 商品轮播（只读 globalData，与点单端同源） -->

    <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="xym-section-gap" wx:if="{{lunboList.length > 0}}"></view>

    <!-- 商品类型选择 -->

    <view class="leixing-quyu dingdanxiang1 filter-card mx20">

      <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 {{item.isMyZhiding ? 'order-my-zhiding' : ''}} {{item.isHighlighted ? 'order-zhiding-highlight' : ''}}" 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">

              <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>

              <block wx:if="{{item.isZhiding}}">
                <view class="zhiding-strip light">
                  <view class="zhiding-strip-top myflex">
                    <text class="zhiding-label">指定</text>
                    <image class="zhiding-avatar" src="{{item.zhiding_avatar_full || defaultAvatarUrl}}" 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="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">{{item.isMyZhiding ? '立即接待' : '抢单'}}</view>

              </view>

            </view>

          </view>

        </view>



        <!-- 优质商家订单（金牌卡片） -->
        <view wx:elif="{{item.isShangjia && item.shangjia_youzhi}}" class="xym-order-item gold-card {{item.isMyZhiding ? 'order-my-zhiding' : ''}} {{item.isHighlighted ? 'order-zhiding-highlight' : ''}}" data-item="{{item}}">
          <view class="gold-head flexb">
            <view class="kehuduan-banner-wrap">
              <image class="gold-banner" src="https://bintao.xmxym88.com/xcx/bintao/82.png" mode="widthFix"/>
            </view>
          </view>
          <view class="gold-body-wrap">
            <view class="order-con gold-inner">
              <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>
              <block wx:if="{{item.isZhiding}}">
                <view class="zhiding-strip">
                  <view class="zhiding-strip-top myflex">
                    <text class="zhiding-label">指定</text>
                    <image class="zhiding-avatar" src="{{item.zhiding_avatar_full || defaultAvatarUrl}}" 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="reward-badge normal-reward gold-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 dark-t">商家备注：</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" src="{{item.shangjia_avatar_full}}" mode="aspectFill"/>
                  <view class="m-info">
                    <view class="m-name m-name-light line1">{{item.sjnicheng || '未知商家'}}</view>
                    <view class="m-sn m-sn-light">发布于 {{item.creat_time}}</view>
                  </view>
                </view>
                <view class="qiangdan flexa btn-bg btn-qiang" data-item="{{item}}" bindtap="onQiangdanTap">{{item.isMyZhiding ? '立即接待' : '抢单'}}</view>
              </view>
              <view class="o-foot flexb kehuduan-foot gold-foot-text-only">
                <text class="o-amt-grey">商家派单</text>
              </view>
            </view>
          </view>
        </view>

        <!-- 商家订单（逍遥梦卡片布局） -->

        <view wx:elif="{{item.isShangjia}}" class="xym-order-item xym-shangjia-order {{item.isMyZhiding ? 'order-my-zhiding' : ''}} {{item.isHighlighted ? 'order-zhiding-highlight' : ''}}" 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 class="zhiding-avatar" src="{{item.zhiding_avatar_full || defaultAvatarUrl}}" 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="merchant-line myflex">

                <image class="m-avatar-sm" src="{{item.shangjia_avatar_full}}" mode="aspectFill"/>

                <text class="m-name-sm">{{item.sjnicheng || '未知商家'}}</text>

              </view>

              <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">{{item.isMyZhiding ? '立即接待' : '抢单'}}</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>



  <global-notification id="global-notification" />

  <kefu-float bottom="200rpx" />

  <popup-notice id="popupNotice" />

  <!-- 指定单详情 -->
  <view class="zhiding-modal-mask" wx:if="{{showZhidingDetail}}" catchtap="closeZhidingDetail">
    <view class="zhiding-modal" catchtap="noop">
      <view class="zhiding-modal-head">
        <text class="zhiding-modal-title">指定订单详情</text>
        <text class="zhiding-modal-close" catchtap="closeZhidingDetail">×</text>
      </view>
      <view class="zhiding-modal-body" wx:if="{{zhidingDetailOrder}}">
        <view class="zhiding-modal-row"><text class="lbl">单号</text><text>{{zhidingDetailOrder.dingdan_id}}</text></view>
        <view class="zhiding-modal-row"><text class="lbl">分成</text><text class="reward">¥{{zhidingDetailOrder.dashou_fencheng || 0}}</text></view>
        <view class="zhiding-modal-row col"><text class="lbl">介绍</text><text>{{zhidingDetailOrder.jieshao || '暂无'}}</text></view>
        <view class="zhiding-modal-row col" wx:if="{{zhidingDetailOrder.beizhu}}"><text class="lbl">备注</text><text>{{zhidingDetailOrder.beizhu}}</text></view>
        <view class="zhiding-modal-row" wx:if="{{zhidingDetailOrder.zhiding_hf_text}}"><text class="lbl">您的回复</text><text>{{zhidingDetailOrder.zhiding_hf_text}}</text></view>
      </view>
      <view class="my-zhiding-actions zhiding-modal-actions" wx:if="{{zhidingDetailOrder}}">
        <view class="zhiding-act zhiding-act--ghost" data-item="{{zhidingDetailOrder}}" catchtap="onZhidingReject">不想接</view>
        <view class="zhiding-act zhiding-act--ghost" data-item="{{zhidingDetailOrder}}" catchtap="onZhidingLater">等会接</view>
        <view class="zhiding-act zhiding-act--primary" data-item="{{zhidingDetailOrder}}" catchtap="onZhidingAccept">立即接待</view>
      </view>
    </view>
  </view>

  <!-- 等会接时间 -->
  <view class="zhiding-modal-mask zhiding-modal-mask--top" wx:if="{{showLaterModal}}" catchtap="closeLaterModal">
    <view class="zhiding-modal zhiding-modal--sm" catchtap="noop">
      <view class="zhiding-modal-head">
        <text class="zhiding-modal-title">等会接</text>
        <text class="zhiding-modal-close" catchtap="closeLaterModal">×</text>
      </view>
      <view class="zhiding-modal-body">
        <text class="later-hint">请填写预计接待时间，例如「30分钟后」「今晚8点」</text>
        <input
          class="later-input"
          placeholder="预计接待时间"
          placeholder-class="later-input-ph"
          value="{{laterNote}}"
          bindinput="onLaterNoteInput"
          maxlength="50"
          focus="{{showLaterModal}}"
          adjust-position="{{true}}"
          confirm-type="done"
          bindconfirm="confirmZhidingLater"
        />
      </view>
      <view class="later-confirm" catchtap="confirmZhidingLater">确认</view>
    </view>
  </view>

  <tab-bar />

</view>


