Merge branch 'main' of http://gitea.bugtc.com/zhouyanli/property-resident-side
@@ -1,325 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="login-page">
|
|
||||||
<view class="status_bar"></view>
|
|
||||||
<!-- 登录标题 -->
|
|
||||||
<view class="login-title">手机验证码登录</view>
|
|
||||||
|
|
||||||
<!-- 手机号输入框 -->
|
|
||||||
<view class="input-item">
|
|
||||||
<view class="input-icon">
|
|
||||||
<!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> -->
|
|
||||||
<image src="/static/登录/手机号.png" mode="" style="height: 100%;width: 100%;"></image>
|
|
||||||
</view>
|
|
||||||
<uni-easyinput class="input-content" type="number" v-model="phoneNumber"
|
|
||||||
placeholder="请输入手机号" :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
|
|
||||||
</uni-easyinput>
|
|
||||||
<!-- <input
|
|
||||||
class="input-content"
|
|
||||||
type="number"
|
|
||||||
placeholder="请输入手机号"
|
|
||||||
v-model="phoneNumber"
|
|
||||||
maxlength="11"
|
|
||||||
@input="checkForm"
|
|
||||||
/> -->
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 验证码输入框 + 获取验证码按钮 -->
|
|
||||||
<view class="input-item verify-item">
|
|
||||||
<view class="input-icon">
|
|
||||||
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
|
|
||||||
<image src="/static/登录/验证码.png" mode="" style="height: 100%;width: 100%;"></image>
|
|
||||||
</view>
|
|
||||||
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode"
|
|
||||||
placeholder="请输入验证码" :inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
|
|
||||||
</uni-easyinput>
|
|
||||||
<!-- <input
|
|
||||||
class="input-content verify-input"
|
|
||||||
type="number"
|
|
||||||
placeholder="请输入验证码"
|
|
||||||
v-model="verifyCode"
|
|
||||||
maxlength="6"
|
|
||||||
@input="checkForm"
|
|
||||||
/> -->
|
|
||||||
<button
|
|
||||||
class="get-verify-btn"
|
|
||||||
:disabled="!canGetVerify || countDown > 0"
|
|
||||||
@click="getVerifyCode"
|
|
||||||
>
|
|
||||||
{{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
|
|
||||||
</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 协议勾选 -->
|
|
||||||
<view class="agreement-item" @click="toggleAgreement">
|
|
||||||
<uni-icons
|
|
||||||
type="checkbox-filled"
|
|
||||||
size="24"
|
|
||||||
color="#007aff"
|
|
||||||
v-if="agreeAgreement"
|
|
||||||
></uni-icons>
|
|
||||||
<uni-icons
|
|
||||||
type="checkbox"
|
|
||||||
size="24"
|
|
||||||
color="#999"
|
|
||||||
v-else
|
|
||||||
></uni-icons>
|
|
||||||
<text class="agreement-text">我已阅读并同意《用户隐私政策》</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 登录按钮 -->
|
|
||||||
<button
|
|
||||||
class="login-btn"
|
|
||||||
:disabled="!canLogin"
|
|
||||||
@click="handleLogin"
|
|
||||||
>
|
|
||||||
登录
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- 底部链接 -->
|
|
||||||
<view class="bottom-link">
|
|
||||||
<navigator class="link-item" url="/pages/login/pwd-login">账号密码登录</navigator>
|
|
||||||
<navigator class="link-item" url="/pages/loginSub/register-new-user">注册新用户</navigator>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { ref, computed, onUnmounted } from 'vue';
|
|
||||||
import {getLoginBySms,getSendCode} from '/pages/api/api.js'
|
|
||||||
|
|
||||||
// ========== 响应式数据 ==========
|
|
||||||
// 手机号
|
|
||||||
const phoneNumber = ref('');
|
|
||||||
// 验证码
|
|
||||||
const verifyCode = ref('');
|
|
||||||
const placeholderStyle = ref('font-size:24rpx')
|
|
||||||
// 是否同意协议
|
|
||||||
const agreeAgreement = ref(true); // 默认勾选
|
|
||||||
// 倒计时(秒)
|
|
||||||
const countDown = ref(0);
|
|
||||||
// 定时器
|
|
||||||
let timer = null;
|
|
||||||
|
|
||||||
// ========== 计算属性 ==========
|
|
||||||
// 是否可以获取验证码(手机号格式正确)
|
|
||||||
const canGetVerify = computed(() => {
|
|
||||||
// 手机号正则:11位数字,以1开头
|
|
||||||
const phoneReg = /^1[3-9]\d{9}$/;
|
|
||||||
return phoneReg.test(phoneNumber.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 是否可以登录(手机号+验证码+协议都满足)
|
|
||||||
const canLogin = computed(() => {
|
|
||||||
const phoneReg = /^1[3-9]\d{9}$/;
|
|
||||||
const verifyReg = /^\d{6}$/;
|
|
||||||
return phoneReg.test(phoneNumber.value) && verifyReg.test(verifyCode.value) && agreeAgreement.value;
|
|
||||||
});
|
|
||||||
|
|
||||||
// ========== 方法 ==========
|
|
||||||
// 检查表单状态
|
|
||||||
const checkForm = () => {
|
|
||||||
// 无需额外逻辑,计算属性已实时监听
|
|
||||||
};
|
|
||||||
|
|
||||||
// 切换协议勾选状态
|
|
||||||
const toggleAgreement = () => {
|
|
||||||
agreeAgreement.value = !agreeAgreement.value;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取验证码
|
|
||||||
const getVerifyCode = () => {
|
|
||||||
if (!canGetVerify.value) return;
|
|
||||||
let params = {
|
|
||||||
phone:phoneNumber.value,
|
|
||||||
scene:'login'
|
|
||||||
}
|
|
||||||
getSendCode(params).then(res =>{
|
|
||||||
if(res.code === 200){
|
|
||||||
uni.showToast({
|
|
||||||
title: '验证码已发送',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
|
|
||||||
}else{
|
|
||||||
uni.showToast({
|
|
||||||
title: '验证码发送失败',
|
|
||||||
icon: 'error'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 开始60秒倒计时
|
|
||||||
countDown.value = 60;
|
|
||||||
timer = setInterval(() => {
|
|
||||||
countDown.value--;
|
|
||||||
if (countDown.value <= 0) {
|
|
||||||
clearInterval(timer);
|
|
||||||
timer = null;
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 登录处理
|
|
||||||
const handleLogin = () => {
|
|
||||||
if (!canLogin.value) return;
|
|
||||||
let params = {
|
|
||||||
phone:phoneNumber.value,
|
|
||||||
smsCode:'123456',
|
|
||||||
scene:'login',
|
|
||||||
}
|
|
||||||
getLoginBySms(params).then(res =>{
|
|
||||||
if(res.code === 200){
|
|
||||||
//uni.setStorageSync('token', res.token); // 假设后端返回token字段
|
|
||||||
uni.showToast({ title: '登录成功', icon: 'success' });
|
|
||||||
|
|
||||||
}else{
|
|
||||||
uni.showToast({ title:'登录失败', icon: 'error' });
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
uni.switchTab({ url: '/pages/index/index' });
|
|
||||||
// 模拟登录请求
|
|
||||||
// uni.showLoading({
|
|
||||||
// title: '登录中...'
|
|
||||||
// });
|
|
||||||
};
|
|
||||||
|
|
||||||
// ========== 生命周期 ==========
|
|
||||||
// 页面卸载时清除定时器
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (timer) {
|
|
||||||
clearInterval(timer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style>
|
||||||
/* 页面容器 */
|
|
||||||
.login-page {
|
|
||||||
padding: 80rpx 40rpx 40rpx;
|
|
||||||
/* background-color: #f8f9fa; */
|
|
||||||
min-height: 100vh;
|
|
||||||
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF );
|
|
||||||
}
|
|
||||||
.status_bar {
|
|
||||||
height: 160px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 登录标题 */
|
|
||||||
.login-title {
|
|
||||||
font-size: 48rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #333;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 80rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 输入框项 */
|
|
||||||
.input-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 40rpx;
|
|
||||||
padding: 0 30rpx;
|
|
||||||
height: 88rpx;
|
|
||||||
margin-bottom: 30rpx;
|
|
||||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 验证码输入项(特殊布局) */
|
|
||||||
.verify-item {
|
|
||||||
position: relative;
|
|
||||||
padding-right: 220rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 输入框图标 */
|
|
||||||
.input-icon {
|
|
||||||
width: 50rpx;
|
|
||||||
height: 50rpx;
|
|
||||||
margin-right: 20rpx;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 输入框内容 */
|
|
||||||
.input-content {
|
|
||||||
flex: 1;
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #333;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 验证码输入框 */
|
|
||||||
.verify-input {
|
|
||||||
padding-right: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 获取验证码按钮 */
|
|
||||||
.get-verify-btn {
|
|
||||||
position: absolute;
|
|
||||||
right: 10rpx;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
width: 200rpx;
|
|
||||||
height: 70rpx;
|
|
||||||
line-height: 70rpx;
|
|
||||||
background-color: #007aff;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 35rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 获取验证码按钮禁用状态 */
|
|
||||||
.get-verify-btn:disabled {
|
|
||||||
background-color: #ccc;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 协议勾选项 */
|
|
||||||
.agreement-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin: 40rpx 0;
|
|
||||||
padding-left: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 协议文本 */
|
|
||||||
.agreement-text {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #666;
|
|
||||||
margin-left: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 登录按钮 */
|
|
||||||
.login-btn {
|
|
||||||
width: 100%;
|
|
||||||
height: 88rpx;
|
|
||||||
line-height: 88rpx;
|
|
||||||
background-color: #007aff;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 44rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
margin-bottom: 60rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 登录按钮禁用状态 */
|
|
||||||
.login-btn:disabled {
|
|
||||||
background-color: #99c8ff;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 底部链接 */
|
|
||||||
.bottom-link {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 0 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 链接项 */
|
|
||||||
.link-item {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #007aff;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
Before Width: | Height: | Size: 413 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 186 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 624 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 577 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 562 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 475 B |
|
Before Width: | Height: | Size: 909 B After Width: | Height: | Size: 323 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 289 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 286 B |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 290 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 282 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 470 B |
|
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 348 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 471 B |
|
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 382 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 624 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 397 B |
|
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 854 B After Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 797 B After Width: | Height: | Size: 309 B |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 1.3 KiB |