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
1a4760a9
Commit
1a4760a9
authored
Jun 24, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
c156b663
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
241 additions
and
194 deletions
+241
-194
src/App.js
+26
-23
src/components/Index/index.js
+22
-14
src/components/my/index.js
+176
-139
src/router/index.js
+4
-11
src/utils/index.js
+13
-7
No files found.
src/App.js
View file @
1a4760a9
...
...
@@ -29,7 +29,7 @@ class App extends Component {
super
(
props
)
this
.
state
=
{
isShowActivityEntry
:
0
,
isShowChannel
:
0
isShowChannel
:
0
,
}
this
.
globalEntry
=
null
}
...
...
@@ -66,11 +66,13 @@ class App extends Component {
sessionStorage
.
setItem
(
'enter_url'
,
window
.
location
.
href
)
}
this
.
getUser
()
this
.
utm
()
const
{
history
}
=
this
.
props
this
.
getUser
()
this
.
setNavigationRecord
(
this
.
props
.
location
,
this
.
props
.
history
.
action
)
this
.
setPreviousLocation
()
...
...
@@ -95,9 +97,9 @@ class App extends Component {
from
:
{
pathname
:
this
.
previousLocation
.
pathname
,
search
:
this
.
previousLocation
.
search
,
hash
:
this
.
previousLocation
.
hash
}
}
hash
:
this
.
previousLocation
.
hash
,
}
,
}
,
}
}
else
{
this
.
removeShareCodeCookie
()
...
...
@@ -114,7 +116,7 @@ class App extends Component {
// treasure_stage,宝箱阶段,0-不在活动时间,1-活动时间内
this
.
setState
({
isShowActivityEntry
:
data
.
treasure_stage
,
isShowChannel
:
data
.
is_show_site_window_by_channel
isShowChannel
:
data
.
is_show_site_window_by_channel
,
},
()
=>
{
data
.
treasure_stage
&&
this
.
bindGlobalEntry
()
})
...
...
@@ -171,7 +173,7 @@ class App extends Component {
if
(
zhihu_cb
)
{
let
data
=
{
'zhihu_cb'
:
zhihu_cb
'zhihu_cb'
:
zhihu_cb
,
}
http
.
post
(
`
${
API
[
'home'
]}
/sys/zhihu/firstRecord`
,
data
)
...
...
@@ -220,11 +222,12 @@ class App extends Component {
}
else
{
http
.
get
(
`
${
API
.
home
}
/m/user_info_sample/0`
).
then
(
res
=>
{
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
})
if
(
this
.
props
.
location
.
pathname
!==
'/my'
)
{
http
.
get
(
`
${
API
.
home
}
/m/user_info_sample/0`
).
then
(
res
=>
{
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
})
}
}
}
componentDidUpdate
()
{
...
...
@@ -253,8 +256,8 @@ class App extends Component {
user_name
:
username
,
is_vip
:
isVIP
,
uid
,
code
}
code
,
}
,
}
=
res
.
data
payload
=
{
...
...
@@ -265,15 +268,15 @@ class App extends Component {
isVIP
,
avatar
,
uid
,
code
}
code
,
}
,
}
}
else
{
payload
=
{
hasError
:
true
,
msg
:
res
.
data
.
msg
,
code
:
res
.
data
.
code
,
data
:
{}
data
:
{}
,
}
}
return
payload
...
...
@@ -284,7 +287,7 @@ class App extends Component {
if
(
data
.
errno
==
200
)
{
//移除红包统计cookie
this
.
removeShareCodeCookie
()
let
{
uid
,
token
,
avatar_file
:
avatar
,
uname
:
username
,
}
=
data
.
data
let
{
uid
,
token
,
avatar_file
:
avatar
,
uname
:
username
}
=
data
.
data
return
{
hasError
:
false
,
...
...
@@ -292,9 +295,9 @@ class App extends Component {
uid
,
token
,
avatar
,
username
username
,
},
msg
:
data
.
msg
msg
:
data
.
msg
,
}
}
else
{
let
{
code
,
msg
}
=
data
.
data
...
...
@@ -302,7 +305,7 @@ class App extends Component {
code
,
msg
,
hasError
:
true
,
data
:
{}
data
:
{}
,
}
}
}
...
...
@@ -338,7 +341,7 @@ class App extends Component {
closeGlobalEntry
=
()
=>
{
localStorage
.
setItem
(
'globalEntryClosedTime'
,
Date
.
now
().
toString
())
this
.
setState
({
isShowActivityEntry
:
0
isShowActivityEntry
:
0
,
})
}
...
...
@@ -374,7 +377,7 @@ class App extends Component {
export
default
compose
(
connect
(
state
=>
({
user
:
state
.
user
}),
{
setCurrentUser
,
startFetchUser
}
{
setCurrentUser
,
startFetchUser
}
,
),
withRouter
withRouter
,
)(
App
)
src/components/Index/index.js
View file @
1a4760a9
...
...
@@ -5,7 +5,7 @@ import { WithTab } from '@/HOCs'
// import Swiper from 'react-mobile-swiper'
// import createStyle from './createStyle'
import
HomeCourseList
from
'./course-list'
import
{
http
}
from
'@/utils'
import
{
http
,
isValidUrl
}
from
'@/utils'
import
LiveRoom
from
'./liveRoom'
import
{
Link
}
from
"react-router-dom"
import
{
Toast
}
from
'antd-mobile'
...
...
@@ -17,7 +17,7 @@ import AllCourseNavigation from "./all-course"
// const animateTypes = Swiper.animateTypes
@
connect
(
state
=>
({
user
:
state
.
user
user
:
state
.
user
,
}))
class
Index
extends
Component
{
constructor
(
props
)
{
...
...
@@ -33,28 +33,28 @@ class Index extends Component {
{
'src'
:
require
(
'./image/freeclass_icon.png'
),
'name'
:
'公开课'
,
'href'
:
'/study/free-course'
'href'
:
'/study/free-course'
,
},
{
'src'
:
require
(
'./image/jingpin_icon.png'
),
'name'
:
'精品特惠'
,
'href'
:
'/preferential'
'href'
:
'/preferential'
,
},
{
'src'
:
require
(
'./image/zjxj_icon.png'
),
'name'
:
'赚奖学金'
,
'href'
:
'/scholarship'
'href'
:
'/scholarship'
,
},
{
'src'
:
require
(
'./image/mryt_icon.png'
),
'name'
:
'每日一题'
,
'href'
:
'/examination'
'href'
:
'/examination'
,
},
{
'src'
:
require
(
'./image/shequ_icon.png'
),
'name'
:
'社区'
,
'href'
:
'https://ask.julyedu.com'
}
'href'
:
'https://ask.julyedu.com'
,
}
,
],
}
}
...
...
@@ -72,7 +72,7 @@ class Index extends Component {
this
.
setState
({
banner
:
data
.
banner
,
lives
:
data
.
lives
,
modules
modules
,
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
...
...
@@ -93,7 +93,7 @@ class Index extends Component {
this
.
setState
({
isShow
:
true
,
islive
:
true
,
roomMess
:
item
roomMess
:
item
,
})
}
else
{
window
.
location
.
href
=
`
${
window
.
location
.
href
.
includes
(
'pre'
)
?
'http://www-pre.julyedu.com'
:
'http://www.julyedu.com'
}
/live/m_room/
${
item
.
room_id
}
`
...
...
@@ -147,10 +147,18 @@ class Index extends Component {
this
.
state
.
tabdata
.
map
((
item
,
index
)
=>
{
return
(
<
li
key
=
{
index
}
>
<
a
href
=
{
item
.
href
}
>
<
img
src
=
{
item
.
src
}
alt
=
""
/>
<
span
>
{
item
.
name
}
<
/span
>
<
/a
>
{
isValidUrl
(
item
.
href
)
?
<
a
href
=
{
item
.
href
}
>
<
img
src
=
{
item
.
src
}
alt
=
""
/>
<
span
>
{
item
.
name
}
<
/span
>
<
/a
>
:
<
Link
to
=
{
item
.
href
}
>
<
img
src
=
{
item
.
src
}
alt
=
""
/>
<
span
>
{
item
.
name
}
<
/span
>
<
/Link
>
}
<
/li
>
)
})
...
...
src/components/my/index.js
View file @
1a4760a9
This diff is collapsed.
Click to expand it.
src/router/index.js
View file @
1a4760a9
...
...
@@ -2,16 +2,6 @@ import React from 'react'
import
{
Switch
,
Route
}
from
'react-router-dom'
import
RouterConfig
from
'./router-config'
import
PrivateRoute
from
'./privateRoute'
// 动态改变title
// const RouteWithSubRoutes = route => {
// return (
// <Route
// exact
// {...route}
// onChange={document.title = route.name}
// />
// );
// };
export
default
function
()
{
return
(
...
...
@@ -21,8 +11,11 @@ export default function () {
if
(
isPrivate
)
{
return
<
PrivateRoute
{...
rest
}
key
=
{
index
}
/
>
}
else
{
const
{
component
:
Component
,
...
rest
}
=
item
return
(
<
Route
{...
rest
}
key
=
{
index
}
/
>
<
Route
{...
rest
}
key
=
{
index
}
render
=
{(
props
)
=>
{
return
<
Component
{...
props
}
/
>
}}
/
>
)
}
})}
...
...
src/utils/index.js
View file @
1a4760a9
...
...
@@ -3,7 +3,7 @@ import {
differenceInDays
,
differenceInHours
,
differenceInMinutes
,
differenceInSeconds
differenceInSeconds
,
}
from
'date-fns'
...
...
@@ -15,7 +15,7 @@ export const getParam = (key, str) => {
}
const
html
=
content
=>
({
__html
:
htmlDecode
(
content
)
__html
:
htmlDecode
(
content
)
,
})
const
htmlDecode
=
content
=>
{
...
...
@@ -102,7 +102,7 @@ const browser = (function () {
isIOS
:
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/i
.
test
(
ua
),
isIPad
:
/iPad/i
.
test
(
ua
),
isAndroidApp
:
/Android/i
.
test
(
ua
)
&&
getParam
(
'version'
),
isIOSApp
:
/iPhone/i
.
test
(
ua
)
&&
getParam
(
'version'
)
isIOSApp
:
/iPhone/i
.
test
(
ua
)
&&
getParam
(
'version'
)
,
}
})()
...
...
@@ -119,17 +119,21 @@ const dateCountDown = (later, earlier) => {
d
,
h
,
m
,
s
s
,
}
}
const
isValidUrl
=
(
str
)
=>
{
return
/https
?
:
\/\/(
www
\.)?[
-a-zA-Z0-9@:%._
\+
~#=
]{1,256}\.[
a-zA-Z0-9()
]{1,6}\b([
-a-zA-Z0-9()@:%_
\+
.~#?&
//
=
]
*
)
/
.
test
(
str
)
}
export
{
default
as
http
default
as
http
,
}
from
'./http'
export
{
default
as
wxShare
default
as
wxShare
,
}
from
'./wechat/share'
export
{
...
...
@@ -141,8 +145,9 @@ export {
browser
,
isLogin
,
dateCountDown
,
isValidUrl
}
export
{
default
as
SendMessageToApp
default
as
SendMessageToApp
,
}
from
'./app'
\ 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