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
shenshaokai
jinfa-platform
Commits
c6a733f8
Commit
c6a733f8
authored
Oct 21, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:修改密码
parent
7d4f8798
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
83 deletions
+36
-83
forgetPwd.tsx
src/pages/user/forgetPwd.tsx
+23
-80
index.ts
src/pages/user/schema/index.ts
+13
-3
No files found.
src/pages/user/forgetPwd.tsx
View file @
c6a733f8
import
React
,
{
useState
,
Fragment
}
from
'react'
;
import
cx
from
'classnames'
;
import
{
Row
}
from
'antd'
;
import
{
Link
,
Helmet
}
from
'umi'
import
{
Row
,
Button
}
from
'antd'
;
import
{
Link
,
Helmet
,
history
}
from
'umi'
import
{
FormPage
,
RiskCheck
}
from
'god'
import
{
IFormControllers
,
IFormButtonTypes
}
from
'god/dist/src/form-page'
import
'./index.less'
...
...
@@ -9,90 +9,25 @@ import NiceForm from '@/components/NiceForm';
import
{
forgetPwdSchema
}
from
'./schema'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
omit
}
from
'@/utils'
;
import
{
createFormActions
}
from
'@formily/antd'
;
import
{
PublicApi
}
from
'@/services/api'
;
const
actions
=
createFormActions
()
const
GetBack
:
React
.
FC
=
()
=>
{
const
[
validButton
,
setValidButton
]
=
useState
(
true
)
const
finish
=
(
value
:
any
)
=>
{
console
.
log
(
value
,
'finish'
)
}
const
handleSubmit
=
(
value
:
any
)
=>
{
const
handleSubmit
=
async
(
value
:
any
)
=>
{
const
{
account
}
=
value
const
accountParams
=
PATTERN_MAPS
.
email
.
test
(
account
)
?
{
email
:
account
,
...
omit
(
value
,
[
'account'
])}
:
{
phone
:
account
,
...
omit
(
value
,
[
'account'
])
}
console
.
log
(
accountParams
)
}
const
getBcakForm
:
IFormControllers
[]
=
[
{
type
:
'Input'
,
name
:
'phonemail'
,
span
:
24
,
inputProps
:
{
type
:
'phonemail'
,
placeholder
:
'请输入您的邮箱/手机'
,
},
rules
:
[
{
required
:
true
,
message
:
'邮箱/手机为必填项!'
}
]
},
// {
// span: 24,
// // @ts-ignore
// custom: () => <RiskCheck />
// },
{
type
:
'Verification'
,
name
:
'smsCode'
,
span
:
24
,
inputProps
:
{
const
isEmail
=
PATTERN_MAPS
.
email
.
test
(
account
)
const
accountParams
=
isEmail
?
{
email
:
account
,
...
omit
(
value
,
[
'account'
,
'confirmPassword'
])}
:
{
phone
:
account
,
...
omit
(
value
,
[
'account'
,
'confirmPassword'
])
}
const
submitFn
=
isEmail
?
PublicApi
.
postMemberRegisterResetEmail
:
PublicApi
.
postMemberRegisterResetSms
}
},
{
type
:
'Input'
,
name
:
'password'
,
span
:
24
,
inputProps
:
{
type
:
'password'
,
placeholder
:
'设置你的密码'
,
},
rules
:
[
{
required
:
true
,
message
:
'密码为必填项!'
},
{
pattern
:
/^
(?=
.*
[
a-z
])(?=
.*
[
A-Z
])(?=
.*
\d)[^]{8,20}
$/
,
message
:
'密码长度8-20个字符,必须包含大小写字母和数字!'
}
],
},
{
type
:
'Input'
,
name
:
'confirm'
,
span
:
24
,
dependencies
:
[
'password'
],
inputProps
:
{
type
:
'password'
,
placeholder
:
'请再次输入密码'
,
},
rules
:
[
{
required
:
true
,
message
:
'请再次确认密码!'
},
({
getFieldValue
})
=>
({
validator
(
rule
,
value
)
{
if
(
!
value
||
getFieldValue
(
'password'
)
===
value
)
{
return
Promise
.
resolve
();
}
return
Promise
.
reject
(
'两次的密码输入不一致!'
);
},
}),
]
},
]
const
getBackButtons
:
IFormButtonTypes
[]
=
[
{
text
:
'提交'
,
type
:
'primary'
,
htmlType
:
'submit'
,
block
:
true
,
disabled
:
false
,
const
{
code
}
=
await
submitFn
(
accountParams
)
if
(
code
===
1000
)
{
history
.
replace
(
'/user/login'
)
}
]
}
const
SubmitBtn
=
<
Button
type=
'primary'
block
htmlType=
'submit'
>
提交
</
Button
>
return
(
<
Fragment
>
...
...
@@ -105,6 +40,10 @@ const GetBack: React.FC = () => {
<
NiceForm
schema=
{
forgetPwdSchema
}
onSubmit=
{
handleSubmit
}
actions=
{
actions
}
expressionScope=
{
{
SubmitBtn
}
}
effects=
{
(
$
,
{
setFieldState
,
getFieldState
})
=>
{
$
(
'onFieldValueChange'
,
'*(password,confirmPassword)'
).
subscribe
(
fieldState
=>
{
const
selfName
=
fieldState
.
name
...
...
@@ -128,6 +67,10 @@ const GetBack: React.FC = () => {
})
}
}
/>
<
p
className=
{
'formBox'
}
>
<
Link
className=
'back'
to=
{
'/user/login'
}
>
返回登录页
</
Link
>
</
p
>
</
div
>
</
Row
>
</
Fragment
>
...
...
src/pages/user/schema/index.ts
View file @
c6a733f8
...
...
@@ -205,9 +205,12 @@ export const forgetPwdSchema: ISchema = {
smsCode
:
{
type
:
'string'
,
"x-component"
:
'Phone'
,
required
:
true
,
"x-rules"
:
[
{
required
:
true
,
message
:
'请输入验证码'
},
{
pattern
:
PATTERN_MAPS
.
smsCode
,
message
:
'请输入正确的6位验证码'
}
...
...
@@ -229,6 +232,8 @@ export const forgetPwdSchema: ISchema = {
if
(
res
.
code
===
1000
)
{
callback
()
}
}).
finally
(()
=>
{
setLoading
(
false
)
})
}
...
...
@@ -240,6 +245,8 @@ export const forgetPwdSchema: ISchema = {
if
(
res
.
code
===
1000
)
{
callback
()
}
}).
finally
(()
=>
{
setLoading
(
false
)
})
}
})
...
...
@@ -282,9 +289,12 @@ export const forgetPwdSchema: ISchema = {
size
:
'large'
,
}
},
submit
:
{
VirtualChildren
:
{
type
:
'string'
,
"x-component"
:
'Submit'
"x-component"
:
'VirtualChildren'
,
"x-component-props"
:
{
children
:
"{{SubmitBtn}}"
}
}
}
}
...
...
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