Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
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
baiguangyao
mr-julyedu
Commits
4279404f
Commit
4279404f
authored
Jul 20, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
无痕验证
parent
b8bf2733
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
47 deletions
+95
-47
src/App.js
+29
-16
src/components/activity/2020-717/invitation/index.js
+17
-13
src/store/no-trace-validation/reducer.js
+22
-0
src/store/userAction.js
+21
-14
src/store/userReducer.js
+6
-4
No files found.
src/App.js
View file @
4279404f
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
Routes
from
'./router'
import
Routes
from
'./router'
import
cookie
from
'js-cookie'
import
cookie
from
'js-cookie'
import
{
connect
}
from
'react-redux'
import
{
connect
}
from
'react-redux'
import
{
setCurrentUser
,
startFetchUser
}
from
'@/store/userAction'
import
{
setCurrentUser
,
startFetchUser
,
endFetchUser
}
from
'@/store/userAction'
import
{
import
{
updateCaptchaState
,
updateCaptchaState
,
closeCaptchaModal
,
closeCaptchaModal
,
showCaptchaModal
,
showCaptchaModal
,
validationPassed
,
validationPassed
,
startFetchValidationState
,
endFetchValidationState
,
}
from
'@/store/no-trace-validation/reducer'
}
from
'@/store/no-trace-validation/reducer'
import
{
initialState
}
from
'@/store/userReducer'
import
{
initialState
}
from
'@/store/userReducer'
import
{
withRouter
}
from
'react-router-dom'
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
import
{
compose
}
from
'redux'
import
{
getParam
,
http
,
browser
,
loadScript
,
getTimestamp
}
from
'@/utils'
import
{
getParam
,
http
,
browser
,
loadScript
,
getTimestamp
}
from
'@/utils'
import
{
Toast
}
from
'antd-mobile'
import
{
Toast
}
from
'antd-mobile'
import
{
addDays
}
from
'date-fns'
import
{
addDays
}
from
'date-fns'
import
stringify
from
'json-stringify-safe'
import
stringify
from
'json-stringify-safe'
//拦截ajax请求,返回mock数据
//拦截ajax请求,返回mock数据
...
@@ -189,7 +191,6 @@ class App extends Component {
...
@@ -189,7 +191,6 @@ class App extends Component {
}
:
(
location
.
state
=
{
records
:
this
.
records
})
}
:
(
location
.
state
=
{
records
:
this
.
records
})
}
}
utm
=
()
=>
{
utm
=
()
=>
{
// utm统计 m站全站统计广告投放、以及统计详情页浏览
// utm统计 m站全站统计广告投放、以及统计详情页浏览
let
zhihu_cb
=
getParam
(
'cb'
)
let
zhihu_cb
=
getParam
(
'cb'
)
...
@@ -214,19 +215,25 @@ class App extends Component {
...
@@ -214,19 +215,25 @@ class App extends Component {
let
code
=
getParam
(
'code'
)
let
code
=
getParam
(
'code'
)
let
oid
=
getParam
(
'oid'
)
let
oid
=
getParam
(
'oid'
)
if
(
code
&&
!
oid
)
{
if
(
code
&&
!
oid
)
{
this
.
props
.
startFetchValidationState
()
http
.
get
(
`
${
API
[
'passport-api'
]}
/m/wx_loginInfo/code/
${
code
}
?redirect=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
)
http
.
get
(
`
${
API
[
'passport-api'
]}
/m/wx_loginInfo/code/
${
code
}
?redirect=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
)
.
then
(
res
=>
{
.
then
(
res
=>
{
let
data
=
res
.
data
let
data
=
res
.
data
if
(
data
.
errno
==
200
)
{
if
(
data
.
errno
==
200
)
{
if
(
data
.
data
.
is_check
)
{
if
(
data
.
data
.
is_check
)
{
this
.
props
.
updateCaptchaState
({
this
.
props
.
updateCaptchaState
({
isNeedValidation
:
true
isNeedValidation
:
true
,
})
})
this
.
props
.
startFetchValidationState
()
this
.
setState
({
this
.
setState
({
mkey
:
data
.
data
.
mkey
,
mkey
:
data
.
data
.
mkey
,
});
});
this
.
setupNoTraceValidate
()
this
.
setupNoTraceValidate
()
}
else
{
}
else
{
this
.
props
.
updateCaptchaState
({
isNeedValidation
:
false
,
isFetching
:
false
})
if
(
data
.
data
[
'is_bind_mobile'
])
{
if
(
data
.
data
[
'is_bind_mobile'
])
{
window
.
location
.
assign
(
data
.
data
.
url
)
window
.
location
.
assign
(
data
.
data
.
url
)
}
else
{
}
else
{
...
@@ -234,6 +241,10 @@ class App extends Component {
...
@@ -234,6 +241,10 @@ class App extends Component {
}
}
}
}
}
else
{
}
else
{
this
.
props
.
updateCaptchaState
({
isNeedValidation
:
false
,
isFetching
:
false
})
Toast
.
info
(
data
.
msg
)
Toast
.
info
(
data
.
msg
)
this
.
props
.
setCurrentUser
(
initialState
)
this
.
props
.
setCurrentUser
(
initialState
)
}
}
...
@@ -304,14 +315,11 @@ class App extends Component {
...
@@ -304,14 +315,11 @@ class App extends Component {
}).
then
(
res
=>
{
}).
then
(
res
=>
{
const
{
errno
,
msg
,
data
}
=
res
.
data
const
{
errno
,
msg
,
data
}
=
res
.
data
if
(
errno
===
200
)
{
if
(
errno
===
200
)
{
this
.
props
.
validationPassed
()
this
.
props
.
validationPassed
()
this
.
handleLoginResponse
(
data
)
this
.
handleLoginResponse
(
data
)
}
else
if
(
errno
===
5002
)
{
}
else
if
(
errno
===
5002
)
{
this
.
props
.
updateCaptchaState
({
this
.
props
.
showCaptchaModal
()
isShowCaptcha
:
true
this
.
props
.
endFetchValidationState
()
})
typeof
nvcReset
===
'function'
&&
nvcReset
()
typeof
nvcReset
===
'function'
&&
nvcReset
()
typeof
getNC
===
'function'
&&
getNC
().
then
(()
=>
{
typeof
getNC
===
'function'
&&
getNC
().
then
(()
=>
{
_nvc_nc
.
reset
()
_nvc_nc
.
reset
()
...
@@ -319,6 +327,8 @@ class App extends Component {
...
@@ -319,6 +327,8 @@ class App extends Component {
}
else
{
}
else
{
Toast
.
info
(
msg
)
Toast
.
info
(
msg
)
}
}
this
.
props
.
endFetchUser
()
this
.
props
.
endFetchValidationState
()
})
})
}
}
...
@@ -459,6 +469,9 @@ export default compose(
...
@@ -459,6 +469,9 @@ export default compose(
closeCaptchaModal
,
closeCaptchaModal
,
showCaptchaModal
,
showCaptchaModal
,
validationPassed
,
validationPassed
,
endFetchUser
,
startFetchValidationState
,
endFetchValidationState
,
}),
}),
withRouter
,
withRouter
,
)(
App
)
)(
App
)
src/components/activity/2020-717/invitation/index.js
View file @
4279404f
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
'./index.scss'
import
'./index.scss'
import
{
connect
}
from
"react-redux"
;
import
{
connect
}
from
"react-redux"
;
import
{
compose
}
from
"redux"
;
import
{
compose
}
from
"redux"
;
import
{
HeaderBar
}
from
"@common/index"
import
{
HeaderBar
}
from
"@common/index"
import
{
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
import
{
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
import
{
Toast
}
from
"antd-mobile"
;
import
{
Toast
}
from
"antd-mobile"
;
import
{
CopyToClipboard
}
from
"react-copy-to-clipboard"
;
import
{
CopyToClipboard
}
from
"react-copy-to-clipboard"
;
import
{
Link
}
from
'react-router-dom'
import
{
Link
}
from
'react-router-dom'
import
storage
from
'store2'
import
storage
from
'store2'
import
{
CaptchaAli
}
from
"@common/index"
import
{
CaptchaAli
}
from
"@common/index"
import
{
showCaptchaModal
}
from
"@/store/no-trace-validation/reducer"
;
import
{
showCaptchaModal
}
from
"@/store/no-trace-validation/reducer"
;
class
Invitation
extends
Component
{
class
Invitation
extends
Component
{
...
@@ -96,11 +96,15 @@ class Invitation extends Component {
...
@@ -96,11 +96,15 @@ class Invitation extends Component {
joinTeam
=
data
=>
{
joinTeam
=
data
=>
{
const
{
user
,
history
,
noTraceValidation
,
showCaptchaModal
}
=
this
.
props
const
{
user
,
history
,
noTraceValidation
,
showCaptchaModal
}
=
this
.
props
if
(
user
.
isFetching
)
{
if
(
noTraceValidation
.
isFetching
)
{
return
return
}
}
if
(
noTraceValidation
.
isNeedValidation
&&
!
noTraceValidation
.
isShowCaptcha
)
{
if
(
noTraceValidation
.
isNeedValidation
)
{
showCaptchaModal
()
!
noTraceValidation
.
isShowCaptcha
&&
showCaptchaModal
()
return
}
if
(
user
.
isFetching
)
{
return
return
}
}
...
...
src/store/no-trace-validation/reducer.js
View file @
4279404f
...
@@ -27,9 +27,20 @@ export const validationPassed = () => {
...
@@ -27,9 +27,20 @@ export const validationPassed = () => {
}
}
}
}
const
START_FETCHING
=
'START_FETCHING'
export
const
startFetchValidationState
=
()
=>
({
type
:
START_FETCHING
,
})
const
END_FETCHING
=
'END_FETCHING'
export
const
endFetchValidationState
=
()
=>
({
type
:
END_FETCHING
,
})
const
initialState
=
{
const
initialState
=
{
isShowCaptcha
:
false
,
isShowCaptcha
:
false
,
isNeedValidation
:
false
,
isNeedValidation
:
false
,
isFetching
:
false
,
}
}
export
default
function
noTraceValidation
(
state
=
initialState
,
action
)
{
export
default
function
noTraceValidation
(
state
=
initialState
,
action
)
{
...
@@ -49,10 +60,21 @@ export default function noTraceValidation(state = initialState, action) {
...
@@ -49,10 +60,21 @@ export default function noTraceValidation(state = initialState, action) {
...
state
,
...
state
,
...{
isShowCaptcha
:
false
},
...{
isShowCaptcha
:
false
},
}
}
case
START_FETCHING
:
return
{
...
state
,
isFetching
:
true
,
}
case
VALIDATION_PASSED
:
case
VALIDATION_PASSED
:
return
{
return
{
isNeedValidation
:
false
,
isNeedValidation
:
false
,
isShowCaptcha
:
false
,
isShowCaptcha
:
false
,
isFetching
:
false
,
}
case
END_FETCHING
:
return
{
...
state
,
isFetching
:
false
,
}
}
default
:
default
:
return
state
return
state
...
...
src/store/userAction.js
View file @
4279404f
import
{
http
}
from
'@/utils'
;
import
{
http
}
from
'@/utils'
;
import
{
encrypt
}
from
'@/components/passport/encryption'
;
import
{
encrypt
}
from
'@/components/passport/encryption'
;
import
jsCookie
from
'js-cookie'
import
jsCookie
from
'js-cookie'
...
@@ -8,7 +8,7 @@ const accountLogin = user => dispatch => {
...
@@ -8,7 +8,7 @@ const accountLogin = user => dispatch => {
user_name
:
user
.
username
,
user_name
:
user
.
username
,
password
:
encrypt
(
user
.
password
),
password
:
encrypt
(
user
.
password
),
is_encrypt
:
1
,
is_encrypt
:
1
,
redirect
:
encodeURIComponent
(
user
.
redirect
)
redirect
:
encodeURIComponent
(
user
.
redirect
),
}).
then
(
res
=>
{
}).
then
(
res
=>
{
return
storeUser
(
res
,
dispatch
)
return
storeUser
(
res
,
dispatch
)
})
})
...
@@ -27,16 +27,16 @@ const studentLogin = params => dispatch => {
...
@@ -27,16 +27,16 @@ const studentLogin = params => dispatch => {
redirect
:
encodeURIComponent
(
params
.
redirect
),
redirect
:
encodeURIComponent
(
params
.
redirect
),
type
:
1
,
type
:
1
,
}).
then
(
res
=>
{
}).
then
(
res
=>
{
const
{
errno
,
data
}
=
res
.
data
;
const
{
errno
,
data
}
=
res
.
data
;
let
result
=
{};
let
result
=
{};
if
(
errno
===
0
)
{
if
(
errno
===
0
)
{
result
=
{
result
=
{
data
:
{
data
:
{
errno
:
200
,
errno
:
200
,
data
,
data
,
}
},
};
};
}
else
{
}
else
{
result
=
res
;
result
=
res
;
}
}
return
storeUser
(
result
,
dispatch
);
return
storeUser
(
result
,
dispatch
);
...
@@ -46,7 +46,7 @@ const studentLogin = params => dispatch => {
...
@@ -46,7 +46,7 @@ const studentLogin = params => dispatch => {
const
quickLogin
=
user
=>
dispatch
=>
{
const
quickLogin
=
user
=>
dispatch
=>
{
return
http
.
post
(
`
${
API
[
'passport-api'
]}
/m/login/quickLogin`
,
{
return
http
.
post
(
`
${
API
[
'passport-api'
]}
/m/login/quickLogin`
,
{
...
user
,
...
user
,
plat
:
5
plat
:
5
,
}).
then
(
res
=>
{
}).
then
(
res
=>
{
return
storeUser
(
res
,
dispatch
)
return
storeUser
(
res
,
dispatch
)
})
})
...
@@ -56,18 +56,18 @@ const storeUser = (res, dispatch) => {
...
@@ -56,18 +56,18 @@ const storeUser = (res, dispatch) => {
const
data
=
res
.
data
const
data
=
res
.
data
let
payload
let
payload
if
(
data
.
errno
===
200
)
{
if
(
data
.
errno
===
200
)
{
const
{
user_name
:
username
,
avatar_file
:
avatar
,
is_vip
:
isVIP
,
...
rest
}
=
data
.
data
.
user_info
const
{
user_name
:
username
,
avatar_file
:
avatar
,
is_vip
:
isVIP
,
...
rest
}
=
data
.
data
.
user_info
payload
=
{
payload
=
{
hasError
:
false
,
hasError
:
false
,
msg
:
data
.
msg
,
msg
:
data
.
msg
,
data
:
{
username
,
avatar
,
isVIP
,
...
rest
}
data
:
{
username
,
avatar
,
isVIP
,
...
rest
},
}
}
}
else
{
}
else
{
payload
=
{
payload
=
{
hasError
:
true
,
hasError
:
true
,
msg
:
data
.
msg
,
msg
:
data
.
msg
,
data
:
{},
data
:
{},
code
:
data
.
errno
code
:
data
.
errno
,
}
}
}
}
dispatch
(
setCurrentUser
(
payload
))
dispatch
(
setCurrentUser
(
payload
))
...
@@ -79,7 +79,7 @@ const storeUser = (res, dispatch) => {
...
@@ -79,7 +79,7 @@ const storeUser = (res, dispatch) => {
const
SET_CURRENT_USER
=
'SET_CURRENT_USER'
const
SET_CURRENT_USER
=
'SET_CURRENT_USER'
const
setCurrentUser
=
payload
=>
({
const
setCurrentUser
=
payload
=>
({
type
:
SET_CURRENT_USER
,
type
:
SET_CURRENT_USER
,
payload
:
{...
payload
,
isFetching
:
false
}
payload
:
{...
payload
,
isFetching
:
false
},
})
})
...
@@ -94,12 +94,17 @@ const logout = () => dispatch => {
...
@@ -94,12 +94,17 @@ const logout = () => dispatch => {
const
UPDATE_USER
=
'UPDATE_USER'
const
UPDATE_USER
=
'UPDATE_USER'
const
updateUser
=
payload
=>
({
const
updateUser
=
payload
=>
({
type
:
UPDATE_USER
,
type
:
UPDATE_USER
,
payload
payload
,
})
})
const
START_FETCH_USER
=
'START_FETCH_USER'
const
START_FETCH_USER
=
'START_FETCH_USER'
const
startFetchUser
=
()
=>
({
const
startFetchUser
=
()
=>
({
type
:
START_FETCH_USER
type
:
START_FETCH_USER
,
})
const
END_FETCH_USER
=
'END_FETCH_USER'
const
endFetchUser
=
()
=>
({
type
:
END_FETCH_USER
,
})
})
...
@@ -114,4 +119,6 @@ export {
...
@@ -114,4 +119,6 @@ export {
updateUser
,
updateUser
,
START_FETCH_USER
,
START_FETCH_USER
,
startFetchUser
,
startFetchUser
,
END_FETCH_USER
,
endFetchUser
,
}
}
src/store/userReducer.js
View file @
4279404f
import
{
SET_CURRENT_USER
,
UPDATE_USER
,
START_FETCH_USER
}
from
'@/store/userAction'
;
import
{
SET_CURRENT_USER
,
UPDATE_USER
,
START_FETCH_USER
,
END_FETCH_USER
}
from
'@/store/userAction'
;
import
{
merge
}
from
'lodash'
import
{
merge
}
from
'lodash'
const
notLoggedIn
=
4030
const
notLoggedIn
=
4030
...
@@ -13,9 +13,9 @@ export const initialState = {
...
@@ -13,9 +13,9 @@ export const initialState = {
isVip
:
false
,
isVip
:
false
,
token
:
''
,
token
:
''
,
email
:
''
,
email
:
''
,
uid
:
''
uid
:
''
,
},
},
isFetching
:
true
isFetching
:
true
,
}
}
...
@@ -27,6 +27,8 @@ export default function (state = initialState, action) {
...
@@ -27,6 +27,8 @@ export default function (state = initialState, action) {
return
merge
({},
state
,
action
.
payload
)
return
merge
({},
state
,
action
.
payload
)
case
START_FETCH_USER
:
case
START_FETCH_USER
:
return
{...
state
,
isFetching
:
true
}
return
{...
state
,
isFetching
:
true
}
case
END_FETCH_USER
:
return
{...
state
,
isFetching
:
false
}
default
:
default
:
return
state
return
state
}
}
...
...
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