<image class="page-bg" src="{{imgUrls.pageBg}}" mode="aspectFill" />

<!-- 未注册打手（无任何服务身份时显示） -->
<block wx:if="{{!isDashou && !isGuanshi && !isZuzhang && !isKaoheguan}}">
<view class="unreg-area">
  <view class="unreg-card">
    <text class="unreg-title">打手认证</text>
    <input class="unreg-input" type="text" placeholder="输入邀请码" maxlength="100" value="{{inviteCode}}" bindinput="onInviteCodeInput" placeholder-class="ph" />
    <view class="unreg-btn" bindtap="onRegister">
      <text class="unreg-btn-text">立即注册</text>
    </view>
    <view class="unreg-btn unreg-btn-secondary" bindtap="quickRegisterAsPlatform">
      <text class="unreg-btn-text">平台直签注册</text>
    </view>
    <view class="unreg-clear" bindtap="clearCache">
      <image class="unreg-clear-icon" src="{{imgUrls.iconClear}}" mode="aspectFit" />
      <text class="unreg-clear-text">清除缓存，回到点单端</text>
    </view>
  </view>
</view>
</block>

<!-- 已注册 -->
<block wx:else>
<view class="main-body {{layoutSparse ? 'layout-sparse-padding' : ''}}">
  <view class="refresh-btn" bindtap="onTapRefresh">
    <image class="refresh-icon" src="{{imgUrls.iconRefresh}}" mode="aspectFit" />
  </view>

  <view class="user-card">
    <image class="user-card-bg" src="{{imgUrls.userCardBg}}" mode="aspectFill" />
    <view class="user-card-inner">
      <image class="user-avatar" src="{{avatarUrl || imgUrls.avatarDefault}}" mode="aspectFill" bindtap="previewAvatar" />
      <view class="user-info">
        <view class="name-row">
          <text class="user-name">{{dashouNicheng || '打手'}}</text>
          <view class="role-tags">
            <view class="role-tag role-tag-dashou">打手</view>
            <view class="role-tag role-tag-guanshi" wx:if="{{isGuanshi}}">管事</view>
            <view class="role-tag role-tag-zuzhang" wx:if="{{isZuzhang}}">组长</view>
            <view class="role-tag role-tag-kaohe" wx:if="{{isKaoheguan}}">考核</view>
          </view>
        </view>
        <view class="uid-row" bindtap="copyUid">
          <text class="uid-text">UID: {{uid || '--'}}</text>
          <image class="copy-icon" src="{{imgUrls.iconCopy}}" mode="aspectFit" />
        </view>
      </view>
    </view>
  </view>

  <!-- 联系客服（企业微信） -->
  <view class="kefu-banner" bindtap="goToKefu">
    <image class="kefu-banner-bg" src="{{imgUrls.kefuBannerBg}}" mode="aspectFill" />
    <view class="kefu-banner-overlay"></view>
    <view class="kefu-banner-content">
      <view class="kefu-banner-left">
        <image class="kefu-banner-icon" src="{{imgUrls.iconKefu}}" mode="aspectFit" />
        <view class="kefu-banner-text">
          <text class="kefu-banner-title">在线客服</text>
          <text class="kefu-banner-sub">企业微信 · 即时响应</text>
        </view>
      </view>
      <view class="kefu-banner-btn">联系</view>
    </view>
  </view>

  <view class="badge-zone" wx:if="{{chenghaoList.length > 0 || (isGuanshi && guanshiChenghaoList.length > 0)}}">
    <scroll-view scroll-x class="badge-scroll" wx:if="{{chenghaoList.length > 0}}">
      <view class="badge-tag-wrap" wx:for="{{chenghaoList}}" wx:key="index">
        <chenghao-tag mingcheng="{{item.mingcheng}}" texiaoJson="{{item.texiao_json}}" />
      </view>
    </scroll-view>
    <scroll-view scroll-x class="badge-scroll badge-scroll-sub" wx:if="{{isGuanshi && guanshiChenghaoList.length > 0}}">
      <view class="badge-tag-wrap" wx:for="{{guanshiChenghaoList}}" wx:key="index">
        <chenghao-tag mingcheng="{{item.mingcheng}}" texiaoJson="{{item.texiao_json}}" />
      </view>
    </scroll-view>
  </view>

  <!-- 我的资产 -->
  <view class="section-card section-asset">
    <!-- 黑卡 VIP -->
    <view class="vip-black-card" bindtap="goToRecharge">
      <image class="vip-black-bg" src="{{imgUrls.vipCardBg}}" mode="aspectFill" />
      <view class="vip-black-overlay"></view>
      <view class="vip-black-body">
        <view class="vip-black-text">
          <text class="vip-black-title">会员充值</text>
          <text class="vip-black-sub">VIP 专属权益 · 尊享服务</text>
        </view>
        <view class="vip-black-action">
          <text class="vip-black-go">去充值</text>
        </view>
      </view>
    </view>

    <view class="asset-panel">
      <view class="asset-panel-fallback"></view>
      <image class="asset-panel-bg" src="{{imgUrls.assetPanelBg}}" mode="aspectFill" />
      <view class="asset-panel-inner">
        <view class="asset-panel-head">
          <image class="asset-panel-head-icon" src="{{imgUrls.iconSectionAsset}}" mode="aspectFit" />
          <text class="asset-panel-head-title">我的资产</text>
        </view>
        <view class="total-asset-row">
          <view class="total-asset-fallback"></view>
          <image class="total-asset-bg" src="{{imgUrls.totalAssetBg}}" mode="aspectFill" />
          <view class="total-asset-inner">
            <view class="total-asset-left">
              <text class="total-asset-label">总资产（可提现）</text>
              <text class="total-asset-val">¥{{totalAssets}}</text>
              <view class="asset-breakdown-list">
                <view class="asset-breakdown-line" wx:for="{{assetBreakdown}}" wx:key="label">
                  <text class="breakdown-name">{{item.label}}</text>
                  <text class="breakdown-amt">¥{{item.amount}}</text>
                </view>
              </view>
            </view>
            <view class="withdraw-btn" catchtap="goToTotalWithdraw">提现</view>
          </view>
        </view>
        <view class="stats-grid">
          <view class="mini-stat">
            <text class="mini-val">{{jinfen || '0'}}</text>
            <text class="mini-lbl">积分</text>
          </view>
          <view class="mini-stat">
            <text class="mini-val">{{yajin || '0.00'}}</text>
            <text class="mini-lbl">保证金</text>
          </view>
          <view class="mini-stat" wx:if="{{isGuanshi}}">
            <text class="mini-val">{{yaoqingzongshu || 0}}</text>
            <text class="mini-lbl">邀请总数</text>
          </view>
          <view class="mini-stat" wx:if="{{isGuanshi}}">
            <text class="mini-val">{{yichongzhiDashou || 0}}</text>
            <text class="mini-lbl">已充值</text>
          </view>
          <view class="mini-stat" wx:if="{{isGuanshi}}">
            <text class="mini-val">{{fenyongzonge || '0.00'}}</text>
            <text class="mini-lbl">分成总额</text>
          </view>
          <view class="mini-stat" wx:if="{{isGuanshi}}">
            <text class="mini-val">{{zhuanhualv || 0}}%</text>
            <text class="mini-lbl">有效率</text>
          </view>
          <view class="mini-stat" wx:if="{{isZuzhang}}">
            <text class="mini-val">{{guanshiCount || 0}}</text>
            <text class="mini-lbl">邀请管事</text>
          </view>
          <view class="mini-stat" wx:if="{{isZuzhang}}">
            <text class="mini-val">{{fenhongZonge || '0.00'}}</text>
            <text class="mini-lbl">分红总额</text>
          </view>
          <view class="mini-stat" wx:if="{{isKaoheguan}}">
            <text class="mini-val">{{shenheZongshu || 0}}</text>
            <text class="mini-lbl">审核总数</text>
          </view>
          <view class="mini-stat" wx:if="{{isKaoheguan}}">
            <text class="mini-val">{{tongguoZongshu || 0}}</text>
            <text class="mini-lbl">通过总数</text>
          </view>
          <view class="mini-stat" wx:if="{{isKaoheguan}}">
            <text class="mini-val">{{pendingShenheCount || 0}}</text>
            <text class="mini-lbl">待审核</text>
          </view>
        </view>
      </view>
    </view>
  </view>

  <!-- 荣耀排行榜（无外层大框，梯形榜格） -->
  <view class="rank-section">
    <view class="rank-hub-head">
      <image class="rank-hub-head-icon" src="{{imgUrls.iconSectionRank}}" mode="aspectFit" />
      <view class="rank-hub-head-text">
        <text class="rank-hub-title">荣耀排行榜</text>
        <text class="rank-hub-sub">四榜实时更新</text>
      </view>
    </view>
    <view class="rank-grid">
      <view
        class="rank-cell {{item.shapeClass}} {{item.themeClass}}"
        wx:for="{{rankBoardList}}"
        wx:key="type"
        bindtap="goToRanking"
        data-type="{{item.type}}"
      >
        <view class="rank-cell-inner">
          <image class="rank-bg-icon" src="{{item.icon}}" mode="aspectFit" />
          <view class="rank-content">
            <image class="rank-main-icon" src="{{item.icon}}" mode="aspectFit" />
            <text class="rank-cell-name">{{item.name}}</text>
            <text class="rank-cell-sub">{{item.sub}}</text>
          </view>
        </view>
      </view>
    </view>
  </view>

  <!-- 打手功能 -->
  <view class="section-card">
    <view class="section-head-line">
      <image class="section-head-icon" src="{{imgUrls.iconSectionFunc}}" mode="aspectFit" />
      <text class="section-title section-title-sm">打手功能</text>
    </view>
    <view class="func-panel">
      <image class="func-panel-bg" src="{{imgUrls.funcPanelBg}}" mode="aspectFill" />
      <view class="func-grid {{layoutSparse ? 'func-grid-sparse' : ''}}">
        <view class="func-cell" bindtap="goToReceiveOrder">
          <image class="func-icon" src="{{imgUrls.iconGame}}" mode="aspectFit" />
          <text class="func-label">抢单大厅</text>
        </view>
        <view class="func-cell" bindtap="goToMyOrders">
          <image class="func-icon" src="{{imgUrls.iconOrders}}" mode="aspectFit" />
          <text class="func-label">我的订单</text>
        </view>
        <view class="func-cell" bindtap="goToMyPunishment">
          <image class="func-icon" src="{{imgUrls.iconPunish}}" mode="aspectFit" />
          <text class="func-label">我的处罚</text>
        </view>
        <view class="func-cell" bindtap="goToKaohe">
          <image class="func-icon" src="{{imgUrls.iconMedal}}" mode="aspectFit" />
          <text class="func-label">考核金牌</text>
        </view>
        <view class="func-cell" bindtap="goToGuanzhuKs">
          <image class="func-icon" src="{{imgUrls.iconKuaishou}}" mode="aspectFit" />
          <text class="func-label">关注快手</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 管事功能 -->
  <view class="section-card" wx:if="{{isGuanshi}}">
    <view class="section-head-line">
      <image class="section-head-icon" src="{{imgUrls.iconSectionGuanshi}}" mode="aspectFit" />
      <text class="section-title section-title-sm">管事功能</text>
    </view>
    <view class="func-panel">
      <image class="func-panel-bg" src="{{imgUrls.funcPanelBg}}" mode="aspectFill" />
      <view class="func-grid">
        <view class="func-cell" bindtap="goToInviteUser">
          <image class="func-icon" src="{{imgUrls.iconInvite}}" mode="aspectFit" />
          <text class="func-label">邀请用户</text>
        </view>
        <view class="func-cell" bindtap="goToMySubordinate">
          <image class="func-icon" src="{{imgUrls.iconSub}}" mode="aspectFit" />
          <text class="func-label">我的下级</text>
        </view>
        <view class="func-cell" bindtap="goToRechargeRecord">
          <image class="func-icon" src="{{imgUrls.iconRecord}}" mode="aspectFit" />
          <text class="func-label">会员记录</text>
        </view>
        <view class="func-cell" bindtap="goToPromoPoster">
          <image class="func-icon" src="{{imgUrls.iconPoster}}" mode="aspectFit" />
          <text class="func-label">推广海报</text>
        </view>
        <view class="func-cell" bindtap="contactZuzhang">
          <image class="func-icon" src="{{imgUrls.iconContact}}" mode="aspectFit" />
          <text class="func-label">联系组长</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 组长功能 -->
  <view class="section-card" wx:if="{{isZuzhang}}">
    <view class="section-head-line">
      <image class="section-head-icon" src="{{imgUrls.iconSectionZuzhang}}" mode="aspectFit" />
      <text class="section-title section-title-sm">组长功能</text>
    </view>
    <view class="func-panel">
      <image class="func-panel-bg" src="{{imgUrls.funcPanelBg}}" mode="aspectFill" />
      <view class="func-grid">
        <view class="func-cell" bindtap="goToFenhongJilu">
          <image class="func-icon" src="{{imgUrls.iconRecord}}" mode="aspectFit" />
          <text class="func-label">分红记录</text>
        </view>
        <view class="func-cell" bindtap="goToYaoqingGuanshi">
          <image class="func-icon" src="{{imgUrls.iconInvite}}" mode="aspectFit" />
          <text class="func-label">邀请管事</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 考核官功能 -->
  <view class="section-card" wx:if="{{isKaoheguan}}">
    <view class="section-head-line">
      <image class="section-head-icon" src="{{imgUrls.iconSectionKaohe}}" mode="aspectFit" />
      <text class="section-title section-title-sm">考核官功能</text>
    </view>
    <view class="func-panel">
      <image class="func-panel-bg" src="{{imgUrls.funcPanelBg}}" mode="aspectFill" />
      <view class="func-grid">
        <view class="func-cell" bindtap="goToKaoheDafen">
          <image class="func-icon" src="{{imgUrls.iconKaoheDafen}}" mode="aspectFit" />
          <text class="func-label">考核打分</text>
        </view>
        <view class="func-cell" bindtap="goToKaoheJilu">
          <image class="func-icon" src="{{imgUrls.iconKaoheJilu}}" mode="aspectFit" />
          <text class="func-label">考核记录</text>
        </view>
        <view class="func-cell" bindtap="goToKaoheZhongxin">
          <image class="func-icon" src="{{imgUrls.iconKaoheZhongxin}}" mode="aspectFit" />
          <text class="func-label">考核中心</text>
        </view>
        <view class="func-cell" bindtap="goToKaoheWithdraw">
          <image class="func-icon" src="{{imgUrls.iconWithdraw}}" mode="aspectFit" />
          <text class="func-label">考核提现</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 身份认证：仅未认证身份 + 商家（已认证可进商家端） -->
  <view class="section-card" wx:if="{{showAuthSection}}">
    <view class="section-head-line">
      <image class="section-head-icon" src="{{imgUrls.iconSectionMore}}" mode="aspectFit" />
      <text class="section-title section-title-sm">身份认证</text>
    </view>
    <view class="func-panel">
      <image class="func-panel-bg" src="{{imgUrls.authPanelBg}}" mode="aspectFill" />
      <view class="auth-grid auth-grid-dynamic">
        <view
          class="auth-cell"
          wx:for="{{pendingAuthList}}"
          wx:key="type"
          bindtap="onTapAuthItem"
          data-type="{{item.type}}"
        >
          <image class="auth-cell-icon" src="{{item.icon}}" mode="aspectFit" />
          <text class="auth-cell-name">{{item.name}}</text>
          <text class="auth-cell-tag {{item.done ? 'auth-cell-tag-done' : ''}}">{{item.tag}}</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 更多 -->
  <view class="section-card section-last">
    <view class="section-head-line">
      <image class="section-head-icon" src="{{imgUrls.iconSectionMore}}" mode="aspectFit" />
      <text class="section-title section-title-sm">更多</text>
    </view>
    <view class="list-card">
      <image class="list-card-bg" src="{{imgUrls.listBg}}" mode="aspectFill" />
      <view class="list-card-inner">
        <view class="list-item" bindtap="contactInviter">
          <image class="list-icon" src="{{imgUrls.iconInvite}}" mode="aspectFit" />
          <text class="list-text">联系邀请人</text>
          <image class="list-arrow" src="{{imgUrls.iconArrow}}" mode="aspectFit" />
        </view>
        <view class="list-item" bindtap="goToModifyInfo">
          <image class="list-icon" src="{{imgUrls.iconEdit}}" mode="aspectFit" />
          <text class="list-text">修改个人信息</text>
          <image class="list-arrow" src="{{imgUrls.iconArrow}}" mode="aspectFit" />
        </view>
        <view class="list-item" bindtap="goToRules">
          <image class="list-icon" src="{{imgUrls.iconBook}}" mode="aspectFit" />
          <text class="list-text">用户规则</text>
          <image class="list-arrow" src="{{imgUrls.iconArrow}}" mode="aspectFit" />
        </view>
        <view class="list-item" bindtap="clearCache">
          <image class="list-icon" src="{{imgUrls.iconClear}}" mode="aspectFit" />
          <text class="list-text">清除缓存</text>
          <text class="list-sub">回点单端</text>
          <image class="list-arrow" src="{{imgUrls.iconArrow}}" mode="aspectFit" />
        </view>
      </view>
    </view>
  </view>
</view>
</block>

<view class="loading-mask" wx:if="{{isLoading}}">
  <view class="loading-spinner"></view>
</view>

<global-notification id="global-notification" />
<custom-tab-bar />
<popup-notice id="popupNotice" />
