<!--
  开发调试面板 — 页面跳转、角色切换、状态切换、绑定切换、上下文展示
-->
<view class="container">

  <!-- 当前上下文信息 -->
  <view class="section">
    <view class="section-title">当前上下文</view>
    <view class="info-card" wx:if="{{ctx}}">
      <view class="info-row"><text class="label">user_id</text><text class="value">{{ctx.user_id}}</text></view>
      <view class="info-row"><text class="label">openid</text><text class="value ellipsis">{{ctx.openid || '-'}}</text></view>
      <view class="info-row"><text class="label">状态</text><text class="value tag tag-{{ctx.status}}">{{ctx.status}}</text></view>
      <view class="info-row"><text class="label">昵称</text><text class="value">{{ctx.nickname || '-'}}</text></view>
      <view class="info-row"><text class="label">门店</text><text class="value">{{ctx.site_name || '-'}} ({{ctx.site_id || '-'}})</text></view>
      <view class="info-row"><text class="label">角色</text><text class="value">{{rolesText}}</text></view>
      <view class="info-row"><text class="label">权限</text><text class="value ellipsis">{{permissionsText}}</text></view>
      <view class="info-row"><text class="label">绑定</text><text class="value">{{bindingText}}</text></view>
    </view>
    <view class="info-card" wx:else>
      <text class="hint">{{loading ? '加载中...' : '未登录或无法获取上下文'}}</text>
    </view>
  </view>

  <!-- 角色切换 -->
  <view class="section">
    <view class="section-title">角色切换</view>
    <view class="btn-group">
      <view
        wx:for="{{roles}}"
        wx:key="code"
        class="btn {{currentRole === item.code ? 'btn-active' : ''}}"
        bindtap="switchRole"
        data-code="{{item.code}}"
      >{{item.name}}</view>
    </view>
  </view>

  <!-- 用户状态切换 -->
  <view class="section">
    <view class="section-title">用户状态切换</view>
    <view class="btn-group">
      <view
        wx:for="{{statuses}}"
        wx:key="*this"
        class="btn {{ctx.status === item ? 'btn-active' : ''}}"
        bindtap="switchStatus"
        data-status="{{item}}"
      >{{item}}</view>
    </view>
  </view>

  <!-- 页面跳转 -->
  <view class="section">
    <view class="section-title">🔧 正在迁移</view>
    <view class="page-list">
      <view
        wx:for="{{migratingPages}}"
        wx:key="path"
        class="page-item page-item--migrating"
        bindtap="goPage"
        data-url="{{item.path}}"
      >
        <text class="page-name">{{item.name}}</text>
        <text class="page-path">/{{item.path}}</text>
      </view>
      <view class="page-item page-item--empty" wx:if="{{migratingPages.length === 0}}">
        <text class="hint">暂无</text>
      </view>
    </view>
  </view>

  <view class="section">
    <view class="section-title">✅ 已完成</view>
    <view class="page-list">
      <view
        wx:for="{{donePages}}"
        wx:key="path"
        class="page-item page-item--done"
        bindtap="goPage"
        data-url="{{item.path}}"
      >
        <text class="page-name">{{item.name}}</text>
        <text class="page-path">/{{item.path}}</text>
      </view>
    </view>
  </view>

  <view class="section">
    <view class="section-title">⏳ 未完成</view>
    <view class="page-list">
      <view
        wx:for="{{todoPages}}"
        wx:key="path"
        class="page-item page-item--todo"
        bindtap="goPage"
        data-url="{{item.path}}"
      >
        <text class="page-name">{{item.name}}</text>
        <text class="page-path">/{{item.path}}</text>
      </view>
    </view>
  </view>

  <!-- 操作提示 -->
  <view class="section" wx:if="{{message}}">
    <view class="message {{messageType}}">{{message}}</view>
  </view>

</view>
