Browse Source

fix changePassword

zhangyong/feature-20250815160302-金币优化
zhangrenyuan 2 months ago
parent
commit
4f05075f50
  1. 8
      src/components/changePassword.vue

8
src/components/changePassword.vue

@ -32,7 +32,9 @@ const getAccount= async function() {
} }
} }
// //
const isLengthValid = computed(() => passwd.newPassword.length >= 8 && passwd.newPassword.length <= 16)
const isLengthValid = computed(() =>
/^[A-Za-z0-9~!@#$%^&*()_+\-=[\]{}|;:,.<>?/]{8,16}$/.test(passwd.newPassword)
);
const isComplexValid = computed(() => { const isComplexValid = computed(() => {
const rules = [/\d/, /[a-z]/, /[A-Z]/, /[^a-zA-Z0-9]/] const rules = [/\d/, /[a-z]/, /[A-Z]/, /[^a-zA-Z0-9]/]
@ -62,7 +64,7 @@ const rules = reactive({
} else if (value.length < 8 || value.length > 16) { } else if (value.length < 8 || value.length > 16) {
callback(new Error('长度应在 8 到 16 个字符')) callback(new Error('长度应在 8 到 16 个字符'))
} else { } else {
const types = [/\d/, /[a-z]/, /[A-Z]/, /[^a-zA-Z0-9]/]
const types = [/\d/, /[a-z]/, /[A-Z]/, /[!@#$%^&*()\-_+={}[\]|\\:;"'<>,.?/~`]/];
const matchCount = types.filter((r) => r.test(value)).length const matchCount = types.filter((r) => r.test(value)).length
if (matchCount < 2) { if (matchCount < 2) {
callback(new Error('密码至少包含两种类型(数字、字母或符号)')) callback(new Error('密码至少包含两种类型(数字、字母或符号)'))
@ -115,7 +117,7 @@ const changePassword = async function () {
router.push('/PasswordSuccess'); router.push('/PasswordSuccess');
}, 1000); }, 1000);
}else if (result.code === 0){ }else if (result.code === 0){
ElMessage.error('原密码错误')
ElMessage.error('原密码错误,请重新输入')
passwd.oldPassword = ''; passwd.oldPassword = '';
}else if(result.code === 400){ }else if(result.code === 400){

Loading…
Cancel
Save