<!--package-live/login/login.wxml-->
<!--pages/live/registration/registration.wxml-->
<navigation-bar title="会员认证" back="{{false}}" color="black" background="#FFF" wx:if="{{(show)}}" />

<!-- 未登录：微信授权 -->
<view class="login" wx:if="{{!show}}">
  <view class="login-header">
    <text class="login-back" bind:tap="goBack">← 返回</text>
  </view>
  <view class="login-logo">
    <text class="login-title">欢迎来到直播间</text>
    <text class="login-desc">授权登录后可观看会员专属内容</text>
  </view>
  <button class="login-btn" bind:tap="handOpen">微信授权登录</button>
</view>

<!-- 已登录：显示用户信息 -->
<view class="body" wx:else>
  <view class="body-header">
    <text class="body-back" bind:tap="goBack">← 返回</text>
  </view>
  <view class="body-content">
      <view class="userinfo" >
          <button class="choose-avatar">
              <image class="avatar" src="{{avatarUrl}}" />
          </button>
          <view class="nickname">{{nickname}}</view>
          <view class="refresh" bind:tap="refresh">刷新</view>
      </view>
  </view>
  <view style="white-space:pre-wrap">{{msg}}</view>
</view>


<!-- 弹窗：设置头像和昵称 -->
<view class="login-container">
  <popup visible="{{showPopup}}" bind:close="closePopup">
    <text class="popup-title">手动设置头像和昵称</text>
    <view class="popup-content">
      <!-- 左右布局：左侧头像 | 右侧按钮组 -->
      <view class="form-row">
        <!-- 左侧：头像 -->
        <button class="avatar-picker" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
          <image src="{{avatarUrl}}" class="popup-avatar"></image>
        </button>
        <!-- 右侧：两个按钮 -->
        <view class="btn-group">
          <button class="form-btn" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">点击获取头像</button>
          <input
            type="nickname"
            class="form-input--nickname"
            placeholder="点击获取昵称"
            bindblur="onNicknameInput"
          />
        </view>
      </view>

      <!-- 提交 -->
      <view class="form-submit">
        <button class="submit-btn" bind:tap="submitLogin">确定授权</button>
      </view>
    </view>
  </popup>
</view>