20261008
This commit is contained in:
@@ -0,0 +1,321 @@
|
||||
<template> <!-- 忘记密码 -->
|
||||
<view class="wrap">
|
||||
<view class="login-img">
|
||||
<image class="full" src="/static/img/login.png" mode=""></image>
|
||||
</view>
|
||||
<view class="layout-login bg-white">
|
||||
<view class="login-title">找回密码</view>
|
||||
<view class="login-form">
|
||||
<view class="m-top-30">
|
||||
<u--input
|
||||
v-model="form1.mobile"
|
||||
placeholder="请输入手机号"
|
||||
prefixIcon="account"
|
||||
prefixIconStyle="font-size: 26px;color: #909399"
|
||||
></u--input>
|
||||
</view>
|
||||
<view class="m-top-30">
|
||||
<u--input
|
||||
v-model="form1.code"
|
||||
placeholder="请输入短信验证码"
|
||||
prefixIcon="email"
|
||||
prefixIconStyle="font-size: 26px;color: #909399"
|
||||
>
|
||||
<template slot="suffix">
|
||||
<u-code
|
||||
ref="uCode"
|
||||
@change="codeChange"
|
||||
seconds="20"
|
||||
changeText="X秒重新获取"
|
||||
></u-code>
|
||||
<u-button
|
||||
@tap="sendSmsCode"
|
||||
:text="smsTips"
|
||||
type="success"
|
||||
size="mini"
|
||||
color="#db1c2c"
|
||||
></u-button>
|
||||
</template>
|
||||
</u--input>
|
||||
</view>
|
||||
<view class="m-top-30">
|
||||
<u--input
|
||||
v-model="form1.password"
|
||||
placeholder="设置登录密码"
|
||||
prefixIcon="lock"
|
||||
prefixIconStyle="font-size: 26px;color: #909399"
|
||||
></u--input>
|
||||
</view>
|
||||
<view class="m-top-30">
|
||||
<u--input
|
||||
v-model="form1.repassword"
|
||||
placeholder="确认登录密码"
|
||||
prefixIcon="lock"
|
||||
prefixIconStyle="font-size: 26px;color: #909399"
|
||||
></u--input>
|
||||
</view>
|
||||
<view class="m-top-30">
|
||||
<u-button color="#db1c2c" text="立即找回" @click="handleSubmit"></u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let timer = null
|
||||
let timeS = 60
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
roleIndex: 1,
|
||||
tabIndex: 1,
|
||||
tips: '',
|
||||
checked: false,
|
||||
smsTips: '获取验证码',
|
||||
form1: {
|
||||
mobile: '',
|
||||
password: '',
|
||||
repassword: '',
|
||||
code: '',
|
||||
username: ''
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handRole(index) {
|
||||
this.roleIndex = index
|
||||
},
|
||||
handTab(index) {
|
||||
this.tabIndex = index
|
||||
},
|
||||
codeChange(text) {
|
||||
this.tips = text;
|
||||
},
|
||||
getCode() {
|
||||
if (this.$refs.uCode.canGetCode) {
|
||||
// 模拟向后端请求验证码
|
||||
uni.showLoading({
|
||||
title: '正在获取验证码'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
// 这里此提示会被this.start()方法中的提示覆盖
|
||||
uni.$u.toast('验证码已发送');
|
||||
// 通知验证码组件内部开始倒计时
|
||||
this.$refs.uCode.start();
|
||||
}, 2000);
|
||||
} else {
|
||||
uni.$u.toast('倒计时结束后再发送');
|
||||
}
|
||||
},
|
||||
handleSubmit() {
|
||||
if (this.testForm()) {
|
||||
const {
|
||||
password,
|
||||
mobile,
|
||||
code
|
||||
} = this.form1
|
||||
|
||||
vk.userCenter.resetPasswordByMobile({
|
||||
data: {
|
||||
password,
|
||||
mobile,
|
||||
code
|
||||
},
|
||||
success: (data) => {
|
||||
// 成功后的逻辑
|
||||
this.$message({
|
||||
message: "密码重置成功",
|
||||
type: 'success'
|
||||
})
|
||||
vk.redirectTo({
|
||||
url: '/pages/auth/login/login'
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
sendSmsCode() {
|
||||
if (timer != null) {
|
||||
return
|
||||
}
|
||||
vk.userCenter.sendSmsCode({
|
||||
loading: false,
|
||||
data: {
|
||||
mobile: this.form1.mobile,
|
||||
type: 'reset-pwd',
|
||||
},
|
||||
success: (data) => {
|
||||
|
||||
this.$message({
|
||||
message: "验证码已发送",
|
||||
type: 'success'
|
||||
})
|
||||
timeS = 60
|
||||
timer = setInterval(() => {
|
||||
timeS--
|
||||
if (timeS <= 0) {
|
||||
this.smsTips = "重新发送"
|
||||
this.stopTimer()
|
||||
} else {
|
||||
this.smsTips = timeS + "秒"
|
||||
}
|
||||
|
||||
}, 1000)
|
||||
}
|
||||
});
|
||||
},
|
||||
stopTimer() {
|
||||
if (timer != null) {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
|
||||
},
|
||||
loginSuccess() {
|
||||
uni.reLaunch({
|
||||
url: '/'
|
||||
})
|
||||
},
|
||||
testForm() {
|
||||
const {
|
||||
mobile, // 手机号
|
||||
code, // 短信验证码4-8位
|
||||
password, // 密码 6-20位
|
||||
repassword, // 重复输入密码
|
||||
} = this.form1;
|
||||
|
||||
// 手机号验证
|
||||
if (!mobile || !/^1[3456789]\d{9}$/.test(mobile)) {
|
||||
this.$message({
|
||||
message: '手机号为空或格式不正确',
|
||||
type: 'error'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
// 短信验证码验证
|
||||
if (!code || !/^\d{4,8}$/.test(code)) {
|
||||
// 短信验证码为空或格式不正确
|
||||
// 处理错误逻辑
|
||||
this.$message({
|
||||
message: '短信验证码为空或格式不正确',
|
||||
type: 'error'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
// 密码验证
|
||||
if (!password || password.length < 6 || password.length > 20) {
|
||||
// 密码为空或长度不符合要求
|
||||
this.$message({
|
||||
message: '密码长度不符合要求',
|
||||
type: 'error'
|
||||
})
|
||||
return false
|
||||
// 处理错误逻辑
|
||||
}
|
||||
|
||||
// 重复输入密码验证
|
||||
if (password !== repassword) {
|
||||
// 两次输入的密码不一致
|
||||
this.$message({
|
||||
message: '两次输入的密码不一致',
|
||||
type: 'error'
|
||||
})
|
||||
return false
|
||||
// 处理错误逻辑
|
||||
}
|
||||
return true
|
||||
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
if (timer != null) {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: #e8f5fe;
|
||||
}
|
||||
|
||||
.login-img {
|
||||
width: 100%;
|
||||
height: 330rpx;
|
||||
}
|
||||
|
||||
.layout-login {
|
||||
margin: 20rpx 30rpx;
|
||||
padding: 30rpx 30rpx 50rpx;
|
||||
|
||||
.login-title {
|
||||
font-size: 44rpx;
|
||||
font-weight: 500;
|
||||
line-height: 60rpx;
|
||||
text-align: center;
|
||||
color: #101010;
|
||||
}
|
||||
|
||||
.login-type {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
color: #8e8e8e;
|
||||
}
|
||||
|
||||
.login-role .role {
|
||||
position: relative;
|
||||
margin: 0 50rpx;
|
||||
padding-left: 60rpx;
|
||||
font-size: 30rpx;
|
||||
line-height: 40rpx;
|
||||
color: #666666;
|
||||
|
||||
&:before {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
z-index: 9;
|
||||
content: '';
|
||||
transform: translateY(-50%);
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
padding: 10rpx;
|
||||
border: 1px solid #f2f2f2;
|
||||
border-radius: 50%;
|
||||
box-sizing: border-box;
|
||||
background-clip: content-box;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
.login-role .active {
|
||||
color: #A92924;
|
||||
|
||||
&:before {
|
||||
border-color: #A92924;
|
||||
background-color: #A92924;
|
||||
}
|
||||
}
|
||||
|
||||
.fg {
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.xie {
|
||||
font-size: 26rpx;
|
||||
line-height: 40rpx;
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user