调整样式和冲突
This commit is contained in:
@@ -74,7 +74,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 登录按钮 -->
|
<!-- 登录按钮 -->
|
||||||
<button class="login-btn" :disabled="!canLogin" @click="handleLogin">登录</button>
|
<button class="login-btn" @click="handleLogin">登录</button>
|
||||||
|
|
||||||
<!-- 底部链接 -->
|
<!-- 底部链接 -->
|
||||||
<view class="bottom-link">
|
<view class="bottom-link">
|
||||||
@@ -241,6 +241,85 @@ const handleLogin = () => {
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 登录处理
|
||||||
|
const handleLogin = () => {
|
||||||
|
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({
|
||||||
|
title: '登录中...',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
let params = {
|
||||||
|
phone: phoneNumber.value,
|
||||||
|
smsCode: verifyCode.value,
|
||||||
|
scene: 'butler_login'
|
||||||
|
}
|
||||||
|
getLoginBySms(params)
|
||||||
|
.then(res => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
if (res.data) {
|
||||||
|
uni.setStorageSync('token', res.data.token)
|
||||||
|
// 存用户ID
|
||||||
|
if (res.data.userId) {
|
||||||
|
uni.setStorageSync('userId', res.data.userId)
|
||||||
|
}
|
||||||
|
// 存当前绑定的小区ID,0 表示未绑定
|
||||||
|
const currentVillageId = res.data.currentVillageId || 0
|
||||||
|
uni.setStorageSync('currentVillageId', currentVillageId)
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录成功',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/index/index'
|
||||||
|
})
|
||||||
|
}, 1500)
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录失败',
|
||||||
|
icon: 'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录失败',
|
||||||
|
icon: 'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
title: err.msg,
|
||||||
|
icon: 'error'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// 模拟登录请求
|
||||||
|
// uni.showLoading({
|
||||||
|
// title: '登录中...'
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
// ========== 生命周期 ==========
|
// ========== 生命周期 ==========
|
||||||
// 页面卸载时清除定时器
|
// 页面卸载时清除定时器
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 登录按钮 -->
|
<!-- 登录按钮 -->
|
||||||
<button class="login-btn" :disabled="!canLogin" @click="handleLogin">
|
<button class="login-btn" @click="handleLogin">
|
||||||
登录
|
登录
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -104,19 +104,26 @@
|
|||||||
|
|
||||||
// 登录逻辑
|
// 登录逻辑
|
||||||
const handleLogin = () => {
|
const handleLogin = () => {
|
||||||
if (!canLogin.value) {
|
|
||||||
uni.showToast({ title: '请输入账号和密码', icon: 'none' });
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!phoneNumber.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) {
|
||||||
|
uni.showToast({ title: '账号长度需为 4-16 位', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!password.value) {
|
if (!password.value) {
|
||||||
uni.showToast({ title: '请输入密码', icon: 'none' });
|
uni.showToast({ title: '请输入密码', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (password.value.length < 6) {
|
||||||
|
uni.showToast({ title: '密码至少输入 6 位', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (password.value.length > 16) {
|
||||||
|
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!agreeAgreement.value){
|
if(!agreeAgreement.value){
|
||||||
uni.showToast({ title: '请勾选协议', icon: 'none' });
|
uni.showToast({ title: '请勾选协议', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user