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
8dc770b7
Commit
8dc770b7
authored
Dec 22, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
进入课程详情页返回首页
parent
e55f224e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
228 additions
and
224 deletions
+228
-224
src/App.js
+227
-222
src/components/blessingPreheat/courseItem/index.js
+1
-2
No files found.
src/App.js
View file @
8dc770b7
...
@@ -23,264 +23,269 @@ import './assets/font/iconfont.css'
...
@@ -23,264 +23,269 @@ import './assets/font/iconfont.css'
class
App
extends
Component
{
class
App
extends
Component
{
static
displayName
=
'App'
static
displayName
=
'App'
previousLocation
=
{
pathname
:
'/'
,
search
:
''
,
hash
:
''
}
previousLocation
=
{
pathname
:
'/'
,
search
:
''
,
hash
:
''
}
records
=
[]
records
=
[]
pathnameBlacklist
=
[
'/country'
,
'/passport'
]
pathnameBlacklist
=
[
'/country'
,
'/passport'
]
firstLoad
=
true
firstLoad
=
true
componentDidMount
()
{
componentDidMount
()
{
this
.
umengStatistic
()
this
.
umengStatistic
()
//平台信息
//平台信息
cookie
.
set
(
'plat'
,
'5'
,
{
domain
:
'.julyedu.com'
})
cookie
.
set
(
'plat'
,
'5'
,
{
domain
:
'.julyedu.com'
})
if
(
browser
.
isWeixin
&&
browser
.
isIOS
)
{
if
(
browser
.
isWeixin
&&
browser
.
isIOS
)
{
sessionStorage
.
setItem
(
'enter_url'
,
window
.
location
.
href
)
sessionStorage
.
setItem
(
'enter_url'
,
window
.
location
.
href
)
}
}
this
.
getUser
()
this
.
getUser
()
this
.
utm
()
this
.
utm
()
const
{
history
}
=
this
.
props
const
{
history
}
=
this
.
props
this
.
setNavigationRecord
(
this
.
props
.
location
,
this
.
props
.
history
.
action
)
this
.
setNavigationRecord
(
this
.
props
.
location
,
this
.
props
.
history
.
action
)
this
.
setPreviousLocation
()
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
()
}
}
if
(
location
.
pathname
===
'/passport'
){
if
(
location
.
pathname
===
'/passport'
)
{
window
.
localStorage
.
setItem
(
'binding_redirect'
,
JSON
.
stringify
(
this
.
previousLocation
))
window
.
localStorage
.
setItem
(
'binding_redirect'
,
JSON
.
stringify
(
this
.
previousLocation
))
}
}
const
{
pathname
,
state
}
=
location
const
{
pathname
,
state
}
=
location
if
(
pathname
.
startsWith
(
'/passport'
))
{
if
(
pathname
.
startsWith
(
'/passport'
))
{
location
.
state
=
{
location
.
state
=
{
...
state
,
...
state
,
...{
...{
from
:
{
from
:
{
pathname
:
this
.
previousLocation
.
pathname
,
pathname
:
this
.
previousLocation
.
pathname
,
search
:
this
.
previousLocation
.
search
,
search
:
this
.
previousLocation
.
search
,
hash
:
this
.
previousLocation
.
hash
hash
:
this
.
previousLocation
.
hash
}
}
}
}
else
{
this
.
removeShareCodeCookie
()
}
}
})
}
}
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'
})
}
setNavigationRecord
=
(
location
,
action
)
=>
{
const
{
pathname
,
search
,
hash
}
=
location
let
isLastRecord
=
location
.
pathname
===
(
this
.
records
.
length
&&
this
.
records
[
this
.
records
.
length
-
1
].
pathname
)
switch
(
action
)
{
case
'POP'
:
this
.
firstLoad
?
this
.
records
.
push
({
pathname
,
search
,
hash
})
:
this
.
records
.
pop
()
break
case
'REPLACE'
:
this
.
records
.
length
>
1
&&
(
this
.
records
[
this
.
records
.
length
-
1
]
=
{
pathname
,
search
,
hash
})
break
default
:
!
isLastRecord
&&
this
.
records
.
push
({
pathname
,
search
,
hash
})
}
}
}
else
{
location
.
state
&&
location
.
state
.
records
this
.
removeShareCodeCookie
()
?
(
location
.
state
.
records
=
this
.
records
)
}
:
location
.
state
?
location
.
state
=
{...
location
.
state
,
records
:
this
.
records
}
})
:
(
location
.
state
=
{
records
:
this
.
records
})
}
}
utm
=
()
=>
{
umengStatistic
=
()
=>
{
// utm统计 m站全站统计广告投放、以及统计详情页浏览
// 友盟统计
let
utm_source
=
getParam
(
'utm_source'
)
const
script
=
document
.
createElement
(
'script'
)
let
utm_medium
=
getParam
(
'utm_medium'
)
script
.
src
=
'https://s22.cnzz.com/z_stat.php?id=1265696973&web_id=1265696973'
let
utm_campaign
=
getParam
(
'utm_campaign'
)
script
.
language
=
'JavaScript'
let
utm_content
=
getParam
(
'utm_content'
)
document
.
body
.
appendChild
(
script
)
let
utm_term
=
getParam
(
'utm_term'
)
}
let
courseId
=
location
.
pathname
.
startsWith
(
'/getDetail'
)
||
location
.
pathname
.
startsWith
(
'/detail'
)
?
getParam
(
'id'
)
:
0
removeShareCodeCookie
=
()
=>
{
if
(
courseId
||
(
utm_term
&&
utm_source
&&
utm_medium
&&
utm_campaign
&&
utm_content
))
{
cookie
.
remove
(
'share_code'
,
{
path
:
'/'
,
domain
:
'.julyedu.com'
})
let
data
=
{
}
'utm_source'
:
utm_source
,
'utm_medium'
:
utm_medium
,
setNavigationRecord
=
(
location
,
action
)
=>
{
'utm_campaign'
:
utm_campaign
,
const
{
pathname
,
search
,
hash
}
=
location
'utm_content'
:
utm_content
,
let
isLastRecord
=
location
.
pathname
===
(
this
.
records
.
length
&&
this
.
records
[
this
.
records
.
length
-
1
].
pathname
)
'utm_term'
:
utm_term
,
let
needHistoryMutation
=
location
.
pathname
!==
this
.
previousLocation
.
pathname
}
switch
(
action
)
{
http
.
post
(
`
${
API
[
'www'
]}
/base/first_utm_record/
${
courseId
}
`
,
data
)
case
'POP'
:
.
then
(
res
=>
{
if
(
needHistoryMutation
)
{
})
this
.
firstLoad
?
this
.
records
.
push
({
pathname
,
search
,
hash
})
:
this
.
records
.
pop
()
}
else
{
this
.
records
[
this
.
records
.
length
-
1
]
=
location
}
}
break
case
'REPLACE'
:
this
.
records
.
length
>
1
&&
(
this
.
records
[
this
.
records
.
length
-
1
]
=
{
pathname
,
search
,
hash
})
break
default
:
!
isLastRecord
&&
this
.
records
.
push
({
pathname
,
search
,
hash
})
}
}
getUser
=
()
=>
{
location
.
state
&&
location
.
state
.
records
//获取用户信息
?
(
location
.
state
.
records
=
this
.
records
)
this
.
props
.
startFetchUser
()
:
location
.
state
?
location
.
state
=
{...
location
.
state
,
records
:
this
.
records
}
http
.
get
(
`
${
API
.
home
}
/m/user_info`
).
then
(
res
=>
{
:
(
location
.
state
=
{
records
:
this
.
records
})
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
}
utm
=
()
=>
{
// utm统计 m站全站统计广告投放、以及统计详情页浏览
let
utm_source
=
getParam
(
'utm_source'
)
let
utm_medium
=
getParam
(
'utm_medium'
)
let
utm_campaign
=
getParam
(
'utm_campaign'
)
let
utm_content
=
getParam
(
'utm_content'
)
let
utm_term
=
getParam
(
'utm_term'
)
let
courseId
=
location
.
pathname
.
startsWith
(
'/getDetail'
)
||
location
.
pathname
.
startsWith
(
'/detail'
)
?
getParam
(
'id'
)
:
0
if
(
courseId
||
(
utm_term
&&
utm_source
&&
utm_medium
&&
utm_campaign
&&
utm_content
))
{
let
data
=
{
'utm_source'
:
utm_source
,
'utm_medium'
:
utm_medium
,
'utm_campaign'
:
utm_campaign
,
'utm_content'
:
utm_content
,
'utm_term'
:
utm_term
,
}
http
.
post
(
`
${
API
[
'www'
]}
/base/first_utm_record/
${
courseId
}
`
,
data
)
.
then
(
res
=>
{
})
})
//微信
let
code
=
getParam
(
'code'
)
let
oid
=
getParam
(
'oid'
)
if
(
code
&&
!
oid
)
{
//针对2019双旦活动特殊处理,活动结束后删掉
}
//treasure_code=3538333139312c31&origin=2&aa=bb&code=0211aiYB1VVOL60rmWWB1367YB11aiY7&state=STATE
}
if
(
getParam
(
'treasure_code'
)
==
'3538333139312c31'
&&
code
==
'0211aiYB1VVOL60rmWWB1367YB11aiY7'
){
return
getUser
=
()
=>
{
//获取用户信息
this
.
props
.
startFetchUser
()
http
.
get
(
`
${
API
.
home
}
/m/user_info`
).
then
(
res
=>
{
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
})
//微信
let
code
=
getParam
(
'code'
)
let
oid
=
getParam
(
'oid'
)
if
(
code
&&
!
oid
)
{
//针对2019双旦活动特殊处理,活动结束后删掉
//treasure_code=3538333139312c31&origin=2&aa=bb&code=0211aiYB1VVOL60rmWWB1367YB11aiY7&state=STATE
if
(
getParam
(
'treasure_code'
)
==
'3538333139312c31'
&&
code
==
'0211aiYB1VVOL60rmWWB1367YB11aiY7'
)
{
return
}
http
.
get
(
`
${
API
[
'home'
]}
/m/wx_loginInfo/code/
${
code
}
?redirect=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
)
.
then
(
res
=>
{
let
data
=
res
.
data
if
(
data
.
errno
==
200
)
{
if
(
data
.
data
[
'is_bind_mobile'
])
{
window
.
location
.
assign
(
data
.
data
.
url
)
}
else
{
let
user
=
this
.
transformWxUser
(
res
)
let
{
role
,
uid
,
token
}
=
data
.
data
let
expires
=
addDays
(
new
Date
(),
90
)
cookie
.
set
(
'role'
,
role
,
{
expires
,
domain
:
'.julyedu.com'
,
path
:
'/'
})
cookie
.
set
(
'uid'
,
uid
,
{
expires
,
domain
:
'.julyedu.com'
,
path
:
'/'
})
cookie
.
set
(
'token'
,
token
,
{
expires
,
domain
:
'.julyedu.com'
,
path
:
'/'
})
this
.
props
.
setCurrentUser
(
user
)
}
}
}
else
{
http
.
get
(
`
${
API
[
'home'
]}
/m/wx_loginInfo/code/
${
code
}
?redirect=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
)
Toast
.
info
(
data
.
msg
)
.
then
(
res
=>
{
}
let
data
=
res
.
data
})
if
(
data
.
errno
==
200
)
{
if
(
data
.
data
[
'is_bind_mobile'
])
{
window
.
location
.
assign
(
data
.
data
.
url
)
}
else
{
let
user
=
this
.
transformWxUser
(
res
)
let
{
role
,
uid
,
token
}
=
data
.
data
let
expires
=
addDays
(
new
Date
(),
90
)
cookie
.
set
(
'role'
,
role
,
{
expires
,
domain
:
'.julyedu.com'
,
path
:
'/'
})
cookie
.
set
(
'uid'
,
uid
,
{
expires
,
domain
:
'.julyedu.com'
,
path
:
'/'
})
cookie
.
set
(
'token'
,
token
,
{
expires
,
domain
:
'.julyedu.com'
,
path
:
'/'
})
this
.
props
.
setCurrentUser
(
user
)
}
}
else
{
Toast
.
info
(
data
.
msg
)
}
})
}
}
}
}
componentDidUpdate
()
{
componentDidUpdate
()
{
this
.
setPreviousLocation
()
if
(
!
this
.
props
.
user
.
hasError
&&
getParam
(
'redirect'
))
{
this
.
setPreviousLocation
()
window
.
location
.
href
=
getParam
(
'redirect'
)
}
}
setPreviousLocation
=
()
=>
{
if
(
!
this
.
props
.
user
.
hasError
&&
getParam
(
'redirect'
))
{
const
{
location
}
=
this
.
props
window
.
location
.
href
=
getParam
(
'redirect'
)
let
isInBlacklist
=
this
.
pathnameBlacklist
.
some
(
item
=>
location
.
pathname
.
startsWith
(
item
))
!
isInBlacklist
&&
(
this
.
previousLocation
=
location
)
}
}
}
transformUser
=
res
=>
{
let
payload
setPreviousLocation
=
()
=>
{
if
(
res
.
data
.
code
===
200
)
{
const
{
location
}
=
this
.
props
//移除红包统计cookie
let
isInBlacklist
=
this
.
pathnameBlacklist
.
some
(
item
=>
location
.
pathname
.
startsWith
(
item
))
this
.
removeShareCodeCookie
()
!
isInBlacklist
&&
(
this
.
previousLocation
=
location
)
const
{
}
msg
,
data
:
{
avatar_file
:
avatar
,
transformUser
=
res
=>
{
user_name
:
username
,
let
payload
is_vip
:
isVIP
,
if
(
res
.
data
.
code
===
200
)
{
uid
,
//移除红包统计cookie
code
this
.
removeShareCodeCookie
()
}
const
{
}
=
res
.
data
msg
,
data
:
{
avatar_file
:
avatar
,
payload
=
{
user_name
:
username
,
hasError
:
false
,
is_vip
:
isVIP
,
msg
,
uid
,
data
:
{
code
username
,
isVIP
,
avatar
,
uid
,
code
}
}
}
else
{
payload
=
{
hasError
:
true
,
msg
:
res
.
data
.
msg
,
code
:
res
.
data
.
code
,
data
:
{}
}
}
}
return
payload
}
=
res
.
data
}
payload
=
{
transformWxUser
=
res
=>
{
hasError
:
false
,
let
data
=
res
.
data
msg
,
if
(
data
.
errno
==
200
)
{
data
:
{
//移除红包统计cookie
username
,
this
.
removeShareCodeCookie
()
isVIP
,
let
{
uid
,
token
,
avatar_file
:
avatar
,
uname
:
username
,}
=
data
.
data
avatar
,
uid
,
return
{
code
hasError
:
false
,
data
:
{
uid
,
token
,
avatar
,
username
},
msg
:
data
.
msg
}
}
else
{
let
{
code
,
msg
}
=
data
.
data
return
{
code
,
msg
,
hasError
:
true
,
data
:
{}
}
}
}
}
}
else
{
payload
=
{
hasError
:
true
,
msg
:
res
.
data
.
msg
,
code
:
res
.
data
.
code
,
data
:
{}
}
}
}
return
payload
render
()
{
}
return
<>
<
Routes
/>
transformWxUser
=
res
=>
{
<
Link
className
=
{
'year19-index'
}
to
=
"/year/yearindex"
>
let
data
=
res
.
data
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/gift-package.png"
alt
=
""
/>
if
(
data
.
errno
==
200
)
{
<
/Link
>
//移除红包统计cookie
<
/
>
this
.
removeShareCodeCookie
()
let
{
uid
,
token
,
avatar_file
:
avatar
,
uname
:
username
,}
=
data
.
data
return
{
hasError
:
false
,
data
:
{
uid
,
token
,
avatar
,
username
},
msg
:
data
.
msg
}
}
else
{
let
{
code
,
msg
}
=
data
.
data
return
{
code
,
msg
,
hasError
:
true
,
data
:
{}
}
}
}
}
render
()
{
return
<>
<
Routes
/>
<
Link
className
=
{
'year19-index'
}
to
=
"/year/yearindex"
>
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/gift-package.png"
alt
=
""
/>
<
/Link
>
<
/
>
}
}
}
export
default
compose
(
export
default
compose
(
connect
(
connect
(
state
=>
({
user
:
state
.
user
}),
state
=>
({
user
:
state
.
user
}),
{
setCurrentUser
,
startFetchUser
}
{
setCurrentUser
,
startFetchUser
}
),
),
withRouter
withRouter
)(
App
)
)(
App
)
src/components/blessingPreheat/courseItem/index.js
View file @
8dc770b7
...
@@ -15,4 +15,4 @@ class CourseItem extends Component {
...
@@ -15,4 +15,4 @@ class CourseItem extends Component {
}
}
}
}
export
default
CourseItem
;
export
default
CourseItem
;
\ No newline at end of file
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