优化登录提示语

This commit is contained in:
zhouyanli
2026-05-12 17:40:59 +08:00
parent ac8b4c3801
commit 1a8b53b244
2 changed files with 46 additions and 20 deletions

View File

@@ -43,7 +43,7 @@
</view> </view>
<!-- 登录按钮 --> <!-- 登录按钮 -->
<button class="login-btn" :disabled="!canLogin" @click="handleLogin"> <button class="login-btn" @click="handleLogin">
登录 登录
</button> </button>
@@ -159,7 +159,26 @@
// 登录处理 // 登录处理
const handleLogin = () => { const handleLogin = () => {
if (!canLogin.value) return; if (!phoneNumber.value) {
uni.showToast({ title: '请输入手机号', icon: 'none' });
return;
}
if (!/^1[3-9]\d{9}$/.test(phoneNumber.value)) {
uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
return;
}
if (!verifyCode.value) {
uni.showToast({ title: '请输入验证码', icon: 'none' });
return;
}
if (!/^\d{6}$/.test(verifyCode.value)) {
uni.showToast({ title: '验证码为 6 位数字', icon: 'none' });
return;
}
if (!agreeAgreement.value) {
uni.showToast({ title: '请勾选协议', icon: 'none' });
return;
}
uni.showLoading({ uni.showLoading({
title: '登录中...', title: '登录中...',
mask: true mask: true

View File

@@ -44,7 +44,7 @@
</view> </view>
<!-- 登录按钮 --> <!-- 登录按钮 -->
<button class="login-btn" :disabled="!canLogin" @click="handleLogin"> <button class="login-btn" @click="handleLogin">
登录 登录
</button> </button>
@@ -104,23 +104,30 @@
// 登录逻辑 // 登录逻辑
const handleLogin = () => { const handleLogin = () => {
if (!canLogin.value) { if (!phoneNumber.value) {
uni.showToast({ title: '请输入账号和密码', icon: 'none' }); uni.showToast({ title: '请输入账号', icon: 'none' });
return return;
} }
if (phoneNumber.value.length < 4 || phoneNumber.value.length > 16) {
if (!phoneNumber.value) { uni.showToast({ title: '账号长度需为 4-16 位', icon: 'none' });
uni.showToast({ title: '请输入账号', icon: 'none' }); return;
return; }
} if (!password.value) {
if (!password.value) { uni.showToast({ title: '请输入密码', icon: 'none' });
uni.showToast({ title: '请输入密码', icon: 'none' }); return;
return; }
} if (password.value.length < 6) {
if(!agreeAgreement.value){ uni.showToast({ title: '密码至少输入 6 位', icon: 'none' });
uni.showToast({ title: '请勾选协议', icon: 'none' }); return;
return; }
} if (password.value.length > 16) {
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' });
return;
}
if(!agreeAgreement.value){
uni.showToast({ title: '请勾选协议', icon: 'none' });
return;
}
uni.showLoading({ title: '登录中...', mask: true }); uni.showLoading({ title: '登录中...', mask: true });
let params = { let params = {
username:phoneNumber.value, username:phoneNumber.value,