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
9225579f
Commit
9225579f
authored
Sep 26, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
route-bug
parent
90fabc1e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
72 deletions
+71
-72
src/App.js
+42
-50
src/components/my/edit.js
+1
-1
src/components/passport/index.js
+26
-19
src/router/router-config.js
+2
-2
No files found.
src/App.js
View file @
9225579f
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
}
from
"@/store/userAction"
import
{
withRouter
}
from
'react-router-dom'
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
import
{
compose
}
from
'redux'
import
{
getParam
,
http
,
browser
}
from
"@/utils"
;
import
{
getParam
,
http
,
browser
}
from
"@/utils"
import
{
Toast
}
from
"antd-mobile"
;
import
{
Toast
}
from
"antd-mobile"
import
{
addDays
}
from
'date-fns'
import
{
addDays
}
from
'date-fns'
...
@@ -16,39 +16,24 @@ mock()*/
...
@@ -16,39 +16,24 @@ mock()*/
// 默认样式
// 默认样式
import
'./assets/css/index.scss'
;
import
'./assets/css/index.scss'
// iconfont
// iconfont
import
'./assets/font/iconfont.css'
;
import
'./assets/font/iconfont.css'
class
App
extends
Component
{
class
App
extends
Component
{
previousLocation
=
{
previousLocation
=
{
pathname
:
'/'
,
search
:
''
,
hash
:
''
}
...{
state
:
{
from
:
{
pathname
:
this
.
props
.
location
.
pathname
,
search
:
this
.
props
.
location
.
search
,
hash
:
this
.
props
.
location
.
hash
}
}
},
...
this
.
props
.
location
}
records
=
[]
records
=
[]
pathnameBlacklist
=
[
'/country'
,
'/passport'
]
firstLoad
=
true
firstLoad
=
true
componentDidMount
()
{
componentDidMount
()
{
// 友盟统计
this
.
umengStatistic
()
const
script
=
document
.
createElement
(
'script'
);
script
.
src
=
'https://s22.cnzz.com/z_stat.php?id=1265696973&web_id=1265696973'
;
script
.
language
=
'JavaScript'
;
document
.
body
.
appendChild
(
script
);
this
.
setNavigationRecord
(
this
.
props
.
location
,
this
.
props
.
history
.
action
)
//平台信息
//平台信息
...
@@ -60,21 +45,34 @@ class App extends Component {
...
@@ -60,21 +45,34 @@ class App extends Component {
this
.
getUser
()
this
.
getUser
()
this
.
utm
()
this
.
utm
()
const
routeMatchRule
=
/binding-tel|forgot|set-password/
const
{
history
}
=
this
.
props
const
{
history
}
=
this
.
props
this
.
setNavigationRecord
(
this
.
props
.
location
,
this
.
props
.
history
.
action
)
this
.
setPreviousLocation
()
history
.
listen
((
location
,
action
)
=>
{
history
.
listen
((
location
,
action
)
=>
{
this
.
firstLoad
=
false
this
.
firstLoad
=
false
this
.
setNavigationRecord
(
location
,
action
)
this
.
setNavigationRecord
(
location
,
action
)
this
.
utm
()
this
.
utm
()
if
(
cookie
.
get
(
'uid'
)
&&
this
.
props
.
user
.
hasError
)
{
if
(
cookie
.
get
(
'uid'
)
&&
this
.
props
.
user
.
hasError
)
{
this
.
getUser
()
this
.
getUser
()
}
}
const
{
pathname
}
=
location
const
{
pathname
,
state
}
=
location
if
(
pathname
.
startsWith
(
'/passport'
))
{
if
(
pathname
.
startsWith
(
'/passport'
))
{
if
(
routeMatchRule
.
test
(
pathname
))
{
location
.
state
=
{
return
...
state
,
...{
from
:
{
pathname
:
this
.
previousLocation
.
pathname
,
search
:
this
.
previousLocation
.
search
,
hash
:
this
.
previousLocation
.
hash
}
}
}
}
location
.
state
=
{...
location
.
state
,
...{
from
:
this
.
previousLocation
}};
}
else
{
}
else
{
this
.
removeShareCodeCookie
()
this
.
removeShareCodeCookie
()
}
}
...
@@ -83,6 +81,14 @@ class App extends Component {
...
@@ -83,6 +81,14 @@ class App extends Component {
}
}
umengStatistic
=
()
=>
{
// 友盟统计
const
script
=
document
.
createElement
(
'script'
)
script
.
src
=
'https://s22.cnzz.com/z_stat.php?id=1265696973&web_id=1265696973'
script
.
language
=
'JavaScript'
document
.
body
.
appendChild
(
script
)
}
removeShareCodeCookie
=
()
=>
{
removeShareCodeCookie
=
()
=>
{
cookie
.
remove
(
'share_code'
,
{
path
:
'/'
,
domain
:
'.julyedu.com'
})
cookie
.
remove
(
'share_code'
,
{
path
:
'/'
,
domain
:
'.julyedu.com'
})
}
}
...
@@ -103,7 +109,7 @@ class App extends Component {
...
@@ -103,7 +109,7 @@ class App extends Component {
location
.
state
&&
location
.
state
.
records
location
.
state
&&
location
.
state
.
records
?
(
location
.
state
.
records
=
this
.
records
)
?
(
location
.
state
.
records
=
this
.
records
)
:
location
.
state
?
location
.
state
=
{...
location
.
state
,
records
:
this
.
records
}
:
location
.
state
?
location
.
state
=
{...
location
.
state
,
records
:
this
.
records
}
:
(
location
.
state
=
{
records
:
this
.
records
})
:
(
location
.
state
=
{
records
:
this
.
records
})
}
}
...
@@ -134,7 +140,7 @@ class App extends Component {
...
@@ -134,7 +140,7 @@ class App extends Component {
}
}
getUser
=
()
=>
{
getUser
=
()
=>
{
//获取用户信息
this
.
props
.
startFetchUser
()
this
.
props
.
startFetchUser
()
http
.
get
(
`
${
API
.
home
}
/m/user_info`
).
then
(
res
=>
{
http
.
get
(
`
${
API
.
home
}
/m/user_info`
).
then
(
res
=>
{
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
...
@@ -179,23 +185,9 @@ class App extends Component {
...
@@ -179,23 +185,9 @@ class App extends Component {
}
}
setPreviousLocation
=
()
=>
{
setPreviousLocation
=
()
=>
{
const
{
location
,
history
:
{
action
}}
=
this
.
props
const
{
location
}
=
this
.
props
let
isInBlacklist
=
this
.
pathnameBlacklist
.
some
(
item
=>
location
.
pathname
.
startsWith
(
item
))
if
(
location
.
pathname
.
startsWith
(
'/passport'
))
{
!
isInBlacklist
&&
(
this
.
previousLocation
=
location
)
let
index
=
this
.
records
.
findIndex
(
item
=>
item
.
pathname
.
startsWith
(
'/passport'
))
this
.
previousLocation
=
index
>
0
?
this
.
records
[
index
-
1
]
:
this
.
records
.
length
?
this
.
records
[
this
.
records
.
length
-
1
]
:
null
}
else
{
if
(
action
===
'POP'
||
action
===
'REPLACE'
)
{
let
index
=
this
.
records
.
findIndex
(
item
=>
item
.
pathname
.
startsWith
(
'/passport'
))
this
.
previousLocation
=
index
>
0
?
this
.
records
[
index
-
1
]
:
this
.
records
[
this
.
records
.
length
-
1
]
}
else
{
this
.
previousLocation
=
location
}
}
}
}
transformUser
=
res
=>
{
transformUser
=
res
=>
{
...
...
src/components/my/edit.js
View file @
9225579f
...
@@ -40,7 +40,7 @@ class MyEdut extends PureComponent {
...
@@ -40,7 +40,7 @@ class MyEdut extends PureComponent {
// 退出登录
// 退出登录
outLogin
=
()
=>
{
outLogin
=
()
=>
{
this
.
props
.
logout
()
this
.
props
.
logout
()
Toast
.
info
(
'已退出'
,
2
)
Toast
.
info
(
'已退出'
,
2
,
null
,
false
)
this
.
props
.
history
.
push
(
'/my'
)
this
.
props
.
history
.
push
(
'/my'
)
}
}
...
...
src/components/passport/index.js
View file @
9225579f
...
@@ -9,9 +9,9 @@ import ForgotPassword from './forgotPassword'
...
@@ -9,9 +9,9 @@ import ForgotPassword from './forgotPassword'
import
SetPassword
from
'./setPassword'
import
SetPassword
from
'./setPassword'
import
BindingTel
from
'./bindingTel'
import
BindingTel
from
'./bindingTel'
import
ForgotPasswordEmail
from
'./forgotPasswordEmail'
import
ForgotPasswordEmail
from
'./forgotPasswordEmail'
import
{
connect
}
from
"react-redux"
;
import
{
connect
}
from
"react-redux"
import
{
compose
}
from
"redux"
;
import
{
compose
}
from
"redux"
import
{
getParam
}
from
"@/utils"
;
import
{
getParam
}
from
"@/utils"
import
account
from
'./icons/account.png'
import
account
from
'./icons/account.png'
import
qq
from
'./icons/qq.png'
import
qq
from
'./icons/qq.png'
...
@@ -22,12 +22,13 @@ import wechat from './icons/wechat.png'
...
@@ -22,12 +22,13 @@ import wechat from './icons/wechat.png'
class
Passport
extends
Component
{
class
Passport
extends
Component
{
redirectURL
=
'/'
redirectURL
=
'/'
count
=
1
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
;
super
(
props
)
const
{
location
}
=
props
const
{
location
}
=
props
const
{
pathname
,
search
,
hash
}
=
location
const
{
pathname
,
search
,
hash
}
=
location
const
{
from
}
=
location
.
state
||
{
from
:
{
pathname
:
pathname
,
search
:
search
,
hash
:
hash
}
}
const
from
=
location
.
state
&&
location
.
state
.
from
||
{
pathname
:
pathname
,
search
:
search
,
hash
:
hash
}
this
.
redirectURL
=
window
.
location
.
origin
+
from
.
pathname
+
from
.
search
+
from
.
hash
this
.
redirectURL
=
window
.
location
.
origin
+
from
.
pathname
+
from
.
search
+
from
.
hash
this
.
state
=
{
this
.
state
=
{
loginWays
:
[
loginWays
:
[
...
@@ -60,27 +61,33 @@ class Passport extends Component {
...
@@ -60,27 +61,33 @@ class Passport extends Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
routeWhenUserLoggedIn
()
const
{
history
}
=
this
.
props
if
(
!
window
.
passportHistoryListener
)
{
this
.
unlisten
=
history
.
listen
((
location
,
action
)
=>
{
window
.
passportHistoryListener
=
this
.
unlisten
location
.
pathname
!==
'/country'
&&
!
location
.
pathname
.
startsWith
(
'/passport'
)
&&
this
.
unlisten
()
if
(
action
===
'PUSH'
)
{
this
.
count
++
}
else
if
(
action
===
'POP'
)
{
this
.
count
--
}
})
}
}
}
componentDidUpdate
()
{
componentDidUpdate
()
{
this
.
routeWhenUserLoggedIn
()
this
.
routeWhenUserLoggedIn
()
}
}
routeWhenUserLoggedIn
=
()
=>
{
routeWhenUserLoggedIn
=
()
=>
{
let
{
history
,
location
}
=
this
.
props
let
{
hasError
}
=
this
.
props
.
user
let
{
data
}
=
this
.
props
.
user
if
(
!
hasError
)
{
if
(
data
&&
Object
.
values
(
data
).
filter
(
item
=>
!!
item
).
length
)
{
const
redirectURI
=
getParam
(
'redirect'
)
if
(
history
.
action
===
'POP'
&&
history
.
length
<=
3
)
{
redirectURI
?
(
window
.
location
.
href
=
redirectURI
)
:
this
.
props
.
history
.
go
(
-
this
.
count
)
history
.
push
(
'/'
)
}
else
{
if
(
!
(
this
.
props
.
user
&&
this
.
props
.
user
.
stage
))
{
const
from
=
location
.
state
&&
location
.
state
.
from
||
{
pathname
:
'/'
,
search
:
''
};
const
redirectURI
=
getParam
(
'redirect'
)
redirectURI
?
(
window
.
location
.
href
=
redirectURI
)
:
history
.
replace
(
from
);
}
}
}
}
}
}
...
...
src/router/router-config.js
View file @
9225579f
...
@@ -29,8 +29,8 @@ const MyEdit = loadable(() => import(/* webpackChunkName: 'MyEdit'*/'@/component
...
@@ -29,8 +29,8 @@ const MyEdit = loadable(() => import(/* webpackChunkName: 'MyEdit'*/'@/component
const
Classify
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/classify'
))
const
Classify
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/classify'
))
const
CampTest
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/video/camp/campTest'
))
const
CampTest
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/video/camp/campTest'
))
const
CampResolve
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/video/camp/campResolve'
))
const
CampResolve
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/video/camp/campResolve'
))
const
ShareCourse
=
loadable
(()
=>
import
(
'@/components/ShareCourse/index'
))
const
ShareCourse
=
loadable
(()
=>
import
(
/* webpackChunkName: 'ShareCourse'*/
'@/components/ShareCourse/index'
))
const
Country
=
loadable
(()
=>
import
(
'@/components/country/index'
))
const
Country
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Country' */
'@/components/country/index'
))
export
default
[
export
default
[
{
{
path
:
'/'
,
path
:
'/'
,
...
...
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