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
48b0a89f
Commit
48b0a89f
authored
Jun 29, 2020
by
xuzhenghua
Browse files
Options
Browse Files
Download
Plain Diff
pull
parents
d7861203
0edee270
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
98 deletions
+95
-98
src/components/Index/index.js
+3
-5
src/components/detail/index.js
+92
-93
No files found.
src/components/Index/index.js
View file @
48b0a89f
...
...
@@ -68,17 +68,15 @@ class Index extends Component {
}
userStatus
=
()
=>
{
this
.
setState
({
isShowUserGift
:
false
})
http
.
get
(
`
${
API
[
'base-api'
]}
/sys/user/new_user_status`
).
then
((
res
)
=>
{
const
{
errno
,
data
}
=
res
.
data
if
(
errno
===
0
)
{
if
(
data
.
status
==
1
)
{
// 新用户登录之后判断是否是新用户
Toast
.
info
(
'新人大礼包已领取成功!'
,
2
)
}
else
{
// 老用户
this
.
setState
({
isShowUserGift
:
false
})
}
}
})
...
...
src/components/detail/index.js
View file @
48b0a89f
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
'./index.scss'
import
Bargain
from
'./bargain'
import
Group
from
'./group'
import
OutLine
from
'./outline'
import
{
HeaderBar
,
CallApp
}
from
'../../common'
import
{
HeaderBar
,
CallApp
}
from
'../../common'
import
ShareRank
from
"./shareRank"
import
Audition
from
"./audition"
import
Single
from
"./single"
import
SingleSuccess
from
'./single/singleSuccess'
;
import
SingleSuccess
from
'./single/singleSuccess'
import
BtnStatus
from
"./btnstatus"
import
Barrage
from
'./barrage'
import
Deposit
from
'./deposit'
import
{
connect
}
from
"react-redux"
import
{
getCourses
,
addCourseToCart
}
from
"./actions"
import
{
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
import
{
Toast
}
from
'antd-mobile'
import
{
bindActionCreators
}
from
"redux"
;
import
{
delCountryNum
}
from
'./../country/countryRedux'
;
import
{
Popup
}
from
"@common/index"
import
RedPacket
from
'./redPacket'
;
import
ExpandActiveToast
from
"../Index/expandActiveToast"
;
import
{
connect
}
from
"react-redux"
import
{
getCourses
,
addCourseToCart
}
from
"./actions"
import
{
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
import
{
Toast
}
from
'antd-mobile'
import
{
bindActionCreators
}
from
"redux"
import
{
delCountryNum
}
from
'./../country/countryRedux'
import
{
Popup
}
from
"@common/index"
import
RedPacket
from
'./redPacket'
import
ExpandActiveToast
from
"../Index/expandActiveToast"
import
{
UserGift
}
from
"@common"
class
Detail
extends
Component
{
...
...
@@ -53,17 +53,17 @@ class Detail extends Component {
countDownTime
:
'20s'
,
isShowChannel
:
window
.
sessionStorage
.
getItem
(
'isShowSiteWindowByChannel'
),
isShowUserGift
:
false
isShowUserGift
:
false
}
}
componentDidMount
()
{
this
.
fetchCourseInfo
();
this
.
showUserGiftFun
();
this
.
userStatus
();
const
{
location
:
{
state
=
{}}}
=
this
.
props
;
this
.
fetchCourseInfo
()
this
.
showUserGiftFun
()
this
.
userStatus
()
const
{
location
:
{
state
=
{}}}
=
this
.
props
if
(
state
.
oid
)
{
this
.
check
(
state
.
oid
);
this
.
check
(
state
.
oid
)
}
if
(
getParam
(
'is_class'
)
===
1
||
getParam
(
'weixinpay'
))
{
this
.
payCallback
()
...
...
@@ -72,32 +72,30 @@ class Detail extends Component {
this
.
isweixinPay
()
}
this
.
judgeIsRedPacket
();
this
.
judgeIsRedPacket
()
// 红包链接进入详情也
if
(
getParam
(
'share_code'
))
{
this
.
setState
({
isRedPacket
:
true
});
})
}
if
(
getParam
(
'ac'
)
&&
Number
(
getParam
(
'ac'
))
===
11
)
{
this
.
getBorwerCourse
();
this
.
getBorwerCourse
()
}
}
userStatus
=
()
=>
{
userStatus
=
()
=>
{
this
.
setState
({
isShowUserGift
:
false
})
http
.
get
(
`
${
API
[
'base-api'
]}
/sys/user/new_user_status`
).
then
((
res
)
=>
{
const
{
errno
,
data
}
=
res
.
data
if
(
errno
===
0
)
{
if
(
data
.
status
==
1
)
{
// 新用户登录之后判断是否是新用户
Toast
.
info
(
'新人大礼包已领取成功!'
,
2
)
}
else
{
// 老用户
this
.
setState
({
isShowUserGift
:
false
})
}
}
})
...
...
@@ -126,38 +124,38 @@ class Detail extends Component {
getBorwerCourse
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/user/blessing`
,
{
type
:
4
,
course_id
:
getParam
(
'id'
)}).
then
(
res
=>
{
let
{
code
,
data
:
{
today_browsed_courses
}}
=
res
.
data
;
let
{
code
,
data
:
{
today_browsed_courses
}}
=
res
.
data
if
(
code
===
200
)
{
let
currentCourseId
=
getParam
(
'id'
);
let
currentCourseId
=
getParam
(
'id'
)
if
(
today_browsed_courses
.
includes
(
Number
(
currentCourseId
)))
{
this
.
setState
({
countDownTime
:
'任务完成'
});
})
}
else
{
this
.
startActivity
();
this
.
startActivity
()
}
}
})
}
startActivity
=
()
=>
{
let
_this
=
this
;
let
_this
=
this
let
countDownInterval
=
setInterval
(
function
()
{
let
countDown
=
parseInt
(
_this
.
state
.
countDownTime
);
countDown
--
;
let
countDown
=
parseInt
(
_this
.
state
.
countDownTime
)
countDown
--
if
(
countDown
>
0
)
{
_this
.
setState
({
countDownTime
:
countDown
+
's'
});
})
}
else
if
(
countDown
===
0
)
{
clearInterval
(
countDownInterval
);
countDownInterval
=
null
;
clearInterval
(
countDownInterval
)
countDownInterval
=
null
http
.
post
(
`
${
API
.
home
}
/sys/add/blessing`
,
{
type
:
4
,
course_id
:
getParam
(
'id'
)}).
then
(
res
=>
{
let
{
code
}
=
res
.
data
;
let
{
code
}
=
res
.
data
if
(
code
===
200
)
{
_this
.
setState
({
countDownTime
:
'任务完成'
});
})
}
})
}
...
...
@@ -167,11 +165,11 @@ class Detail extends Component {
// 判断时候未红包课程
judgeIsRedPacket
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/redPacket/showShareActive/
${
getParam
(
'id'
)}
`
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
;
const
{
code
,
data
}
=
res
.
data
if
(
code
===
200
)
{
this
.
setState
({
isRedPacket
:
data
.
is_show
});
})
}
})
}
...
...
@@ -183,9 +181,9 @@ class Detail extends Component {
}
payCallback
=
()
=>
{
const
_this
=
this
;
const
_this
=
this
if
(
!
getParam
(
'oid'
))
{
return
;
return
}
else
{
this
.
setState
({
singMess
:
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'singMess'
))
...
...
@@ -193,8 +191,8 @@ class Detail extends Component {
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
===
401
)
{
clearInterval
(
_this
.
intervalPayStatus
);
_this
.
intervalPayStatus
=
null
;
clearInterval
(
_this
.
intervalPayStatus
)
_this
.
intervalPayStatus
=
null
// 获取课程类型
http
.
get
(
`
${
API
[
'base-api'
]}
/class_order_status/
${
getParam
(
'oid'
)}
`
).
then
((
res
)
=>
{
if
(
Number
(
res
.
data
.
data
.
errno
)
===
200
)
{
...
...
@@ -228,10 +226,10 @@ class Detail extends Component {
})
},
1000
)
}
};
}
isweixinPay
=
()
=>
{
let
_this
=
this
;
let
weixin_code
=
getParam
(
'code'
);
let
_this
=
this
let
weixin_code
=
getParam
(
'code'
)
if
(
weixin_code
)
{
if
(
!
getParam
(
'oid'
))
{
return
...
...
@@ -239,10 +237,10 @@ class Detail extends Component {
// this.props.weixinPay(weixin_code)
this
.
setState
({
singMess
:
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'singMess'
))
});
})
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/pub_charge/oid/
${
getParam
(
'oid'
)}
/code/
${
weixin_code
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
const
data
=
res
.
data
.
data
;
const
data
=
res
.
data
.
data
function
onBridgeReady
()
{
WeixinJSBridge
.
invoke
(
...
...
@@ -256,12 +254,12 @@ class Detail extends Component {
},
function
(
res
)
{
if
(
res
.
err_msg
==
"get_brand_wcpay_request:ok"
)
{
Toast
.
info
(
'支付成功'
,
2
);
Toast
.
info
(
'支付成功'
,
2
)
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
===
401
)
{
clearInterval
(
_this
.
intervalPayStatus
);
_this
.
intervalPayStatus
=
null
;
clearInterval
(
_this
.
intervalPayStatus
)
_this
.
intervalPayStatus
=
null
// 获取课程类型
http
.
get
(
`
${
API
[
'base-api'
]}
/class_order_status/
${
getParam
(
'oid'
)}
`
).
then
((
res
)
=>
{
if
(
Number
(
res
.
data
.
data
.
errno
)
===
200
)
{
...
...
@@ -356,7 +354,7 @@ class Detail extends Component {
}
payCallBack
=
(
singleType
,
nowPrice
,
laterPrice
)
=>
{
const
_this
=
this
;
const
_this
=
this
if
(
singleType
===
2
)
{
_this
.
setState
({
singleType
,
...
...
@@ -368,18 +366,18 @@ class Detail extends Component {
singleType
,
})
}
};
}
fetchCourseInfo
=
()
=>
{
const
id
=
getParam
(
'id'
);
const
id
=
getParam
(
'id'
)
http
.
get
(
`
${
API
.
home
}
/m/course/detail/
${
id
}
`
).
then
((
res
)
=>
{
const
{
data
,
code
}
=
res
.
data
;
const
{
data
,
code
}
=
res
.
data
if
(
code
===
200
)
{
if
(
data
[
'redirect_url'
]
!==
''
)
{
window
.
location
.
href
=
data
[
'redirect_url'
]
}
this
.
setState
({
course
:
data
});
})
if
(
data
.
course_info
)
{
const
mode
=
data
.
course_info
.
mode
...
...
@@ -392,28 +390,28 @@ class Detail extends Component {
6
:
'python'
,
7
:
'ml'
}
if
(
Object
.
keys
(
route
).
includes
(
mode
))
{
if
(
Object
.
keys
(
route
).
includes
(
mode
))
{
history
.
push
(
`
${
route
[
mode
]}
?id=
${
id
}
`
)
}
}
let
course_info
=
data
.
course_info
;
document
.
title
=
`
${
course_info
.
course_title
}
- 七月在线`
;
let
course_info
=
data
.
course_info
document
.
title
=
`
${
course_info
.
course_title
}
- 七月在线`
if
(
course_info
.
group_status
===
3
||
course_info
.
group_status
===
4
)
{
let
endTime
=
course_info
.
pdd_group_info
.
groupon_member
.
end_time
;
let
endTime
=
course_info
.
pdd_group_info
.
groupon_member
.
end_time
if
(
endTime
&&
endTime
>
0
)
{
let
date
=
endTime
*
1000
,
hours
=
0
,
minutes
=
0
,
seconds
=
0
;
seconds
=
0
setInterval
(()
=>
{
date
-=
1000
hours
=
`
${
parseInt
(
date
/
(
60
*
60
*
1000
))}
`
.
padStart
(
2
,
0
);
minutes
=
`
${
parseInt
((
date
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
);
seconds
=
`
${
parseInt
((
date
-
hours
*
3600000
-
minutes
*
60000
)
/
1000
)}
`
.
padStart
(
2
,
0
);
hours
=
`
${
parseInt
(
date
/
(
60
*
60
*
1000
))}
`
.
padStart
(
2
,
0
)
minutes
=
`
${
parseInt
((
date
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
)
seconds
=
`
${
parseInt
((
date
-
hours
*
3600000
-
minutes
*
60000
)
/
1000
)}
`
.
padStart
(
2
,
0
)
this
.
setState
({
countdown
:
`
${
hours
}
:
${
minutes
}
:
${
seconds
}
`
});
})
},
1000
)
}
}
...
...
@@ -422,11 +420,11 @@ class Detail extends Component {
desc
:
course_info
.
index_description
,
link
:
encodeURI
(
location
.
origin
+
'/detail?id='
+
getParam
(
'id'
)),
imgUrl
:
course_info
.
image_name
});
})
}
}
});
})
}
// 点击子组件试听按钮
...
...
@@ -437,13 +435,13 @@ class Detail extends Component {
this
.
props
.
history
.
push
(
'/passport/login'
)
}
else
{
if
(
videoId
==
''
||
videoId
==
0
||
videoId
==
undefined
)
{
return
false
;
return
false
}
http
.
post
(
`
${
API
[
'base-api'
]}
/sys/get_class_audition?video_id=
${
videoId
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
==
200
)
{
this
.
props
.
history
.
push
(
`/play/video?id=
${
vCourseId
+
'&video_id='
+
videoId
}
`
)
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
// this.setState({
...
...
@@ -462,37 +460,37 @@ class Detail extends Component {
singleBox
:
true
,
singleType
:
1
,
singMess
:
item
});
})
window
.
localStorage
.
setItem
(
'singMess'
,
JSON
.
stringify
(
item
))
}
}
// 加入购物车 type:1 加入购物车,2加入购物车并跳转到购物车页面去支付
toCart
=
(
type
)
=>
{
const
{
history
,
addCourseToCart
}
=
this
.
props
;
const
{
history
,
addCourseToCart
}
=
this
.
props
let
data
=
{
course_id
:
getParam
(
'id'
)
};
}
http
.
post
(
`
${
API
.
home
}
/m/cart/add`
,
data
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
if
(
type
===
1
)
{
Toast
.
info
(
'已加入购物车'
,
2
)
// this.props.getCourses()
// document.location.reload()
addCourseToCart
();
this
.
fetchCourseInfo
();
addCourseToCart
()
this
.
fetchCourseInfo
()
}
else
{
history
.
replace
(
'/shopcart'
);
history
.
replace
(
'/shopcart'
)
}
}
else
if
(
res
.
data
.
code
===
15001
)
{
history
.
replace
(
'/shopcart'
);
history
.
replace
(
'/shopcart'
)
}
else
if
(
res
.
data
.
code
===
4030
)
{
history
.
replace
(
'/passport'
);
history
.
replace
(
'/passport'
)
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
};
}
invitedFriends
=
()
=>
{
// const {course_title, image_name, course_id, pdd_group_info, pdd_group_info: {groupon_member, groupon_member: {number}, price}} = this.state.course.course_info;
...
...
@@ -506,10 +504,10 @@ class Detail extends Component {
// } else {
// Toast.info('请在微信中使用分享功能!', 2);
// }
const
{
history
}
=
this
.
props
;
const
{
course
=
{}}
=
this
.
state
;
const
{
history
}
=
this
.
props
const
{
course
=
{}}
=
this
.
state
if
(
course
.
course_info
&&
course
.
course_info
.
self_oid
)
{
history
.
push
(
`/togroup?id=
${
course
.
course_info
.
self_oid
}
`
);
history
.
push
(
`/togroup?id=
${
course
.
course_info
.
self_oid
}
`
)
}
}
...
...
@@ -520,7 +518,7 @@ class Detail extends Component {
singleBox
:
val
,
singleType
:
1
})
this
.
props
.
history
.
push
(
`/detail?id=
${
getParam
(
'id'
)}
`
);
this
.
props
.
history
.
push
(
`/detail?id=
${
getParam
(
'id'
)}
`
)
}
formatTime
=
seconds
=>
({
...
...
@@ -543,7 +541,8 @@ class Detail extends Component {
closable
:
false
,
clickMaskClose
:
false
,
title
:
<
div
>
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/time_limited_free/M/check.png"
alt
=
""
/>
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/time_limited_free/M/check.png"
alt
=
""
/>
<
div
>
课程有效期
7
天,快去学习吧
~<
/div
>
<
/div>
,
content
:
<
div
className
=
{
'btns'
}
>
...
...
@@ -569,24 +568,24 @@ class Detail extends Component {
render
()
{
const
{
course
:
{
course_info
=
{}},
barInfo
,
singleBox
,
singleType
,
isRedPacket
,
countDownTime
}
=
this
.
state
;
const
{
course
:
{
course_info
=
{}},
barInfo
,
singleBox
,
singleType
,
isRedPacket
,
countDownTime
}
=
this
.
state
const
{
d
,
h
,
m
}
=
this
.
formatTime
(
course_info
.
limit_free_time
)
let
courseInfo
=
''
,
service
=
''
,
number
=
0
,
endTime
=
0
;
endTime
=
0
// if (this.props.courseInfo.course_info) {
// courseInfo = this.props.courseInfo.course_info;
// service = courseInfo.service;
if
(
course_info
.
group_status
===
3
||
course_info
.
group_status
===
4
)
{
number
=
course_info
.
pdd_group_info
.
groupon_member
.
number
;
number
=
course_info
.
pdd_group_info
.
groupon_member
.
number
}
// }
const
{
share
,
countdown
,
list
,
outList
}
=
this
.
state
;
let
href
=
''
;
const
{
location
:
{
state
=
{}}}
=
this
.
props
;
const
{
share
,
countdown
,
list
,
outList
}
=
this
.
state
let
href
=
''
const
{
location
:
{
state
=
{}}}
=
this
.
props
if
(
state
.
to
&&
state
.
to
===
'classify'
)
{
href
=
'/classify'
}
...
...
@@ -596,7 +595,7 @@ class Detail extends Component {
if
(
getParam
(
'dist_code'
))
{
href
=
'/'
}
let
isCent
=
course_info
.
pdd_group_info
&&
course_info
.
pdd_group_info
.
price
!=
'0.01'
;
let
isCent
=
course_info
.
pdd_group_info
&&
course_info
.
pdd_group_info
.
price
!=
'0.01'
return
(
<
div
>
{
...
...
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