Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ant-design-pro-vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianzhuanghu
ant-design-pro-vue
Commits
b3067fb4
Commit
b3067fb4
authored
Nov 22, 2018
by
sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: register password check level
parent
7dc1af0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
20 deletions
+39
-20
Register.vue
src/views/user/Register.vue
+39
-20
No files found.
src/views/user/Register.vue
View file @
b3067fb4
...
@@ -4,33 +4,38 @@
...
@@ -4,33 +4,38 @@
<a-form
ref=
"formRegister"
:autoFormCreate=
"(form)=>
{this.form = form}" id="formRegister">
<a-form
ref=
"formRegister"
:autoFormCreate=
"(form)=>
{this.form = form}" id="formRegister">
<a-form-item
<a-form-item
fieldDecoratorId=
"email"
fieldDecoratorId=
"email"
:fieldDecoratorOptions=
"
{rules: [{ required: true,
message: '请输入邮箱地址' }], validateTrigger: 'blur'
}">
:fieldDecoratorOptions=
"
{rules: [{ required: true,
type: 'email', message: '请输入邮箱地址' }]
}">
<a-input
size=
"large"
type=
"text"
placeholder=
"邮箱"
></a-input>
<a-input
size=
"large"
type=
"text"
placeholder=
"邮箱"
></a-input>
</a-form-item>
</a-form-item>
<a-form-item
<a-popover
placement=
"right"
trigger=
"click"
:visible=
"state.passwordLevelChecked"
>
fieldDecoratorId=
"password"
<template
slot=
"content"
>
:fieldDecoratorOptions=
"
{rules: [{ required: true, message: '至少6位密码,区分大小写' }, { validator: this.handlePasswordLevel }], validateTrigger: ['change', 'blur']}">
<div
:style=
"
{ width: '240px' }">
<a-popover
placement=
"right"
trigger=
"click"
:visible=
"clicked"
@
visibleChange=
"clicked = true"
>
<div
:class=
"['user-register', passwordLevelClass]"
>
强度:
<span>
{{
passwordLevelName
}}
</span></div>
<template
slot=
"content"
>
<a-progress
:percent=
"state.percent"
:showInfo=
"false"
:strokeColor=
" passwordLevelColor "
/>
<div
:style=
"
{ width: '240px' }">
<div
style=
"margin-top: 10px;"
>
<div
:class=
"['user-register', passwordLevelClass]"
>
强度:
<span>
{{
passwordLevelName
}}
</span></div>
<span>
请至少输入 6 个字符。请不要使用容易被猜到的密码。
</span>
<a-progress
:percent=
"state.percent"
:showInfo=
"false"
strokeColor=
"#FF0000"
/>
<div
style=
"margin-top: 10px;"
>
<span>
请至少输入 6 个字符。请不要使用容易被猜到的密码。
</span>
</div>
</div>
</div>
</
template
>
</div>
<a-input
size=
"large"
type=
"password"
placeholder=
"至少6位密码,区分大小写"
></a-input>
</
template
>
</a-popover>
<a-form-item
</a-form-item>
fieldDecoratorId=
"password"
:fieldDecoratorOptions=
"{rules: [
{ required: true, message: '至少6位密码,区分大小写'},
{ validator: this.handlePasswordLevel }
]}"
>
<a-input
size=
"large"
type=
"password"
@
click=
"state.passwordLevelChecked = true"
autocomplete=
"false"
placeholder=
"至少6位密码,区分大小写"
></a-input>
</a-form-item>
</a-popover>
<a-form-item
<a-form-item
fieldDecoratorId=
"password2"
fieldDecoratorId=
"password2"
:fieldDecoratorOptions=
"{rules: [{ required: true, message: '至少6位密码,区分大小写' }, { validator: this.handlePasswordCheck }]
, validateTrigger: 'blur'
}"
>
:fieldDecoratorOptions=
"{rules: [{ required: true, message: '至少6位密码,区分大小写' }, { validator: this.handlePasswordCheck }]}"
>
<a-input
size=
"large"
type=
"password"
placeholder=
"确认密码"
></a-input>
<a-input
size=
"large"
type=
"password"
autocomplete=
"false"
placeholder=
"确认密码"
></a-input>
</a-form-item>
</a-form-item>
<a-form-item
<a-form-item
...
@@ -98,6 +103,12 @@
...
@@ -98,6 +103,12 @@
2
:
'warning'
,
2
:
'warning'
,
3
:
'success'
3
:
'success'
}
}
const
levelColor
=
{
0
:
'#ff0000'
,
1
:
'#ff0000'
,
2
:
'#ff7e05'
,
3
:
'#52c41a'
,
}
export
default
{
export
default
{
name
:
"Register"
,
name
:
"Register"
,
components
:
{
components
:
{
...
@@ -106,12 +117,13 @@
...
@@ -106,12 +117,13 @@
return
{
return
{
form
:
null
,
form
:
null
,
clicked
:
false
,
state
:
{
state
:
{
time
:
60
,
time
:
60
,
smsSendBtn
:
false
,
smsSendBtn
:
false
,
passwordLevel
:
0
,
passwordLevel
:
0
,
percent
:
0
,
passwordLevelChecked
:
false
,
percent
:
10
,
progressColor
:
'#FF0000'
},
},
registerBtn
:
false
registerBtn
:
false
}
}
...
@@ -122,11 +134,15 @@
...
@@ -122,11 +134,15 @@
},
},
passwordLevelName
()
{
passwordLevelName
()
{
return
levelNames
[
this
.
state
.
passwordLevel
]
return
levelNames
[
this
.
state
.
passwordLevel
]
},
passwordLevelColor
()
{
return
levelColor
[
this
.
state
.
passwordLevel
]
}
}
},
},
methods
:
{
methods
:
{
handlePasswordLevel
(
rule
,
value
,
callback
)
{
handlePasswordLevel
(
rule
,
value
,
callback
)
{
let
level
=
0
let
level
=
0
// 判断这个字符串中有没有数字
// 判断这个字符串中有没有数字
...
@@ -150,6 +166,9 @@
...
@@ -150,6 +166,9 @@
}
}
callback
()
callback
()
}
else
{
}
else
{
if
(
level
==
0
)
{
this
.
state
.
percent
=
10
}
callback
(
new
Error
(
'密码强度不够'
))
callback
(
new
Error
(
'密码强度不够'
))
}
}
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment