<!-- 打手端个人中心 - 逍遥梦布局，逻辑/事件不变 -->

<!-- 未注册 -->
<block wx:if="{{!isDashou && !isGuanshi && !isZuzhang && !isKaoheguan}}">
  <view class="user-page unreg-page">
    <view class="page-header">
      <view class="status-bar" style="height:{{statusBar}}px"></view>
      <view class="nav-bar" style="height:{{navBar - statusBar}}px"><text class="nav-title">我的</text></view>
    </view>
    <view class="unreg-area">
      <view class="panel shadow 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="btn-bg unreg-btn" bindtap="onRegister"><text class="unreg-btn-text">立即注册</text></view>
        <view class="unreg-btn-secondary" bindtap="quickRegisterAsPlatform"><text>平台直签注册</text></view>
        <view class="unreg-link" bindtap="switchToNormal"><text>返回点单端</text></view>
        <view class="unreg-link" bindtap="clearCache"><text>清除缓存，重新登录</text></view>
      </view>
    </view>
    <tab-bar/>
  </view>
</block>

<!-- 已注册 -->
<block wx:else>
  <view class="user-page">
    <view class="page-header">
      <view class="status-bar" style="height:{{statusBar}}px"></view>
      <view class="nav-bar" style="height:{{navBar - statusBar}}px">
        <text class="nav-title">我的</text>
      </view>
    </view>

    <scroll-view
      class="content"
      scroll-y
      enhanced
      show-scrollbar="{{false}}"
      refresher-enabled="{{true}}"
      refresher-threshold="80"
      refresher-default-style="black"
      refresher-background="#fff8e1"
      refresher-triggered="{{scrollViewRefreshing}}"
      bindrefresherrefresh="onPullDownRefresh"
    >
      <!-- 用户信息 -->
      <view class="user-info flexb">
        <view class="flex">
          <image class="avatar" src="{{avatarUrl || imgUrls.avatarDefault}}" mode="aspectFill" bindtap="previewAvatar"/>
          <view class="user-text-col">
            <view class="nickname-row">
              <text class="nickname">{{dashouNicheng || '接单员'}}</text>
              <view class="deposit-tag" wx:if="{{yajin && yajin != '0' && yajin != '0.00'}}">保证金</view>
              <view class="role-tags">
                <text class="role-tag">接单员</text>
                <text class="role-tag" wx:if="{{isGuanshi}}">管事</text>
                <text class="role-tag" wx:if="{{isZuzhang}}">组长</text>
                <text class="role-tag" wx:if="{{isKaoheguan}}">考核</text>
              </view>
            </view>
            <view class="sn-row" bindtap="copyUid">
              <text class="sn">ID: {{uid || '--'}}</text>
              <image class="copy-ico" src="{{imgUrls.iconCopy}}" mode="aspectFit"/>
            </view>
          </view>
        </view>
        <view class="user-header-actions">
          <image class="header-action-ico" src="{{imgUrls.iconRefresh}}" mode="aspectFit" bindtap="onTapRefresh"/>
          <image class="setting-ico" src="{{imgUrls.iconEdit}}" mode="aspectFit" bindtap="goToModifyInfo"/>
        </view>
      </view>

      <!-- 称号 -->
      <view class="badge-zone" wx:if="{{chenghaoList.length > 0 || (isGuanshi && guanshiChenghaoList.length > 0) || identityTagList.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" 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>
        <scroll-view scroll-x class="badge-scroll identity-tag-scroll" wx:if="{{identityTagList.length > 0}}">
          <view class="badge-tag-wrap" wx:for="{{identityTagList}}" wx:key="id">
            <chenghao-tag mingcheng="{{item.mingcheng}}" texiaoJson="{{item.texiao_json}}"/>
          </view>
        </scroll-view>
      </view>

      <!-- 佣金/资产卡（逍遥梦 wallet-card） -->
      <view class="wallet-card flexb">
        <view class="wallet-left">
          <view class="w-label">我的佣金(元)</view>
          <view class="w-num">¥{{totalAssets}}</view>
          <view class="w-sub">可提现 ¥{{yongjin || '0.00'}} · 查看</view>
        </view>
        <view class="wallet-btns flex">
          <view class="btn-outline" catchtap="goToRecharge">充值</view>
          <view class="btn-outline" catchtap="goToTotalWithdraw">去提现</view>
        </view>
      </view>

      <!-- 会员充值 + 保证金（无后台图时显示文字按钮） -->
      <view class="banner-row flex" wx:if="{{showRechargeBanners}}">
        <image wx:if="{{imgUrls.bannerVip}}" class="banner-img" src="{{imgUrls.bannerVip}}" mode="widthFix" bindtap="goToRecharge"/>
        <image wx:if="{{imgUrls.bannerDeposit}}" class="banner-img" src="{{imgUrls.bannerDeposit}}" mode="widthFix" bindtap="goToRecharge"/>
      </view>
      <view class="recharge-text-row flex" wx:else>
        <view class="recharge-text-btn" catchtap="goToRecharge">充值会员</view>
        <view class="recharge-text-btn" catchtap="goToRecharge">充值保证金</view>
      </view>

      <!-- 资产统计（逍遥梦 freeze-row） -->
      <view class="freeze-row flexa">
        <view class="freeze-col flexmc">
          <text class="freeze-num">{{jinfen || '0'}}</text>
          <text class="freeze-lbl">积分</text>
        </view>
        <view class="freeze-col flexmc">
          <text class="freeze-num">{{yajin || '0.00'}}</text>
          <text class="freeze-lbl">保证金</text>
        </view>
        <view class="freeze-col flexmc">
          <text class="freeze-num">{{yongjin || '0.00'}}</text>
          <text class="freeze-lbl">佣金</text>
        </view>
      </view>

      <!-- 角色扩展统计（从左往右排列，不均分撑满） -->
      <view class="stats-bar" wx:if="{{isGuanshi || isZuzhang || isKaoheguan}}">
        <view class="stat-cell" wx:if="{{isGuanshi}}"><text class="stat-val">{{yaoqingzongshu || 0}}</text><text class="stat-lbl">邀请总数</text></view>
        <view class="stat-cell" wx:if="{{isGuanshi}}"><text class="stat-val">{{yichongzhiDashou || 0}}</text><text class="stat-lbl">已充值</text></view>
        <view class="stat-cell" wx:if="{{isGuanshi}}"><text class="stat-val">{{fenyongzonge || '0.00'}}</text><text class="stat-lbl">分成总额</text></view>
        <view class="stat-cell" wx:if="{{isGuanshi}}"><text class="stat-val">{{zhuanhualv || 0}}%</text><text class="stat-lbl">有效率</text></view>
        <view class="stat-cell" wx:if="{{isZuzhang}}"><text class="stat-val">{{guanshiCount || 0}}</text><text class="stat-lbl">邀请管事</text></view>
        <view class="stat-cell" wx:if="{{isZuzhang}}"><text class="stat-val">{{fenhongZonge || '0.00'}}</text><text class="stat-lbl">分红总额</text></view>
        <view class="stat-cell" wx:if="{{isKaoheguan}}"><text class="stat-val">{{shenheZongshu || 0}}</text><text class="stat-lbl">审核总数</text></view>
        <view class="stat-cell" wx:if="{{isKaoheguan}}"><text class="stat-val">{{tongguoZongshu || 0}}</text><text class="stat-lbl">通过总数</text></view>
        <view class="stat-cell" wx:if="{{isKaoheguan}}"><text class="stat-val">{{pendingShenheCount || 0}}</text><text class="stat-lbl">待审核</text></view>
      </view>

      <!-- 接单服务（对应逍遥梦「我的订单」四宫格） -->
      <view class="panel shadow">
        <view class="panel-title flexb"><text class="lg">接单服务</text></view>
        <view class="order-nav">
          <view class="nav-item flexmc" bindtap="goToReceiveOrder">
            <image class="nav-icon" src="{{imgUrls.iconGame}}" mode="aspectFit"/><text class="sm">抢单大厅</text>
          </view>
          <view class="nav-item flexmc" bindtap="goToMyOrders">
            <image class="nav-icon" src="{{imgUrls.iconOrders}}" mode="aspectFit"/><text class="sm">我的订单</text>
          </view>
          <view class="nav-item flexmc" bindtap="goToMyPunishment">
            <image class="nav-icon" src="{{imgUrls.iconPunish}}" mode="aspectFit"/><text class="sm">我的处罚</text>
          </view>
          <view class="nav-item flexmc" bindtap="goToKaohe">
            <image class="nav-icon" src="{{imgUrls.iconMedal}}" mode="aspectFit"/><text class="sm">考核金牌</text>
          </view>
          <view class="nav-item flexmc" bindtap="goToDashouExam">
            <image class="nav-icon" src="{{imgUrls.iconBook}}" mode="aspectFit"/>
            <text class="sm">接单考试</text>
            <text wx:if="{{examEnabled}}" class="exam-tag {{examPassed ? 'exam-tag-pass' : 'exam-tag-pending'}}">{{examPassed ? '已通过' : '待考试'}}</text>
          </view>
        </view>
      </view>

      <!-- 荣耀排行榜（横向滑动，省空间） -->
      <view class="rank-hub panel shadow">
        <view class="panel-title flexb">
          <text class="lg">荣耀排行榜</text>
          <text class="rank-hub-tip">TOP50</text>
        </view>
        <scroll-view scroll-x class="rank-hub-scroll" enhanced show-scrollbar="{{false}}">
          <view class="rank-hub-track">
            <view
              wx:for="{{rankBoardList}}"
              wx:key="type"
              class="rank-tile {{item.themeClass}}"
              bindtap="goToRanking"
              data-type="{{item.type}}"
            >
              <view class="rank-tile-inner">
                <image class="rank-tile-icon" src="{{item.icon}}" mode="aspectFit"/>
                <view class="rank-tile-text">
                  <text class="rank-tile-name">{{item.name}}</text>
                  <text class="rank-tile-sub">{{item.sub}}</text>
                </view>
                <text class="rank-tile-go">进入</text>
              </view>
            </view>
          </view>
        </scroll-view>
      </view>

      <!-- 管事功能 -->
      <view class="panel shadow" wx:if="{{isGuanshi}}">
        <view class="panel-title"><text class="lg">管事功能</text></view>
        <view class="func-grid">
          <view class="func-item flexmc" bindtap="goToInviteUser"><image class="func-icon" src="{{imgUrls.iconInvite}}" mode="aspectFit"/><text class="func-txt">邀请用户</text></view>
          <view class="func-item flexmc" bindtap="goToMySubordinate"><image class="func-icon" src="{{imgUrls.iconSub}}" mode="aspectFit"/><text class="func-txt">我的下级</text></view>
          <view class="func-item flexmc" bindtap="goToRechargeRecord"><image class="func-icon" src="{{imgUrls.iconRecord}}" mode="aspectFit"/><text class="func-txt">会员记录</text></view>
          <view class="func-item flexmc" bindtap="goToPromoPoster"><image class="func-icon" src="{{imgUrls.iconPoster}}" mode="aspectFit"/><text class="func-txt">推广海报</text></view>
          <view class="func-item flexmc" bindtap="contactZuzhang"><image class="func-icon" src="{{imgUrls.iconContact}}" mode="aspectFit"/><text class="func-txt">联系组长</text></view>
        </view>
      </view>

      <!-- 组长功能 -->
      <view class="panel shadow" wx:if="{{isZuzhang}}">
        <view class="panel-title"><text class="lg">组长功能</text></view>
        <view class="func-grid">
          <view class="func-item flexmc" bindtap="goToFenhongJilu"><image class="func-icon" src="{{imgUrls.iconRecord}}" mode="aspectFit"/><text class="func-txt">分红记录</text></view>
          <view class="func-item flexmc" bindtap="goToYaoqingGuanshi"><image class="func-icon" src="{{imgUrls.iconInvite}}" mode="aspectFit"/><text class="func-txt">邀请管事</text></view>
        </view>
      </view>

      <!-- 考核官功能 -->
      <view class="panel shadow" wx:if="{{isKaoheguan}}">
        <view class="panel-title"><text class="lg">考核官功能</text></view>
        <view class="func-grid">
          <view class="func-item flexmc" bindtap="goToKaoheDafen"><image class="func-icon" src="{{imgUrls.iconKaoheDafen}}" mode="aspectFit"/><text class="func-txt">考核打分</text></view>
          <view class="func-item flexmc" bindtap="goToKaoheJilu"><image class="func-icon" src="{{imgUrls.iconKaoheJilu}}" mode="aspectFit"/><text class="func-txt">考核记录</text></view>
          <view class="func-item flexmc" bindtap="goToKaoheZhongxin"><image class="func-icon" src="{{imgUrls.iconKaoheZhongxin}}" mode="aspectFit"/><text class="func-txt">考核中心</text></view>
        </view>
      </view>

      <!-- 身份认证 -->
      <view class="panel shadow" wx:if="{{showAuthSection}}">
        <view class="panel-title"><text class="lg">身份认证</text></view>
        <view class="func-grid">
          <view class="func-item flexmc" wx:for="{{pendingAuthList}}" wx:key="type" bindtap="onTapAuthItem" data-type="{{item.type}}">
            <image class="func-icon" src="{{item.icon}}" mode="aspectFit"/>
            <text class="func-txt">{{item.name}}</text>
            <text class="func-tag {{item.done ? 'func-tag-done' : ''}}">{{item.tag}}</text>
          </view>
        </view>
      </view>

      <!-- 更多功能 -->
      <view class="panel shadow">
        <view class="panel-title"><text class="lg">更多功能</text></view>
        <view class="func-grid">
          <view class="func-item flexmc" bindtap="goToKefu"><image class="func-icon" src="{{imgUrls.iconKefu}}" mode="aspectFit"/><text class="func-txt">在线客服</text></view>
          <view class="func-item flexmc" bindtap="goToGuanzhuKs"><image class="func-icon" src="{{imgUrls.iconKuaishou}}" mode="aspectFit"/><text class="func-txt">关注快手</text></view>
          <view class="func-item flexmc" wx:if="{{showPindaoEntry}}" bindtap="openPindaoModal"><image class="func-icon" src="{{imgUrls.iconPindao}}" mode="aspectFit"/><text class="func-txt">频道</text></view>
          <view class="func-item flexmc" bindtap="contactInviter"><image class="func-icon" src="{{imgUrls.iconInvite}}" mode="aspectFit"/><text class="func-txt">联系邀请人</text></view>
          <view class="func-item flexmc" bindtap="goToRules"><image class="func-icon" src="{{imgUrls.iconBook}}" mode="aspectFit"/><text class="func-txt">用户规则</text></view>
          <view class="func-item flexmc" bindtap="switchToNormal"><image class="func-icon" src="{{imgUrls.iconSwitch}}" mode="aspectFit"/><text class="func-txt">返回点单端</text></view>
          <view class="func-item flexmc" bindtap="clearCache"><image class="func-icon" src="{{imgUrls.iconClear}}" mode="aspectFit"/><text class="func-txt">清除缓存</text></view>
        </view>
      </view>

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

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

<global-notification id="global-notification"/>
<popup-notice id="popupNotice"/>
<pindao-modal
  visible="{{pindaoVisible}}"
  title="{{pindaoTitle}}"
  channelNo="{{pindaoChannelNo}}"
  images="{{pindaoImages}}"
  bind:close="closePindaoModal"
/>
