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
linweijiong
jinfa-platform
Commits
d3026192
Commit
d3026192
authored
Oct 21, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:修改密码
parent
8ce3c83d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
6 deletions
+116
-6
Phone.tsx
src/components/NiceForm/components/Phone.tsx
+4
-2
forgetPwd.tsx
src/pages/user/forgetPwd.tsx
+28
-1
index.ts
src/pages/user/schema/index.ts
+84
-3
No files found.
src/components/NiceForm/components/Phone.tsx
View file @
d3026192
...
@@ -20,9 +20,11 @@ const Phone = (props) => {
...
@@ -20,9 +20,11 @@ const Phone = (props) => {
const
handleClickSms
=
()
=>
{
const
handleClickSms
=
()
=>
{
if
(
smsFn
)
{
if
(
smsFn
)
{
smsFn
(
form
,
()
=>
{
smsFn
(
form
,
setLoading
,
()
=>
{
start
()
setLoading
(
false
)
})
})
return
;
}
}
form
.
validate
(
'phone'
).
then
(
result
=>
{
form
.
validate
(
'phone'
).
then
(
result
=>
{
// 暂时写死, 需优化该组件
// 暂时写死, 需优化该组件
...
...
src/pages/user/forgetPwd.tsx
View file @
d3026192
...
@@ -7,6 +7,8 @@ import { IFormControllers, IFormButtonTypes } from 'god/dist/src/form-page'
...
@@ -7,6 +7,8 @@ import { IFormControllers, IFormButtonTypes } from 'god/dist/src/form-page'
import
'./index.less'
import
'./index.less'
import
NiceForm
from
'@/components/NiceForm'
;
import
NiceForm
from
'@/components/NiceForm'
;
import
{
forgetPwdSchema
}
from
'./schema'
;
import
{
forgetPwdSchema
}
from
'./schema'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
omit
}
from
'@/utils'
;
const
GetBack
:
React
.
FC
=
()
=>
{
const
GetBack
:
React
.
FC
=
()
=>
{
const
[
validButton
,
setValidButton
]
=
useState
(
true
)
const
[
validButton
,
setValidButton
]
=
useState
(
true
)
...
@@ -16,7 +18,9 @@ const GetBack: React.FC = () => {
...
@@ -16,7 +18,9 @@ const GetBack: React.FC = () => {
}
}
const
handleSubmit
=
(
value
:
any
)
=>
{
const
handleSubmit
=
(
value
:
any
)
=>
{
console
.
log
(
value
,
'handleSubmit'
)
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
[]
=
[
const
getBcakForm
:
IFormControllers
[]
=
[
...
@@ -100,6 +104,29 @@ const GetBack: React.FC = () => {
...
@@ -100,6 +104,29 @@ const GetBack: React.FC = () => {
<
div
className=
{
cx
(
'getBackForm'
)
}
>
<
div
className=
{
cx
(
'getBackForm'
)
}
>
<
NiceForm
<
NiceForm
schema=
{
forgetPwdSchema
}
schema=
{
forgetPwdSchema
}
onSubmit=
{
handleSubmit
}
effects=
{
(
$
,
{
setFieldState
,
getFieldState
})
=>
{
$
(
'onFieldValueChange'
,
'*(password,confirmPassword)'
).
subscribe
(
fieldState
=>
{
const
selfName
=
fieldState
.
name
const
selfValue
=
fieldState
.
value
const
otherName
=
selfName
==
'password'
?
'confirmPassword'
:
'password'
const
otherValue
=
getFieldState
(
otherName
,
state
=>
state
.
value
)
setFieldState
(
otherName
,
state
=>
{
if
(
selfValue
&&
otherValue
&&
selfValue
!==
otherValue
)
{
state
.
errors
=
[
'两次密码输入不一致'
]
}
else
{
state
.
errors
=
[
''
]
}
})
setFieldState
(
selfName
,
state
=>
{
if
(
selfValue
&&
otherValue
&&
selfValue
!==
otherValue
)
{
state
.
errors
=
[
'两次密码输入不一致'
]
}
else
{
state
.
errors
=
[
''
]
}
})
})
}
}
/>
/>
</
div
>
</
div
>
</
Row
>
</
Row
>
...
...
src/pages/user/schema/index.ts
View file @
d3026192
import
{
ISchema
}
from
'@formily/antd'
;
import
{
ISchema
}
from
'@formily/antd'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
import
{
PublicApi
}
from
'@/services/api'
;
export
const
registerStep0Schema
:
ISchema
=
{
export
const
registerStep0Schema
:
ISchema
=
{
type
:
'object'
,
type
:
'object'
,
...
@@ -47,9 +48,12 @@ export const registerStep0Schema: ISchema = {
...
@@ -47,9 +48,12 @@ export const registerStep0Schema: ISchema = {
},
},
password
:
{
password
:
{
type
:
'string'
,
type
:
'string'
,
required
:
true
,
"x-rules"
:
[
"x-rules"
:
[
{
{
required
:
true
,
message
:
'请输入密码'
},
{
pattern
:
PATTERN_MAPS
.
password
,
pattern
:
PATTERN_MAPS
.
password
,
message
:
'请输入正确的密码'
message
:
'请输入正确的密码'
}
}
...
@@ -62,9 +66,12 @@ export const registerStep0Schema: ISchema = {
...
@@ -62,9 +66,12 @@ export const registerStep0Schema: ISchema = {
},
},
confirmPassword
:
{
confirmPassword
:
{
type
:
'string'
,
type
:
'string'
,
required
:
true
,
"x-rules"
:
[
"x-rules"
:
[
{
{
required
:
true
,
message
:
'请输入密码'
},
{
pattern
:
PATTERN_MAPS
.
password
,
pattern
:
PATTERN_MAPS
.
password
,
message
:
'请输入正确的密码'
message
:
'请输入正确的密码'
}
}
...
@@ -178,10 +185,14 @@ export const forgetPwdSchema: ISchema = {
...
@@ -178,10 +185,14 @@ export const forgetPwdSchema: ISchema = {
full
:
true
full
:
true
},
},
properties
:
{
properties
:
{
email
:
{
account
:
{
type
:
'string'
,
type
:
'string'
,
"x-rules"
:
[
"x-rules"
:
[
{
{
required
:
true
,
message
:
'请输入正确的邮箱/手机号'
},
{
pattern
:
PATTERN_MAPS
.
phoneAndEmail
,
pattern
:
PATTERN_MAPS
.
phoneAndEmail
,
message
:
'请输入正确的邮箱/手机号'
message
:
'请输入正确的邮箱/手机号'
},
},
...
@@ -202,8 +213,78 @@ export const forgetPwdSchema: ISchema = {
...
@@ -202,8 +213,78 @@ export const forgetPwdSchema: ISchema = {
}
}
],
],
"x-component-props"
:
{
"x-component-props"
:
{
size
:
'large'
,
smsFn
:
(
form
,
setLoading
,
callback
)
=>
{
form
.
validate
(
'account'
).
then
(()
=>
{
const
values
=
form
.
getFieldValue
(
'account'
)
const
isPhone
=
PATTERN_MAPS
.
phone
.
test
(
values
)
const
isEmail
=
PATTERN_MAPS
.
email
.
test
(
values
)
if
(
isPhone
)
{
setLoading
(
true
)
PublicApi
.
postMemberRegisterPswSms
({
countryCode
:
'+86'
,
phone
:
values
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
callback
()
}
})
}
if
(
isEmail
)
{
setLoading
(
true
)
PublicApi
.
postMemberRegisterPswEmail
({
email
:
values
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
callback
()
}
})
}
})
}
}
},
password
:
{
type
:
'string'
,
"x-rules"
:
[
{
required
:
true
,
message
:
'请输入密码'
},
{
pattern
:
PATTERN_MAPS
.
password
,
message
:
'请输入正确的密码'
}
],
"x-component-props"
:
{
type
:
'password'
,
placeholder
:
'请设置你的新密码'
,
size
:
'large'
size
:
'large'
}
}
},
confirmPassword
:
{
type
:
'string'
,
"x-rules"
:
[
{
required
:
true
,
message
:
'请输入密码'
},
{
pattern
:
PATTERN_MAPS
.
password
,
message
:
'请输入正确的密码'
}
],
"x-component-props"
:
{
type
:
'password'
,
placeholder
:
'请再次输入密码'
,
size
:
'large'
,
}
},
submit
:
{
type
:
'string'
,
"x-component"
:
'Submit'
}
}
}
}
}
}
...
...
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