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

<!-- 未注册状态 -->
<view class="unreg-area" wx:if="{{!isGuanshi}}">
  <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>
</view>

<!-- 已注册状态 -->
<view class="main-body" wx:else>
  <!-- 刷新按钮 -->
  <view class="refresh-btn" bindtap="refreshGuanshiInfo">
    <image class="refresh-icon" src="{{imgUrls.iconRefresh}}" mode="aspectFit" />
  </view>

  <!-- 用户信息卡片 -->
  <view class="user-card">
    <image class="user-avatar" src="{{avatarUrl}}" mode="aspectFill" bindtap="previewAvatar" />
    <view class="user-info">
      <text class="user-name">{{nicheng || '管事'}}</text>
      <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 class="badge-zone" wx:if="{{chenghaoList.length > 0}}">
    <scroll-view scroll-x class="badge-scroll">
      <chenghao-tag wx:for="{{chenghaoList}}" wx:key="index" mingcheng="{{item.mingcheng}}" texiaoJson="{{item.texiao_json}}" />
    </scroll-view>
  </view>

  <!-- 资产卡片 -->
  <view class="asset-card">
    <text class="asset-title">可提现分成</text>
    <view class="asset-amount">
      <text class="amount-number">{{fenyongtixian}}</text>
      <text class="amount-unit">元</text>
    </view>
    <!-- 四列数据：邀请总数、已充值、分成总额、有效率 -->
    <view class="four-stats">
      <view class="stat-item">
        <text class="stat-val">{{yaoqingzongshu}}</text>
        <text class="stat-label">邀请总数</text>
      </view>
      <view class="stat-item">
        <text class="stat-val">{{yichongzhiDashou}}</text>
        <text class="stat-label">已充值</text>
      </view>
      <view class="stat-item">
        <text class="stat-val">{{fenyongzonge}}</text>
        <text class="stat-label">分成总额</text>
      </view>
      <view class="stat-item">
        <text class="stat-val">{{zhuanhualv}}%</text>
        <text class="stat-label">有效率</text>
      </view>
    </view>
    <!-- 提现按钮 -->
    <view class="withdraw-btn" bindtap="goToWithdraw">
      <image class="withdraw-icon" src="{{imgUrls.iconWithdraw}}" mode="aspectFit" />
      <text class="withdraw-text">提现</text>
    </view>
  </view>

  <!-- 功能入口区：三列布局，6项已补全 -->
  <view class="func-grid">
    <view class="func-item" bindtap="goToInviteUser">
      <image class="func-icon" src="{{imgUrls.iconInvite}}" mode="aspectFit" />
      <text class="func-label">邀请用户</text>
    </view>
    <view class="func-item" bindtap="goToMySubordinate">
      <image class="func-icon" src="{{imgUrls.iconSub}}" mode="aspectFit" />
      <text class="func-label">我的下级</text>
    </view>
    <view class="func-item" bindtap="goToRechargeRecord">
      <image class="func-icon" src="{{imgUrls.iconRecord}}" mode="aspectFit" />
      <text class="func-label">会员记录</text>
    </view>
    <view class="func-item" bindtap="goToGuanshiRanking">
      <image class="func-icon" src="{{imgUrls.iconRank}}" mode="aspectFit" />
      <text class="func-label">管事排行</text>
    </view>
    <view class="func-item" bindtap="goToPromoPoster">
      <image class="func-icon" src="{{imgUrls.iconPoster}}" mode="aspectFit" />
      <text class="func-label">推广海报</text>
    </view>
    <view class="func-item" bindtap="contactInviter">
      <image class="func-icon" src="{{imgUrls.iconContact}}" mode="aspectFit" />
      <text class="func-label">联系组长</text>
    </view>
  </view>

  <!-- 原有的联系组长卡片 -->
  <view class="contact-card" bindtap="contactInviter">
    <view class="contact-left">
      <image class="contact-avatar" src="{{inviterCache.avatar || imgUrls.avatarDefault}}" mode="aspectFill" />
      <view class="contact-info">
        <text class="contact-name">{{inviterCache.nicheng || '联系组长'}}</text>
        <text class="contact-uid" wx:if="{{inviterCache && inviterCache.uid}}">ID: {{inviterCache.uid}}</text>
      </view>
    </view>
    <image class="contact-arrow" src="{{imgUrls.iconArrow}}" mode="aspectFit" />
  </view>
</view>

<!-- 加载遮罩 -->
<view class="loading-mask" wx:if="{{isLoading}}">
  <view class="loading-spinner"></view>
</view>

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