登陆页操作流程调整

This commit is contained in:
xuxin
2026-06-05 17:56:44 +08:00
parent c17f75c707
commit 1c3ea6aa3c
2 changed files with 60 additions and 10 deletions
+16
View File
@@ -336,6 +336,22 @@
50% { opacity: 0; } 50% { opacity: 0; }
} }
/* ==================== 验证码发送状态提示 ==================== */
.login-view__sms-status {
width: 100%;
font-size: 0.13rem;
line-height: 0.16rem;
color: #64748B;
text-align: center;
padding-right: 0.1rem;
margin-top: -0.19rem;
margin-bottom: -0.10rem;
}
.login-view__sms-status--error {
color: #E85635;
}
/* ==================== 状态按钮(步骤二) ==================== */ /* ==================== 状态按钮(步骤二) ==================== */
.login-view__status-btn { .login-view__status-btn {
width: 100%; width: 100%;
+44 -10
View File
@@ -78,7 +78,7 @@
<!-- 标题 --> <!-- 标题 -->
<div class="login-view__heading"> <div class="login-view__heading">
<h2 class="login-view__title">请输入验证码</h2> <h2 class="login-view__title">请输入验证码</h2>
<p class="login-view__subtitle">短信验证码已发送至 +86{{ phone }}</p> <p class="login-view__subtitle">短信验证码已发送至 +86{{ phone }} <span class="fw600 ml5 cursor-po" @click="handleChangePhone">修改手机号</span></p>
</div> </div>
<!-- 6位验证码输入框 --> <!-- 6位验证码输入框 -->
<div class="login-view__otp-wrap" @click="focusOtpInput"> <div class="login-view__otp-wrap" @click="focusOtpInput">
@@ -109,6 +109,8 @@
<span v-else-if="idx === otpValue.length && !isLoggingIn" class="login-view__otp-cursor"></span> <span v-else-if="idx === otpValue.length && !isLoggingIn" class="login-view__otp-cursor"></span>
</div> </div>
</div> </div>
<!-- 验证码发送状态提示 -->
<p v-if="smsStatusMsg" class="login-view__sms-status" :class="{ 'login-view__sms-status--error': smsStatusIsError }">{{ smsStatusMsg }}</p>
<!-- 状态按钮 三种状态登录中 / 倒计时 / 再次发送 --> <!-- 状态按钮 三种状态登录中 / 倒计时 / 再次发送 -->
<button <button
class="login-view__status-btn" class="login-view__status-btn"
@@ -178,6 +180,10 @@ const countdown = ref(0)
let countdownTimer: ReturnType<typeof setInterval> | null = null let countdownTimer: ReturnType<typeof setInterval> | null = null
/** 是否正在调用登录接口 */ /** 是否正在调用登录接口 */
const isLoggingIn = ref(false) const isLoggingIn = ref(false)
/** 验证码发送状态提示文字 */
const smsStatusMsg = ref('')
/** 状态提示是否为错误样式 */
const smsStatusIsError = ref(false)
/** OTP 输入框引用 */ /** OTP 输入框引用 */
const otpInputRef = ref<HTMLInputElement | null>(null) const otpInputRef = ref<HTMLInputElement | null>(null)
@@ -199,6 +205,21 @@ function focusOtpInput() {
otpInputRef.value?.focus() otpInputRef.value?.focus()
} }
/** 修改手机号 — 回到步骤一并清空所有状态 */
function handleChangePhone() {
step.value = 1
phone.value = ''
otpValue.value = ''
countdown.value = 0
smsStatusMsg.value = ''
smsStatusIsError.value = false
isLoggingIn.value = false
if (countdownTimer) {
clearInterval(countdownTimer)
countdownTimer = null
}
}
/** 开始60秒倒计时 */ /** 开始60秒倒计时 */
function startCountdown() { function startCountdown() {
countdown.value = 60 countdown.value = 60
@@ -224,7 +245,8 @@ async function handleSendCode() {
try { try {
const res = await sendSmsCode(phone.value) const res = await sendSmsCode(phone.value)
if (res.code === '0') { if (res.code === '0') {
ElMessage.success('验证码发送') smsStatusMsg.value = '验证码发送成功,请输入'
smsStatusIsError.value = false
// 进入步骤二 // 进入步骤二
step.value = 2 step.value = 2
// 开始倒计时 // 开始倒计时
@@ -233,15 +255,20 @@ async function handleSendCode() {
nextTick(() => focusOtpInput()) nextTick(() => focusOtpInput())
} else if (res.msg && res.msg.includes('请勿重复发送')) { } else if (res.msg && res.msg.includes('请勿重复发送')) {
// 之前发送过的验证码仍有效,直接进入步骤二让用户输入 // 之前发送过的验证码仍有效,直接进入步骤二让用户输入
ElMessage.warning(res.msg) smsStatusMsg.value = '验证码还在有效期内,请输入'
smsStatusIsError.value = false
step.value = 2 step.value = 2
startCountdown() startCountdown()
nextTick(() => focusOtpInput()) nextTick(() => focusOtpInput())
} else { } else {
ElMessage.error(res.msg || '验证码发送失败') smsStatusMsg.value = res.msg || '验证码发送失败'
smsStatusIsError.value = true
} }
} catch { } catch (err: any) {
// 错误已在 request 拦截器中统一处理 // HTTP 500 等异常,拦截器已弹提示,这里同步显示到状态文字
const msg = err?.response?.data?.msg || '验证码发送失败'
smsStatusMsg.value = msg
smsStatusIsError.value = true
} }
} }
@@ -261,15 +288,22 @@ async function handleResendCode() {
try { try {
const res = await sendSmsCode(phone.value) const res = await sendSmsCode(phone.value)
if (res.code === '0') { if (res.code === '0') {
ElMessage.success('验证码发送') smsStatusMsg.value = '验证码发送成功,请输入'
smsStatusIsError.value = false
otpValue.value = '' otpValue.value = ''
startCountdown() startCountdown()
nextTick(() => focusOtpInput()) nextTick(() => focusOtpInput())
} else if (res.msg && res.msg.includes('请勿重复发送')) {
smsStatusMsg.value = '验证码还在有效期内,请输入'
smsStatusIsError.value = false
} else { } else {
ElMessage.error(res.msg || '验证码发送失败') smsStatusMsg.value = res.msg || '验证码发送失败'
smsStatusIsError.value = true
} }
} catch { } catch (err: any) {
// 错误已在 request 拦截器中统一处理 const msg = err?.response?.data?.msg || '验证码发送失败'
smsStatusMsg.value = msg
smsStatusIsError.value = true
} }
} }