hookehuyr

fix(登录页): 修正验证码校验规则为4位数字

修复登录页验证码校验逻辑,将验证码长度从4-6位改为严格4位数字
<!--
* @Date: 2025-11-10 18:08:59
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-11-11 14:01:40
* @LastEditTime: 2025-11-11 15:51:10
* @FilePath: /stdj_h5/src/views/Login.vue
* @Description: 登录页
-->
......@@ -45,7 +45,7 @@
</template>
<script setup>
import { ref, onUnmounted, computed } from 'vue'
import { ref, onUnmounted, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useTitle } from '@vueuse/core'
import { smsAPI } from '@/api/common.js'
......@@ -82,7 +82,7 @@ const login_disabled = computed(function () {
return (
logging.value ||
!is_valid_phone(phone.value) ||
!/^\d{4,6}$/.test(String(code.value || '').trim())
!/^\d{4}$/.test(String(code.value || '').trim())
)
})
......@@ -172,8 +172,8 @@ const on_login = async function () {
showFailToast('请输入有效的手机号')
return
}
if (!/^\d{4,6}$/.test(String(code.value || '').trim())) {
showFailToast('请输入4~6位数字验证码')
if (!/^\d{4}$/.test(String(code.value || '').trim())) {
showFailToast('请输入4位数字验证码')
return
}
try {
......@@ -193,6 +193,9 @@ const on_login = async function () {
}
}
onMounted(() => {
})
// 组件卸载时清理计时器
onUnmounted(function () {
if (timer_id.value) {
......@@ -220,6 +223,7 @@ onUnmounted(function () {
.logo-title {
margin-bottom: 2rem;
}
.logo-img {
height: 5.5rem;
object-fit: contain;
......@@ -234,6 +238,7 @@ onUnmounted(function () {
padding: 1rem;
box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.06);
}
.card-title {
text-align: center;
color: #432C0E;
......@@ -248,6 +253,7 @@ onUnmounted(function () {
margin-top: 1.25rem;
margin-bottom: 0.75rem;
}
.code-row {
display: flex;
gap: 0.5rem;
......@@ -258,6 +264,7 @@ onUnmounted(function () {
.input-with-icon {
position: relative;
}
.input-with-icon::before {
content: '';
position: absolute;
......@@ -270,9 +277,11 @@ onUnmounted(function () {
background-repeat: no-repeat;
transform: translateY(-50%);
}
.input-with-icon.phone::before {
background-image: url('https://cdn.ipadbiz.cn/stdj/images/%E6%89%8B%E6%9C%BA@2x.png');
}
.input-with-icon.code::before {
background-image: url('https://cdn.ipadbiz.cn/stdj/images/%E9%AA%8C%E8%AF%81%E7%A0%81@2x-1.png');
}
......@@ -286,6 +295,7 @@ onUnmounted(function () {
padding: 0 0.75rem 0 2.25rem; // 为左侧图标预留空间
box-shadow: inset 0 0 0 0.0625rem rgba(0, 0, 0, 0.08);
}
.input::placeholder {
color: #999999;
}
......@@ -302,12 +312,15 @@ onUnmounted(function () {
text-align: center;
line-height: 2.5rem;
}
.btn.send {
white-space: nowrap;
}
.btn.primary {
width: 100%;
}
.btn.disabled {
// 不可操作态:明显的灰显与禁止样式
opacity: 0.5;
......