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