Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
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
ReactWeb5
CivWeb
Commits
0e5eecd5
Commit
0e5eecd5
authored
Dec 17, 2024
by
周宏民
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 验证码登录
parent
464eb3b2
Pipeline
#94688
passed with stages
Changes
7
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
16 deletions
+67
-16
reducer.js
src/containers/App/store/reducer.js
+5
-0
LoginItem.js
src/pages/user/login/components/Login/LoginItem.js
+53
-7
index.js
src/pages/user/login/components/Login/index.js
+4
-1
index.less
src/pages/user/login/components/Login/index.less
+1
-0
useAccount.js
src/pages/user/login/js/useAccount.js
+2
-7
login.js
src/pages/user/login/login.js
+2
-1
baseLogin.js
src/pages/user/login/template/baseLogin.js
+0
-0
No files found.
src/containers/App/store/reducer.js
View file @
0e5eecd5
...
@@ -92,7 +92,12 @@ const appReducer = (state = initialState, action) => {
...
@@ -92,7 +92,12 @@ const appReducer = (state = initialState, action) => {
window
.
__INITIAL_STATE__
.
menu
=
'banner-left'
;
window
.
__INITIAL_STATE__
.
menu
=
'banner-left'
;
const
temp
=
AppConfig
(
window
.
__INITIAL_STATE__
);
const
temp
=
AppConfig
(
window
.
__INITIAL_STATE__
);
temp
.
displayMode
=
window
.
__INITIAL_STATE__
?.
displayMode
||
''
;
temp
.
displayMode
=
window
.
__INITIAL_STATE__
?.
displayMode
||
''
;
// 验证码开启 系统配置表里配置
temp
.
isVerification
=
action
.
data
.
isVerification
||
''
;
temp
.
isVerification
=
action
.
data
.
isVerification
||
''
;
// 验证码配置 站点设置里配置 只针对该站点
temp
.
isVerificationCode
=
action
.
data
.
VerificationConfig
?.
IsVerificationCode
||
false
;
temp
.
verificationCodeTimeOut
=
action
.
data
.
VerificationConfig
?.
VerificationCodeTimeOut
||
1
;
temp
.
verificationCodeType
=
action
.
data
.
VerificationConfig
?.
VerificationCodeType
||
''
;
window
.
globalConfig
=
temp
;
window
.
globalConfig
=
temp
;
// eslint-disable-next-line no-undef
// eslint-disable-next-line no-undef
...
...
src/pages/user/login/components/Login/LoginItem.js
View file @
0e5eecd5
...
@@ -2,7 +2,7 @@ import 'kit_logger';
...
@@ -2,7 +2,7 @@ import 'kit_logger';
import
React
,
{
useCallback
,
useEffect
,
useState
,
useRef
}
from
'react'
;
import
React
,
{
useCallback
,
useEffect
,
useState
,
useRef
}
from
'react'
;
import
{
FieldNumberOutlined
,
ReloadOutlined
}
from
'@ant-design/icons'
;
import
{
FieldNumberOutlined
,
ReloadOutlined
}
from
'@ant-design/icons'
;
import
{
Button
,
Form
,
Input
,
message
}
from
'antd'
;
import
{
Button
,
Form
,
Input
,
message
,
Space
}
from
'antd'
;
import
omit
from
'omit.js'
;
import
omit
from
'omit.js'
;
import
{
useIntl
}
from
'@wisdom-utils/components'
;
import
{
useIntl
}
from
'@wisdom-utils/components'
;
...
@@ -38,6 +38,8 @@ const ValidateCode = props => {
...
@@ -38,6 +38,8 @@ const ValidateCode = props => {
const
codeUrl
=
window
?.
globalConfig
?.
hasGateWay
const
codeUrl
=
window
?.
globalConfig
?.
hasGateWay
?
'/PandaCore/Identity/GetVerificationCode'
?
'/PandaCore/Identity/GetVerificationCode'
:
'/PandaCore/GCK/BussinessAuth/GetVerificationCode'
;
:
'/PandaCore/GCK/BussinessAuth/GetVerificationCode'
;
const
verificationCodeTimeOut
=
(
window
?.
globalConfig
?.
verificationCodeTimeOut
||
1
)
*
60
;
const
onTimeOver
=
()
=>
{
const
onTimeOver
=
()
=>
{
console
.
log
(
'超时了'
);
console
.
log
(
'超时了'
);
setIsOver
(
true
);
setIsOver
(
true
);
...
@@ -75,14 +77,13 @@ const ValidateCode = props => {
...
@@ -75,14 +77,13 @@ const ValidateCode = props => {
},
[]);
},
[]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
isOver
)
{
if
(
!
isOver
)
{
console
.
log
(
'开始计时'
);
if
(
timer
.
current
)
{
if
(
timer
.
current
)
{
clearInterval
(
timer
.
current
);
clearInterval
(
timer
.
current
);
timer
.
current
=
null
;
timer
.
current
=
null
;
}
}
timer
.
current
=
setTimeout
(()
=>
{
timer
.
current
=
setTimeout
(()
=>
{
onTimeOver
();
onTimeOver
();
},
60
*
1000
);
},
verificationCodeTimeOut
*
1000
);
}
}
return
()
=>
{
return
()
=>
{
if
(
timer
.
current
)
{
if
(
timer
.
current
)
{
...
@@ -119,7 +120,8 @@ const ValidateCode = props => {
...
@@ -119,7 +120,8 @@ const ValidateCode = props => {
};
};
const
LoginItem
=
props
=>
{
const
LoginItem
=
props
=>
{
const
[
count
,
setCount
]
=
useState
(
props
.
countDown
||
0
);
const
{
isVerificationCode
,
verificationCodeType
,
verificationCodeTimeOut
}
=
window
.
globalConfig
;
const
[
count
,
setCount
]
=
useState
(
props
.
countDown
||
(
verificationCodeTimeOut
||
1
)
*
60
);
const
[
timing
,
setTiming
]
=
useState
(
false
);
const
[
timing
,
setTiming
]
=
useState
(
false
);
const
[
ext
,
setExt
]
=
useState
(
''
);
const
[
ext
,
setExt
]
=
useState
(
''
);
const
intl
=
useIntl
();
const
intl
=
useIntl
();
...
@@ -136,7 +138,9 @@ const LoginItem = props => {
...
@@ -136,7 +138,9 @@ const LoginItem = props => {
tabUtil
,
tabUtil
,
...
restProps
...
restProps
}
=
props
;
}
=
props
;
if
(
isVerificationCode
&&
(
verificationCodeType
&&
verificationCodeType
!==
'图片验证码'
)
&&
customProps
?.
size
)
{
customProps
.
size
=
''
;
}
const
onGetCaptcha
=
useCallback
(
mobile
=>
{
const
onGetCaptcha
=
useCallback
(
mobile
=>
{
// eslint-disable-next-line no-undef
// eslint-disable-next-line no-undef
if
(
window
.
globalConfig
?.
hasGateWay
)
{
if
(
window
.
globalConfig
?.
hasGateWay
)
{
...
@@ -178,21 +182,23 @@ const LoginItem = props => {
...
@@ -178,21 +182,23 @@ const LoginItem = props => {
useEffect
(()
=>
{
useEffect
(()
=>
{
let
interval
=
0
;
let
interval
=
0
;
const
{
countDown
}
=
props
;
const
{
countDown
}
=
props
;
const
timeDown
=
countDown
||
(
verificationCodeTimeOut
||
1
)
*
60
;
if
(
timing
)
{
if
(
timing
)
{
interval
=
window
.
setInterval
(()
=>
{
interval
=
window
.
setInterval
(()
=>
{
setCount
(
preSecond
=>
{
setCount
(
preSecond
=>
{
if
(
preSecond
<=
1
)
{
if
(
preSecond
<=
1
)
{
setTiming
(
false
);
setTiming
(
false
);
clearInterval
(
interval
);
clearInterval
(
interval
);
return
countDown
||
60
;
return
timeDown
;
}
}
return
preSecond
-
1
;
return
preSecond
-
1
;
});
});
},
1000
);
},
1000
);
}
}
return
()
=>
clearInterval
(
interval
);
return
()
=>
clearInterval
(
interval
);
},
[
props
,
timing
]);
},
[
props
.
countDown
,
timing
]);
if
(
!
name
)
{
if
(
!
name
)
{
return
null
;
return
null
;
...
@@ -256,6 +262,46 @@ const LoginItem = props => {
...
@@ -256,6 +262,46 @@ const LoginItem = props => {
}
}
if
(
type
===
'Validate'
)
{
if
(
type
===
'Validate'
)
{
// 短信验证码
if
(
verificationCodeType
===
'阿里云短信验证码'
)
{
const
inputProps
=
omit
(
otherProps
,
[
'onGetCaptcha'
,
'countDown'
]);
return
(
<>
<
FormItem
name
=
"mobile"
rules
=
{
ItemMap
.
Mobile
.
rules
}
>
<
Input
{...
ItemMap
.
Mobile
.
props
}
size
=
"middle"
placeholder
=
"请输入手机号码"
/>
<
/FormItem
>
<
FormItem
shouldUpdate
style
=
{{
marginBottom
:
'0px'
}}
>
{({
getFieldValue
,
validateFields
})
=>
(
<
Space
align
=
"start"
>
<
FormItem
name
=
{
name
}
{...
options
}
rules
=
{
rules
}
>
<
Input
{...
customProps
}
{...
inputProps
}
/
>
<
/FormItem
>
<
Button
disabled
=
{
timing
}
className
=
{
styles
.
getCaptcha
}
style
=
{{
lineHeight
:
'32px'
,
width
:
'110px'
,
textAlign
:
'center'
}}
size
=
"large"
onClick
=
{()
=>
{
validateFields
([
'mobile'
])
.
then
(
values
=>
{
onGetCaptcha
(
values
.
mobile
);
})
.
catch
(
error
=>
{
Logger
.
log
(
error
);
});
}}
>
{
timing
?
`
${
intl
.
formatMessage
({
id
:
'pages.login.phoneLogin.sendCationCode'
})}
(
${
count
}
)`
:
intl
.
formatMessage
({
id
:
'pages.login.phoneLogin.getVerificationCode'
})}
<
/Button
>
<
/Space
>
)}
<
/FormItem
>
<
/
>
);
}
// 图形验证码
return
(
return
(
<
Form
.
Item
name
=
{
name
}
{...
options
}
>
<
Form
.
Item
name
=
{
name
}
{...
options
}
>
<
ValidateCode
{...
customProps
}
{...
otherProps
}
/
>
<
ValidateCode
{...
customProps
}
{...
otherProps
}
/
>
...
...
src/pages/user/login/components/Login/index.js
View file @
0e5eecd5
...
@@ -14,6 +14,7 @@ const Login = props => {
...
@@ -14,6 +14,7 @@ const Login = props => {
const
intl
=
useIntl
();
const
intl
=
useIntl
();
const
{
className
}
=
props
;
const
{
className
}
=
props
;
const
otherChildren
=
[];
const
otherChildren
=
[];
React
.
Children
.
forEach
(
props
.
children
,
child
=>
{
React
.
Children
.
forEach
(
props
.
children
,
child
=>
{
if
(
!
child
)
{
if
(
!
child
)
{
return
;
return
;
...
@@ -25,7 +26,9 @@ const Login = props => {
...
@@ -25,7 +26,9 @@ const Login = props => {
<
div
className
=
{
classNames
(
className
,
styles
.
login
)}
>
<
div
className
=
{
classNames
(
className
,
styles
.
login
)}
>
{
props
.
welcome
===
void
0
?
(
{
props
.
welcome
===
void
0
?
(
<
div
className
=
{
styles
.
desc
}
>
{
intl
.
formatMessage
({
id
:
'pages.login.welcome'
})}
<
/div
>
<
div
className
=
{
styles
.
desc
}
>
{
intl
.
formatMessage
({
id
:
'pages.login.welcome'
})}
<
/div
>
)
:
props
.
welcome
}
)
:
(
props
.
welcome
)}
<
Form
<
Form
form
=
{
props
.
from
}
form
=
{
props
.
from
}
onFinish
=
{
values
=>
{
onFinish
=
{
values
=>
{
...
...
src/pages/user/login/components/Login/index.less
View file @
0e5eecd5
...
@@ -113,6 +113,7 @@
...
@@ -113,6 +113,7 @@
width: 100%;
width: 100%;
height: 100%;
height: 100%;
object-fit: contain;
object-fit: contain;
margin: 0;
}
}
.validate_invalid {
.validate_invalid {
...
...
src/pages/user/login/js/useAccount.js
View file @
0e5eecd5
...
@@ -44,16 +44,11 @@ const useAccount = props => (
...
@@ -44,16 +44,11 @@ const useAccount = props => (
/
>
/
>
{
props
?.
isValidate
?
<
Validate
name
=
"validate"
/>
:
null
}
{
props
?.
isValidate
?
<
Validate
name
=
"validate"
/>
:
null
}
<
div
>
<
div
>
<
Checkbox
<
Checkbox
checked
=
{
props
.
autoLogin
}
onChange
=
{
e
=>
props
.
setAutoLogin
(
e
.
target
.
checked
)}
>
checked
=
{
props
.
autoLogin
}
onChange
=
{
e
=>
props
.
setAutoLogin
(
e
.
target
.
checked
)}
>
{
useIntl
().
formatMessage
({
id
:
'pages.login.rememberMe'
})}
{
useIntl
().
formatMessage
({
id
:
'pages.login.rememberMe'
})}
<
/Checkbox
>
<
/Checkbox
>
<
/div
>
<
/div
>
<
Submit
loading
=
{
props
.
submitting
}
>
<
Submit
loading
=
{
props
.
submitting
}
>
{
useIntl
().
formatMessage
({
id
:
'pages.login.submit'
})}
<
/Submit
>
{
useIntl
().
formatMessage
({
id
:
'pages.login.submit'
})}
<
/Submit
>
<
/LoginForm
>
<
/LoginForm
>
);
);
...
...
src/pages/user/login/login.js
View file @
0e5eecd5
...
@@ -1567,7 +1567,8 @@ class Login {
...
@@ -1567,7 +1567,8 @@ class Login {
loginHandlerValidate
(
user
,
pwd
,
userPhone
,
isRememberPWD
,
ref
,
validateCode
=
''
)
{
loginHandlerValidate
(
user
,
pwd
,
userPhone
,
isRememberPWD
,
ref
,
validateCode
=
''
)
{
const
self
=
this
;
const
self
=
this
;
if
((
this
.
globalConfig
?.
isVerification
||
0
)
*
1
===
1
)
// isVerification 取自系统配置表,isVerificationCode 取自 站点配置,isVerificationCode为1 会默认把 isVerificationCode改为true
if
((
this
.
globalConfig
?.
isVerification
||
0
)
*
1
===
1
||
this
.
globalConfig
.
isVerificationCode
)
return
self
.
loginValidate
(
user
,
pwd
,
userPhone
,
isRememberPWD
,
SERVICE_APP_LOGIN_MODE
.
password
,
validateCode
);
return
self
.
loginValidate
(
user
,
pwd
,
userPhone
,
isRememberPWD
,
SERVICE_APP_LOGIN_MODE
.
password
,
validateCode
);
if
(
user
&&
pwd
)
{
if
(
user
&&
pwd
)
{
if
(
self
.
loginFailed
&&
self
.
captchaObj
)
{
if
(
self
.
loginFailed
&&
self
.
captchaObj
)
{
...
...
src/pages/user/login/template/baseLogin.js
View file @
0e5eecd5
This diff is collapsed.
Click to expand it.
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