Commit ea8362c2 by 高浩杰

fix login third

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