<!-- 商家中心首页 - 逍遥梦布局，功能/接口不变 -->
<view class="sj-page sj-page--home">
  <view class="sj-page-header">
    <view class="status-bar" style="height:{{statusBar}}px"></view>
    <view class="nav-bar flexm" style="height:{{navBar - statusBar}}px">
      <text class="sj-nav-title">商家中心</text>
    </view>
  </view>

  <block wx:if="{{!isShangjia && !isStaffMode}}">
    <view class="guest-box sj-mx20 sj-panel">
      <text class="guest-title">商家入驻</text>
      <text class="guest-desc">完成入驻后可发单、管理订单</text>
      <view class="sj-btn-bg guest-btn flexm" bindtap="goRegister">去入驻</view>
    </view>
    <tab-bar/>
  </block>

  <block wx:else>
    <view class="sj-main-body">
      <view class="sj-notice-bar" wx:if="{{gonggao}}">
        <image class="notice-ico" src="{{imgUrls.noticeIco}}" mode="aspectFit"/>
        <text class="sj-notice-txt">{{gonggao}}</text>
      </view>

      <view class="swiper-wrap" wx:if="{{lunboList.length}}">
        <view class="swiper-con">
          <swiper class="banner-swiper" autoplay circular interval="4000" duration="500" bindchange="onSwiperChange">
            <swiper-item wx:for="{{lunboList}}" wx:key="index">
              <image class="slide-image" src="{{item}}" mode="aspectFill"/>
            </swiper-item>
          </swiper>
          <view class="dots flexm">
            <view wx:for="{{lunboList}}" wx:key="index" class="dot {{swiperCurrent===index?'active':''}}"></view>
          </view>
        </view>
      </view>
      <view class="swiper-wrap" wx:else>
        <image class="slide-image banner-placeholder" src="{{lunbozhanwei}}" mode="aspectFill"/>
      </view>

      <view class="staff-banner sj-mx20" wx:if="{{isStaffMode}}">
        <text class="staff-banner-txt">商家客服 · {{staffRoleName}} · 可用额度 ¥{{quotaAvailable}}</text>
      </view>

      <view class="sj-fadan-block" wx:if="{{canDispatch}}">
        <view class="sj-fadan-row">
          <view class="sj-fadan-img-btn sj-fadan-img-btn--left" bindtap="goRegularDispatch"/>
          <view class="sj-fadan-img-btn sj-fadan-img-btn--right" bindtap="goCustomDispatch"/>
        </view>
        <view class="sj-fadan-row sj-fadan-row--link">
          <view class="sj-fadan-big-btn sj-fadan-big-btn--link" bindtap="goLinkDispatch">
            <text class="sj-fadan-big-title">链接派单</text>
            <text class="sj-fadan-big-sub">模板管理 · 生成链接</text>
          </view>
        </view>
      </view>

      <view class="merchant-stats shadow">
        <view class="merchant-stats-bg" style="background-image:url({{imgUrls.statCardBg}})"></view>
        <view class="merchant-stats-inner">
          <view class="stats-hd flexb">
            <text class="stats-hd-sp"></text>
            <text class="stats-more" bindtap="goOrdersTab">查看更多</text>
          </view>
          <view class="stats-row flexa">
            <view class="stat-col stat-col--l" bindtap="goPendingOrders">
              <text class="stat-lbl">待结算订单(数)</text>
              <text class="stat-num">{{stats.pendingCount}}</text>
            </view>
            <view class="stat-divider"></view>
            <view class="stat-col stat-col--r">
              <text class="stat-lbl">待结算金额(元)</text>
              <text class="stat-num">{{stats.pendingAmount}}</text>
            </view>
          </view>
          <view class="stats-row flexa stats-row--gap">
            <view class="stat-col stat-col--l">
              <text class="stat-lbl">今日派单(数)</text>
              <text class="stat-num">{{stats.todayDispatch}}</text>
            </view>
            <view class="stat-divider"></view>
            <view class="stat-col stat-col--r">
              <text class="stat-lbl">今日退款(数)</text>
              <text class="stat-num">{{stats.todayRefund}}</text>
            </view>
          </view>
          <view class="stats-kefu-wrap" wx:if="{{canStaffManage}}">
            <view class="kefu-row-inset flexm">
              <view class="kefu-btn-inset" bindtap="goKefuKey">
                <image class="kefu-inset-img" src="{{imgUrls.kefuKeyBtn}}" mode="widthFix"/>
              </view>
              <view class="kefu-btn-inset kefu-btn-inset--right" bindtap="goKefuList">
                <image class="kefu-inset-img" src="{{imgUrls.kefuListBtn}}" mode="widthFix"/>
              </view>
            </view>
          </view>
        </view>
      </view>

      <view class="recent-box shadow">
        <view class="recent-hd flexb">
          <text class="recent-title">最近订单</text>
          <text class="recent-more" bindtap="goOrdersTab">查看更多</text>
        </view>
        <view wx:if="{{recentLoading && !recentOrders.length}}" class="recent-empty">加载中...</view>
        <block wx:elif="{{recentOrders.length}}">
          <view
            wx:for="{{recentOrders}}"
            wx:key="dingdan_id"
            class="recent-item flexb"
            bindtap="goOrderDetail"
            data-index="{{index}}"
          >
            <view class="recent-main">
              <text class="recent-name line2">{{item.title}}</text>
              <text class="recent-sub">{{item.time}} · {{item.status}}</text>
            </view>
            <text class="recent-money">¥{{item.money}}</text>
          </view>
        </block>
        <view wx:else class="recent-empty">暂无最近订单</view>
      </view>

      <view class="sj-scroll-bottom"></view>
    </view>
    <tab-bar/>
  </block>

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