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
6f816124
Commit
6f816124
authored
Dec 24, 2019
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登陆
parent
968a968f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
33 deletions
+101
-33
src/components/python/index.js
+101
-33
src/components/python/pythomDes/index.js
+0
-0
No files found.
src/components/python/index.js
View file @
6f816124
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
{
http
,
getParam
}
from
'@/utils'
import
{
http
,
getParam
,
SendMessageToApp
}
from
'@/utils'
import
PythonDes
from
'./pythomDes'
import
PythonDes
from
'./pythomDes'
import
PythonStudy
from
'./pythonStudy'
import
PythonStudy
from
'./pythonStudy'
import
{
Toast
}
from
'antd-mobile'
import
{
connect
}
from
"react-redux"
import
{
addDays
}
from
"date-fns"
import
cookie
from
"js-cookie"
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
@
connect
(
state
=>
({
user
:
state
.
user
}),
{
setCurrentUser
,
startFetchUser
}
)
class
Python
extends
Component
{
class
Python
extends
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
)
this
.
state
=
{
this
.
state
=
{
isPay
:
''
,
isPay
:
''
,
userInfoList
:
[],
isAppUpdate
:
false
}
}
}
}
componentDidMount
()
{
componentDidMount
()
{
this
.
fetchCourseInfo
();
const
_this
=
this
}
this
.
fetchCourseInfo
()
// 获取App登录信息
window
[
'loginInfo'
]
=
result
=>
{
_this
.
loginInfo
(
result
)
}
}
fetchCourseInfo
=
()
=>
{
// 获取app登录数据
const
id
=
getParam
(
'id'
);
loginInfo
=
(
result
)
=>
{
http
.
get
(
`
${
API
.
home
}
/m/course/detail/
${
id
}
`
).
then
((
res
)
=>
{
const
{
data
,
code
}
=
res
.
data
;
if
(
code
===
200
)
{
this
.
setState
({
this
.
setState
({
isPay
:
data
.
course_info
.
is_pay
userInfoList
:
result
},
()
=>
{
if
(
this
.
state
.
userInfoList
.
length
)
{
this
.
props
.
startFetchUser
()
this
.
appLogin
()
}
})
})
}
});
}
}
// 保存cookie
render
()
{
appLogin
=
()
=>
{
const
{
isPay
}
=
this
.
state
;
let
expires
=
addDays
(
new
Date
(),
90
)
return
(
this
.
state
.
userInfoList
.
map
((
item
,
index
)
=>
{
<
div
>
cookie
.
set
(
"token"
,
item
.
token
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
{
cookie
.
set
(
"plat"
,
item
.
plat
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
isPay
===
0
&&
<
PythonDes
history
=
{
this
.
props
.
history
}
><
/PythonDes
>
cookie
.
set
(
"uid"
,
item
.
uid
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
}
cookie
.
set
(
"uname"
,
item
.
uname
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
{
cookie
.
set
(
"avatar_file"
,
item
.
avatar_file
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
(
isPay
===
1
&&
!
getParam
(
'version'
))
&&
<
PythonStudy
/>
})
if
(
cookie
.
get
(
"token"
)
&&
cookie
.
get
(
"uid"
))
{
this
.
setState
({
isAppUpdate
:
true
})
}
}
<
/div
>
)
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
this
.
state
.
userInfoList
))
}
}
transformUser
=
res
=>
{
let
payload
res
.
map
((
item
,
index
)
=>
{
payload
=
{
hasError
:
false
,
data
:
{
username
:
item
.
uname
,
avatar
:
item
.
avatar_file
,
token
:
item
.
token
,
uid
:
item
.
uid
},
isFetching
:
false
}
})
return
payload
}
fetchCourseInfo
=
()
=>
{
const
id
=
getParam
(
'id'
)
http
.
get
(
`
${
API
.
home
}
/m/course/detail/
${
id
}
`
).
then
((
res
)
=>
{
const
{
data
,
code
}
=
res
.
data
if
(
code
===
200
)
{
this
.
setState
({
isPay
:
data
.
course_info
.
is_pay
})
}
})
}
render
()
{
const
{
isPay
,
isAppUpdate
}
=
this
.
state
return
(
<
div
>
{
isPay
===
0
&&
<
PythonDes
history
=
{
this
.
props
.
history
}
isAppUpdate
=
{
isAppUpdate
}
><
/PythonDes
>
}
{
(
isPay
===
1
&&
!
getParam
(
'version'
))
&&
<
PythonStudy
isAppUpdate
=
{
isAppUpdate
}
/
>
}
<
/div
>
)
}
}
}
export
default
Python
export
default
Python
src/components/python/pythomDes/index.js
View file @
6f816124
This diff is collapsed.
Click to expand it.
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