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
8b38e844
Commit
8b38e844
authored
Sep 27, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'passport-navigation'
# Conflicts: # src/App.js
parents
ac61580e
9ef5370b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
78 deletions
+81
-78
src/App.js
+52
-56
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 @
8b38e844
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
Routes
from
'./router'
import
cookie
from
'js-cookie'
import
{
connect
}
from
"react-redux"
;
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
;
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
import
{
getParam
,
http
,
browser
}
from
"@/utils"
;
import
{
Toast
}
from
"antd-mobile"
;
import
{
addDays
}
from
'date-fns'
import
{
connect
}
from
"react-redux"
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
import
{
getParam
,
http
,
browser
}
from
"@/utils"
import
{
Toast
}
from
"antd-mobile"
import
{
addDays
}
from
'date-fns'
//拦截ajax请求,返回mock数据
...
...
@@ -16,39 +16,26 @@ mock()*/
// 默认样式
import
'./assets/css/index.scss'
;
import
'./assets/css/index.scss'
// iconfont
import
'./assets/font/iconfont.css'
;
import
'./assets/font/iconfont.css'
class
App
extends
Component
{
previousLocation
=
{
...{
state
:
{
from
:
{
pathname
:
this
.
props
.
location
.
pathname
,
search
:
this
.
props
.
location
.
search
,
hash
:
this
.
props
.
location
.
hash
}
}
},
...
this
.
props
.
location
}
static
displayName
=
'App'
previousLocation
=
{
pathname
:
'/'
,
search
:
''
,
hash
:
''
}
records
=
[]
pathnameBlacklist
=
[
'/country'
,
'/passport'
]
firstLoad
=
true
componentDidMount
()
{
// 友盟统计
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
)
this
.
umengStatistic
()
//平台信息
...
...
@@ -57,23 +44,37 @@ class App extends Component {
if
(
browser
.
isWeixin
&&
browser
.
isIOS
)
{
sessionStorage
.
setItem
(
'enter_url'
,
window
.
location
.
href
)
}
this
.
getUser
()
this
.
utm
()
const
routeMatchRule
=
/binding-tel|forgot|set-password/
const
{
history
}
=
this
.
props
this
.
setNavigationRecord
(
this
.
props
.
location
,
this
.
props
.
history
.
action
)
this
.
setPreviousLocation
()
history
.
listen
((
location
,
action
)
=>
{
this
.
utm
()
this
.
firstLoad
=
false
this
.
setNavigationRecord
(
location
,
action
)
this
.
utm
()
if
(
cookie
.
get
(
'uid'
)
&&
this
.
props
.
user
.
hasError
)
{
this
.
getUser
()
}
const
{
pathname
}
=
location
const
{
pathname
,
state
}
=
location
if
(
pathname
.
startsWith
(
'/passport'
))
{
if
(
routeMatchRule
.
test
(
pathname
))
{
return
location
.
state
=
{
...
state
,
...{
from
:
{
pathname
:
this
.
previousLocation
.
pathname
,
search
:
this
.
previousLocation
.
search
,
hash
:
this
.
previousLocation
.
hash
}
}
}
location
.
state
=
{...
location
.
state
,
...{
from
:
this
.
previousLocation
}};
}
else
{
this
.
removeShareCodeCookie
()
}
...
...
@@ -82,6 +83,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
=
()
=>
{
cookie
.
remove
(
'share_code'
,
{
path
:
'/'
,
domain
:
'.julyedu.com'
})
}
...
...
@@ -103,7 +112,7 @@ class App extends Component {
location
.
state
&&
location
.
state
.
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
})
}
...
...
@@ -134,7 +143,7 @@ class App extends Component {
}
getUser
=
()
=>
{
//获取用户信息
this
.
props
.
startFetchUser
()
http
.
get
(
`
${
API
.
home
}
/m/user_info`
).
then
(
res
=>
{
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
...
...
@@ -171,30 +180,17 @@ class App extends Component {
componentDidUpdate
()
{
this
.
setPreviousLocation
()
if
(
!
this
.
props
.
user
.
hasError
&&
getParam
(
'redirect'
))
{
window
.
location
.
href
=
getParam
(
'redirect'
)
}
}
setPreviousLocation
=
()
=>
{
const
{
location
,
history
:
{
action
}}
=
this
.
props
if
(
location
.
pathname
.
startsWith
(
'/passport'
))
{
/*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
}
}
const
{
location
}
=
this
.
props
let
isInBlacklist
=
this
.
pathnameBlacklist
.
some
(
item
=>
location
.
pathname
.
startsWith
(
item
))
!
isInBlacklist
&&
(
this
.
previousLocation
=
location
)
}
transformUser
=
res
=>
{
...
...
src/components/my/edit.js
View file @
8b38e844
...
...
@@ -40,7 +40,7 @@ class MyEdut extends PureComponent {
// 退出登录
outLogin
=
()
=>
{
this
.
props
.
logout
()
Toast
.
info
(
'已退出'
,
2
)
Toast
.
info
(
'已退出'
,
2
,
null
,
false
)
this
.
props
.
history
.
push
(
'/my'
)
}
...
...
src/components/passport/index.js
View file @
8b38e844
...
...
@@ -9,9 +9,9 @@ import ForgotPassword from './forgotPassword'
import
SetPassword
from
'./setPassword'
import
BindingTel
from
'./bindingTel'
import
ForgotPasswordEmail
from
'./forgotPasswordEmail'
import
{
connect
}
from
"react-redux"
;
import
{
compose
}
from
"redux"
;
import
{
getParam
}
from
"@/utils"
;
import
{
connect
}
from
"react-redux"
import
{
compose
}
from
"redux"
import
{
getParam
}
from
"@/utils"
import
account
from
'./icons/account.png'
import
qq
from
'./icons/qq.png'
...
...
@@ -22,12 +22,13 @@ import wechat from './icons/wechat.png'
class
Passport
extends
Component
{
redirectURL
=
'/'
count
=
1
constructor
(
props
)
{
super
(
props
)
;
super
(
props
)
const
{
location
}
=
props
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
.
state
=
{
loginWays
:
[
...
...
@@ -60,27 +61,33 @@ class Passport extends Component {
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
()
{
this
.
routeWhenUserLoggedIn
()
}
routeWhenUserLoggedIn
=
()
=>
{
let
{
history
,
location
}
=
this
.
props
let
{
data
}
=
this
.
props
.
user
if
(
data
&&
Object
.
values
(
data
).
filter
(
item
=>
!!
item
).
length
)
{
if
(
history
.
action
===
'POP'
&&
history
.
length
<=
3
)
{
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
);
}
}
let
{
hasError
}
=
this
.
props
.
user
if
(
!
hasError
)
{
const
redirectURI
=
getParam
(
'redirect'
)
redirectURI
?
(
window
.
location
.
href
=
redirectURI
)
:
this
.
props
.
history
.
go
(
-
this
.
count
)
}
}
...
...
src/router/router-config.js
View file @
8b38e844
...
...
@@ -29,8 +29,8 @@ const MyEdit = loadable(() => import(/* webpackChunkName: 'MyEdit'*/'@/component
const
Classify
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/classify'
))
const
CampTest
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/video/camp/campTest'
))
const
CampResolve
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Classify'*/
'@/components/video/camp/campResolve'
))
const
ShareCourse
=
loadable
(()
=>
import
(
'@/components/ShareCourse/index'
))
const
Country
=
loadable
(()
=>
import
(
'@/components/country/index'
))
const
ShareCourse
=
loadable
(()
=>
import
(
/* webpackChunkName: 'ShareCourse'*/
'@/components/ShareCourse/index'
))
const
Country
=
loadable
(()
=>
import
(
/* webpackChunkName: 'Country' */
'@/components/country/index'
))
export
default
[
{
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