Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
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
黄庭坚
jinfa-platform
Commits
2bb62c82
Commit
2bb62c82
authored
Oct 23, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:加入忘记密码校验
parent
a5198e4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
forgetPwd.tsx
src/pages/user/forgetPwd.tsx
+41
-0
index.ts
src/pages/user/schema/index.ts
+7
-3
No files found.
src/pages/user/forgetPwd.tsx
View file @
2bb62c82
...
...
@@ -13,6 +13,8 @@ import { createFormActions } from '@formily/antd';
import
{
PublicApi
}
from
'@/services/api'
;
const
actions
=
createFormActions
()
const
prefixCode
=
'+86'
const
GetBack
:
React
.
FC
=
()
=>
{
const
handleSubmit
=
async
(
value
:
any
)
=>
{
...
...
@@ -45,6 +47,45 @@ const GetBack: React.FC = () => {
SubmitBtn
}
}
effects=
{
(
$
,
{
setFieldState
,
getFieldState
})
=>
{
$
(
'onFieldInputChange'
,
'account'
).
subscribe
(
fieldState
=>
{
// 手动输入的时候 重置校验信息
setFieldState
(
'account'
,
state
=>
{
state
.
errors
=
[]
})
})
$
(
'onFieldValidateEnd'
,
'account'
).
subscribe
(
fieldState
=>
{
if
(
fieldState
.
valid
)
{
if
(
PATTERN_MAPS
.
phone
.
test
(
fieldState
.
value
))
{
// 校验手机号格式通过时, 需请求接口判断手机号是否存在数据库
PublicApi
.
getMemberRegisterPhoneCheck
({
countryCode
:
prefixCode
,
phone
:
fieldState
.
value
},
{
ctlType
:
'none'
,
useCache
:
true
,
ttl
:
60
*
1000
}).
then
(({
code
,
data
})
=>
{
if
(
code
===
1000
)
{
setFieldState
(
'account'
,
state
=>
{
state
.
errors
=
[
'手机号不存在, 请检查'
]
})
}
})
return
;
}
if
(
PATTERN_MAPS
.
email
.
test
(
fieldState
.
value
))
{
// 校验邮箱格式通过时, 需请求接口判断邮箱是否存在数据库
PublicApi
.
getMemberRegisterEmailCheck
({
email
:
fieldState
.
value
},
{
ctlType
:
'none'
,
useCache
:
true
,
ttl
:
60
*
1000
}).
then
(({
code
,
data
})
=>
{
if
(
code
===
1000
)
{
setFieldState
(
'account'
,
state
=>
{
state
.
errors
=
[
'邮箱不存在, 请检查'
]
})
}
})
return
;
}
}
})
$
(
'onFieldValueChange'
,
'*(password,confirmPassword)'
).
subscribe
(
fieldState
=>
{
const
selfName
=
fieldState
.
name
const
selfValue
=
fieldState
.
value
...
...
src/pages/user/schema/index.ts
View file @
2bb62c82
import
{
ISchema
}
from
'@formily/antd'
;
import
{
ISchema
,
ISchemaFormActions
}
from
'@formily/antd'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
import
{
PublicApi
}
from
'@/services/api'
;
...
...
@@ -221,8 +221,12 @@ export const forgetPwdSchema: ISchema = {
],
"x-component-props"
:
{
size
:
'large'
,
smsFn
:
(
form
,
setLoading
,
callback
)
=>
{
form
.
validate
(
'account'
).
then
(()
=>
{
smsFn
:
(
form
:
ISchemaFormActions
,
setLoading
,
callback
)
=>
{
form
.
validate
(
'account'
).
then
((
res
)
=>
{
const
state
=
form
.
getFieldState
(
'account'
)
if
(
state
.
errors
?.
length
>
0
)
{
return
;
}
const
values
=
form
.
getFieldValue
(
'account'
)
const
isPhone
=
PATTERN_MAPS
.
phone
.
test
(
values
)
const
isEmail
=
PATTERN_MAPS
.
email
.
test
(
values
)
...
...
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