<view class="page" style="background:#fff">
  <view class="login-header">
    <view class="login-logo">省胜优铺</view>
    <view class="login-welcome">欢迎回来</view>
  </view>

  <!-- 登录方式切换 -->
  <view class="login-tabs">
    <view class="lt-item {{loginMode === 'password' ? 'active' : ''}}" bindtap="switchMode" data-mode="password">密码登录</view>
    <view class="lt-item {{loginMode === 'sms' ? 'active' : ''}}" bindtap="switchMode" data-mode="sms">短信登录</view>
  </view>

  <!-- 密码登录 -->
  <view class="login-form" wx:if="{{loginMode === 'password'}}">
    <view class="input-item">
      <text class="input-label">手机号</text>
      <input class="input-field" type="text" placeholder="请输入手机号" maxlength="11" value="{{phone}}" bindinput="onPhoneInput" />
    </view>
    <view class="input-item">
      <text class="input-label">密码</text>
      <input class="input-field" type="{{showPassword ? 'text' : 'password'}}" placeholder="请输入密码" value="{{password}}" bindinput="onPasswordInput" />
      <text class="eye-btn" bindtap="togglePassword">{{showPassword ? '👁️' : '👁️‍🗨️'}}</text>
    </view>
    <button class="btn-primary btn-block submit-btn" loading="{{loading}}" bindtap="onPasswordLogin">登 录</button>
    <view class="register-link" bindtap="goRegister">还没有账号？去注册</view>
  </view>

  <!-- 短信登录 -->
  <view class="login-form" wx:if="{{loginMode === 'sms'}}">
    <view class="input-item">
      <text class="input-label">手机号</text>
      <input class="input-field" type="text" placeholder="请输入手机号" maxlength="11" value="{{phone}}" bindinput="onPhoneInput" />
    </view>
    <view class="input-item">
      <text class="input-label">验证码</text>
      <input class="input-field" type="text" placeholder="请输入验证码" maxlength="6" value="{{smsCode}}" bindinput="onSmsCodeInput" />
      <button class="sms-btn {{smsTimer > 0 ? 'disabled' : ''}}" disabled="{{smsTimer > 0}}" bindtap="onSendSms">
        {{smsTimer > 0 ? smsTimer + 's' : '获取验证码'}}
      </button>
    </view>
    <button class="btn-primary btn-block submit-btn" loading="{{loading}}" bindtap="onSmsLogin">登 录</button>
  </view>
</view>
