Commit ea8362c2 by 高浩杰

fix login third

parent 8fa18f99
......@@ -46,8 +46,7 @@ export default {
data() {
return {
iconName: 'invisible',
countdown: 60,
errMsg: '' // 错误信息
countdown: 60
}
},
computed: {
......@@ -62,11 +61,7 @@ export default {
},
errMessage: {
get: function () {
if (this.errorMessage !== '') {
return this.errorMessage
} else {
return this.errMsg
}
}
}
},
......
......@@ -21,37 +21,31 @@ function checkEmail(email) {
}
// 检测account 手机 邮箱
function checkAccount(account, isEmail=true) {
function checkAccount(account) {
if(/[a-zA-Z]+/.test(account)) {
if (isEmail) {
// console.log('email');
return checkEmail(account)
}
} else {
return checkPhone(account);
}
}
// 检测密码
function checkPassword(password) {
function checkPassword(password, isLogin=false) {
if (password === '') {
return '密码不能为空';
} else {
} else if (!isLogin) {
let reg = /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{8,16}$/;
if (!reg.test(password)) {
return '密码格式错误';
} else {
return ''
}
return !reg.test(password) ? '密码要求长度为8-16位,包含数字和字母' : '';
}
return ''
}
// 检测验证码
function checkVerification(phone) {
let result = checkPhone(phone);
if (result === '') {
return true
function checkVerification(verifyCode) {
if (verifyCode === '') {
return '验证码不能为空'
}
return ''
}
// function errorCode(res) {
......
......@@ -60,7 +60,7 @@ import loginWrap from '../../components/pc/loginCard/loginWrap'
import LoginInput from "../../components/pc/loginCard/loginInput";
import LoginButton from "../../components/pc/loginCard/loginButton";
import config from '../../action/config';
import {checkAccount, checkPassword, checkVerification} from './checkfrom';
import {checkAccount, checkPhone, checkPassword, checkVerification} from './checkfrom';
const Cookie = process.client ? require('js-cookie') : null;
......@@ -107,14 +107,15 @@ export default {
},
// 检测 密码
checkPassword() {
this.passwordErrMsg = checkPassword(this.password);
this.passwordErrMsg = checkPassword(this.password, true);
},
// 检测验证码
checkVerification() {
this.isCount = false;
let result = checkVerification(this.account);
if (result) {
this.accountErrMsg = checkPhone(this.account);
if (this.accountErrMsg === '') {
this.getSms();
this.verifyErrMsg = '';
this.isCount = true;
setTimeout(() => {
this.isCount = false;
......@@ -146,6 +147,7 @@ export default {
// 防止全部未输入就点击
this.checkAccount();
this.checkPassword();
this.verifyErrMsg = checkVerification(this.verifyCode);
let authResponse;
// 两种登录方式
......
......@@ -72,7 +72,7 @@ export default {
account: '', // 保存 手机号 邮箱
password: '', // 保存 密码
verifyCode: '', // 保存 验证码
isEmail: false, // 判断验证码
isEmail: false, // 判断 邮箱 手机 注册
placeholder: '请输入手机号',
accountErrMsg: '', // 手机号 邮箱 错误提示
passwordErrMsg: '', // 密码错误 提示信息
......@@ -115,18 +115,15 @@ export default {
},
// 检测 密码
checkPassword() {
if (checkPassword(this.password) === '密码格式错误') {
this.passwordErrMsg = '密码要求长度为8-16位,包含数字和字母'
} else {
this.passwordErrMsg = checkPassword(this.password);
}
},
// 检测验证码
checkVerification() {
this.isCount = false;
let result = checkVerification(this.account);
if (result) {
this.accountErrMsg = checkPhone(this.account);
if (this.accountErrMsg === '') {
this.getSms();
this.verifyErrMsg = '';
this.isCount = true;
setTimeout(() => {
this.isCount = false;
......@@ -156,6 +153,7 @@ export default {
async handleRegister() {
this.checkAccount();
this.checkPassword();
this.verifyErrMsg = checkVerification(this.verifyCode);
let registerResponse;
......
......@@ -15,7 +15,7 @@
></login-input>
<login-input
:error-message="passwordErrMsg"
placeholder="请输入密码"
placeholder="请输入新的密码"
input-type="2"
type="password"
v-model="password"
......@@ -33,7 +33,7 @@
></login-input>
</template>
<template #mainFooter>
<login-button @handle="handleReset" button="重账号"></login-button>
<login-button @handle="handleReset" button="重账号"></login-button>
</template>
</login-wrap>
</div>
......@@ -64,7 +64,7 @@ export default {
password: '', // 保存 密码
verifyCode: '', // 保存 验证码
isPassword: true, // 判断验证码
placeholder: '请输入手机号或邮箱',
placeholder: '请输入手机号',
accountErrMsg: '', // 手机号 邮箱 错误提示
passwordErrMsg: '', // 密码错误 提示信息
verifyErrMsg: '', // 验证码错误 提示信息
......@@ -74,7 +74,7 @@ export default {
watch: {
account: function (val) {
if (val.length > 10) {
this.checkPhone();
this.checkAccount();
}
},
password: function (val) {
......@@ -90,18 +90,15 @@ export default {
},
// 检测 密码
checkPassword() {
if (checkPassword(this.password) === '密码格式错误') {
this.passwordErrMsg = '密码要求长度为8-16位,包含数字和字母'
} else {
this.passwordErrMsg = checkPassword(this.password);
}
},
// 检测验证码
checkVerification() {
this.isCount = false;
let result = checkVerification(this.account);
if (result) {
this.accountErrMsg = checkPhone(this.account);
if (this.accountErrMsg === '') {
this.getSms();
this.verifyErrMsg = '';
this.isCount = true;
setTimeout(() => {
this.isCount = false;
......@@ -131,7 +128,7 @@ export default {
async handleReset() {
this.checkAccount();
this.checkPassword();
this.verifyErrMsg = checkVerification(this.verifyCode);
let resetResponse;
if (this.passwordErrMsg === '' && this.accountErrMsg === '' && this.verifyErrMsg === '') {
......@@ -149,9 +146,7 @@ export default {
type: 'success',
message: resetResponse.msg
});
setTimeout(() => {
this.$router.push('/users/login');
}, 2500)
} else if(resetResponse !== undefined) {
// 修改密码失败
if (resetResponse.code === 1002) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment