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
ed228052
Commit
ed228052
authored
Sep 26, 2019
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券
parent
2d6e62de
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
230 additions
and
24 deletions
+230
-24
src/common/VList/index.js
+1
-0
src/components/coupons/Coupon/index.js
+14
-1
src/components/coupons/myCoupons/index.js
+89
-21
src/components/coupons/myCoupons/index.scss
+86
-1
src/components/purchased/index.js
+5
-0
src/components/purchased/index.scss
+15
-1
src/components/study/myCourses/index.js
+5
-0
src/components/study/myCourses/my-courses.scss
+15
-0
No files found.
src/common/VList/index.js
View file @
ed228052
...
@@ -12,6 +12,7 @@ const VList = (props) => {
...
@@ -12,6 +12,7 @@ const VList = (props) => {
<
div
className
=
"content"
>
<
div
className
=
"content"
>
<
div
className
=
"cover"
>
<
div
className
=
"cover"
>
{
props
.
status
}
{
props
.
status
}
{
props
.
courseExpire
}
{
props
.
toDetail
{
props
.
toDetail
?
(
<
img
src
=
{
props
.
img
}
alt
=
""
/>
)
?
(
<
img
src
=
{
props
.
img
}
alt
=
""
/>
)
:
(
<
img
src
=
{
props
.
img
}
alt
=
""
/>
)
:
(
<
img
src
=
{
props
.
img
}
alt
=
""
/>
)
...
...
src/components/coupons/Coupon/index.js
View file @
ed228052
...
@@ -7,11 +7,15 @@ class Coupon extends PureComponent {
...
@@ -7,11 +7,15 @@ class Coupon extends PureComponent {
pick
=
()
=>
{
pick
=
()
=>
{
let
{
useCoupon
,
invalid
}
=
this
.
props
let
{
useCoupon
,
invalid
}
=
this
.
props
!
invalid
&&
useCoupon
&&
useCoupon
(
this
.
props
.
id
)
!
invalid
&&
useCoupon
&&
useCoupon
(
this
.
props
.
id
)
}
}
GoToUse
=
()
=>
{
GoToUse
=
()
=>
{
this
.
props
.
useCoupon
(
this
.
props
.
id
)
this
.
props
.
useCoupon
(
this
.
props
.
id
)
}
}
ExchangeCourse
=
(
e
)
=>
{
this
.
props
.
toExchangeCourse
(
e
,
this
.
props
.
code
)
}
render
()
{
render
()
{
let
{
let
{
...
@@ -22,6 +26,7 @@ class Coupon extends PureComponent {
...
@@ -22,6 +26,7 @@ class Coupon extends PureComponent {
invalid
,
invalid
,
course_title
,
course_title
,
id
,
id
,
code
,
selectedCouponId
,
selectedCouponId
,
showUseButton
showUseButton
}
=
this
.
props
}
=
this
.
props
...
@@ -56,13 +61,21 @@ class Coupon extends PureComponent {
...
@@ -56,13 +61,21 @@ class Coupon extends PureComponent {
limit_course
===
0
?
'可用于大于代金券金额的课程'
:
`仅适用于《
${
course_title
}
》`
limit_course
===
0
?
'可用于大于代金券金额的课程'
:
`仅适用于《
${
course_title
}
》`
}
<
/span
>
}
<
/span
>
{
{
showUseButton
&&
showUseButton
&&
ctype
==
1
&&
<
button
<
button
className
=
'use'
className
=
'use'
onClick
=
{
this
.
GoToUse
}
onClick
=
{
this
.
GoToUse
}
>
立即使用
>
立即使用
<
/button
>
<
/button
>
}
}
{
showUseButton
&&
ctype
==
2
&&
<
button
className
=
'use'
onClick
=
{(
e
)
=>
this
.
ExchangeCourse
(
e
)}
>
立即兑换
<
/button
>
}
<
/div
>
<
/div
>
<
/li
>
<
/li
>
...
...
src/components/coupons/myCoupons/index.js
View file @
ed228052
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
'./index.scss'
import
'./index.scss'
import
RedeemBar
from
"../RedeemBar"
;
import
RedeemBar
from
"../RedeemBar"
;
import
Coupon
from
'../Coupon'
import
Coupon
from
'../Coupon'
import
{
http
,
getParam
}
from
'@/utils'
import
{
http
,
getParam
}
from
'@/utils'
import
{
WithFullSize
}
from
'@/HOCs'
import
{
WithFullSize
}
from
'@/HOCs'
import
{
Toast
}
from
'antd-mobile'
import
{
Toast
}
from
'antd-mobile'
import
{
isEmpty
}
from
'lodash'
import
{
isEmpty
}
from
'lodash'
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
@
connect
()
@
connect
()
class
UseCoupon
extends
PureComponent
{
class
UseCoupon
extends
PureComponent
{
...
@@ -19,11 +19,12 @@ class UseCoupon extends PureComponent {
...
@@ -19,11 +19,12 @@ class UseCoupon extends PureComponent {
valid_coupons
:
[],
valid_coupons
:
[],
invalid_coupons
:
[],
invalid_coupons
:
[],
courseId
:
getParam
(
'id'
),
courseId
:
getParam
(
'id'
),
showUseButton
:
false
showUseButton
:
false
,
courseCouponExchange
:
false
,
// 课程券兑换弹窗
courseCouponData
:
''
// 兑换课程信息
}
}
componentDidMount
()
{
componentDidMount
()
{
const
{
history
,
location
}
=
this
.
props
const
{
history
,
location
}
=
this
.
props
const
{
state
}
=
this
.
props
.
location
const
{
state
}
=
this
.
props
.
location
...
@@ -47,6 +48,7 @@ class UseCoupon extends PureComponent {
...
@@ -47,6 +48,7 @@ class UseCoupon extends PureComponent {
this
.
setState
({
redeemCode
:
value
})
this
.
setState
({
redeemCode
:
value
})
}
}
// 兑换
exchange
=
()
=>
{
exchange
=
()
=>
{
const
{
location
:
{
state
=
{}}}
=
this
.
props
;
const
{
location
:
{
state
=
{}}}
=
this
.
props
;
if
(
this
.
state
.
redeemCode
!==
''
)
{
if
(
this
.
state
.
redeemCode
!==
''
)
{
...
@@ -59,6 +61,13 @@ class UseCoupon extends PureComponent {
...
@@ -59,6 +61,13 @@ class UseCoupon extends PureComponent {
const
coupon
=
data
.
data
const
coupon
=
data
.
data
if
(
coupon
[
'ctype'
]
==
2
)
{
this
.
setState
({
courseCouponData
:
coupon
,
courseCouponExchange
:
true
,
redeemCode
:
''
})
}
else
{
if
(
this
.
state
.
showUseButton
)
{
if
(
this
.
state
.
showUseButton
)
{
this
.
setState
({
this
.
setState
({
couponList
:
[...
this
.
state
.
couponList
,
coupon
],
couponList
:
[...
this
.
state
.
couponList
,
coupon
],
...
@@ -67,21 +76,11 @@ class UseCoupon extends PureComponent {
...
@@ -67,21 +76,11 @@ class UseCoupon extends PureComponent {
}
else
{
}
else
{
const
coupon
=
data
.
data
const
coupon
=
data
.
data
if
(
coupon
[
'ctype'
]
==
2
&&
coupon
[
'limit_course'
]
!=
this
.
state
.
courseId
)
{
this
.
setState
({
invalid_coupons
:
[...
this
.
state
.
invalid_coupons
,
coupon
],
showUseButton
:
null
});
}
else
{
this
.
setState
({
this
.
setState
({
valid_coupons
:
[...
this
.
state
.
valid_coupons
,
coupon
],
valid_coupons
:
[...
this
.
state
.
valid_coupons
,
coupon
],
redeemCode
:
''
redeemCode
:
''
})
})
}
}
}
Toast
.
info
(
'兑换成功'
)
Toast
.
info
(
'兑换成功'
)
if
(
state
.
from
===
'/my'
)
{
if
(
state
.
from
===
'/my'
)
{
this
.
getMyCoupons
()
this
.
getMyCoupons
()
...
@@ -89,6 +88,7 @@ class UseCoupon extends PureComponent {
...
@@ -89,6 +88,7 @@ class UseCoupon extends PureComponent {
if
(
state
.
from
===
'/order'
)
{
if
(
state
.
from
===
'/order'
)
{
this
.
getAllCoupons
()
this
.
getAllCoupons
()
}
}
}
}
else
{
}
else
{
Toast
.
info
(
data
.
msg
)
Toast
.
info
(
data
.
msg
)
}
}
...
@@ -135,6 +135,24 @@ class UseCoupon extends PureComponent {
...
@@ -135,6 +135,24 @@ class UseCoupon extends PureComponent {
})
})
}
}
// 立即兑换课程
toExchangeCourse
=
(
e
,
code
)
=>
{
e
.
stopPropagation
();
http
.
post
(
`
${
API
[
'base-api'
]}
/pay/miandan/
${
code
}
`
,
{
}).
then
(
res
=>
{
const
data
=
res
.
data
if
(
data
.
errno
===
200
)
{
this
.
setState
({
courseCouponExchange
:
true
,
courseCouponData
:
res
.
data
.
data
})
this
.
getMyCoupons
()
}
else
{
Toast
.
info
(
data
.
msg
)
}
})
}
useCoupon
=
val
=>
{
useCoupon
=
val
=>
{
const
{
history
,
dispatch
}
=
this
.
props
const
{
history
,
dispatch
}
=
this
.
props
const
coupon
=
this
.
state
.
couponList
.
find
(
item
=>
item
.
id
===
val
)
const
coupon
=
this
.
state
.
couponList
.
find
(
item
=>
item
.
id
===
val
)
...
@@ -142,13 +160,11 @@ class UseCoupon extends PureComponent {
...
@@ -142,13 +160,11 @@ class UseCoupon extends PureComponent {
if
(
val
)
{
if
(
val
)
{
if
(
this
.
state
.
showUseButton
)
{
if
(
this
.
state
.
showUseButton
)
{
if
(
coupon
[
'
ctype'
]
===
1
)
{
if
(
coupon
[
'
limit_course'
]
===
0
)
{
history
.
push
(
`/classify`
)
history
.
push
(
`/classify`
)
}
else
{
}
else
{
// dispatch(getCourses(coupon['limit_course'], () => {
history
.
push
(
`/detail?id=
${
coupon
[
'limit_course'
]}
`
);
history
.
push
(
`/detail?id=
${
coupon
[
'limit_course'
]}
`
);
return
false
;
return
false
;
// }));
}
}
}
else
{
}
else
{
...
@@ -206,6 +222,26 @@ class UseCoupon extends PureComponent {
...
@@ -206,6 +222,26 @@ class UseCoupon extends PureComponent {
}
}
// 开始学习
toStudy
=
(
vCourseId
,
isHaveVideo
)
=>
{
const
{
history
}
=
this
.
props
;
if
(
isHaveVideo
==
0
)
{
Toast
.
info
(
'尚未开课,开课后立即上传课程~'
,
2
)
}
else
{
history
.
push
(
`/play/video?id=
${
vCourseId
}
`
)
}
this
.
setState
({
courseCouponExchange
:
false
})
}
// 关闭弹窗
closeFreeCourse
=
()
=>
{
this
.
setState
({
courseCouponExchange
:
false
})
}
render
()
{
render
()
{
const
{
state
}
=
this
.
props
.
location
const
{
state
}
=
this
.
props
.
location
const
{
showUseButton
,
selectedCouponId
}
=
this
.
state
const
{
showUseButton
,
selectedCouponId
}
=
this
.
state
...
@@ -227,6 +263,7 @@ class UseCoupon extends PureComponent {
...
@@ -227,6 +263,7 @@ class UseCoupon extends PureComponent {
selectedCouponId
=
{
selectedCouponId
}
selectedCouponId
=
{
selectedCouponId
}
select
=
{
this
.
select
}
select
=
{
this
.
select
}
useCoupon
=
{
this
.
useCoupon
}
useCoupon
=
{
this
.
useCoupon
}
toExchangeCourse
=
{
this
.
toExchangeCourse
}
/
>
/
>
{
{
this
.
state
.
invalid_coupons
.
length
>
0
&&
this
.
state
.
invalid_coupons
.
length
>
0
&&
...
@@ -244,6 +281,11 @@ class UseCoupon extends PureComponent {
...
@@ -244,6 +281,11 @@ class UseCoupon extends PureComponent {
)
)
}
}
<
/div
>
<
/div
>
{
this
.
state
.
courseCouponExchange
&&
<
FreeCouponCourse
toStudy
=
{
this
.
toStudy
}
closeFreeCourse
=
{
this
.
closeFreeCourse
}
courseCouponData
=
{
this
.
state
.
courseCouponData
}
/
>
}
<
/div
>
<
/div
>
);
);
}
}
...
@@ -275,4 +317,29 @@ function Content({coupons, ...rest}) {
...
@@ -275,4 +317,29 @@ function Content({coupons, ...rest}) {
)
)
}
}
function
FreeCouponCourse
(
props
)
{
const
{
toStudy
,
closeFreeCourse
,
courseCouponData
}
=
props
return
(
<
div
className
=
"free-coupon-box"
>
<
div
className
=
"free-coupon-content"
>
<
div
className
=
"coures-content-success"
><
i
className
=
{
'iconfont icondanseshixintubiao-5'
}
/></
div
>
<
div
className
=
"coures-content-title"
>
恭喜你课程兑换成功
!
赶快去学习吧
~<
/div
>
<
img
className
=
"coures-content-img"
src
=
{
courseCouponData
.
image_name
}
alt
=
""
/>
{
courseCouponData
.
course_expire
!=
0
&&
<
div
className
=
"coures-content-tip"
><
i
className
=
{
'iconfont icondanseshixintubiao-8'
}
/><span>课程有效期:自今日起{courseCouponData.course_expire}天内,请在有效期内学习该课程哦~</
span
>
<
/div
>
}
<
a
className
=
'toStudy'
onClick
=
{()
=>
toStudy
(
courseCouponData
.
v_course_id
,
courseCouponData
.
is_is_start
)}
>
去学习
<
/a
>
<
/div
>
<
div
className
=
"free-coupon-close"
>
<
i
className
=
{
'iconfont iconiconfront-2'
}
onClick
=
{()
=>
closeFreeCourse
()}
/
>
<
/div
>
<
/div
>
)
}
export
default
WithFullSize
(
UseCoupon
);
export
default
WithFullSize
(
UseCoupon
);
\ No newline at end of file
src/components/coupons/myCoupons/index.scss
View file @
ed228052
...
@@ -17,11 +17,95 @@
...
@@ -17,11 +17,95 @@
text-align
:
center
;
text-align
:
center
;
}
}
.invalid-title
{
.invalid-title
{
text-align
:
center
;
text-align
:
center
;
font-size
:
$font_12
;
font-size
:
$font_12
;
line-height
:
52px
;
line-height
:
52px
;
color
:
$color_999
;
color
:
$color_999
;
}
}
}
}
.free-coupon-box
{
position
:
fixed
;
width
:
100%
;
top
:
0
;
left
:
0
;
right
:
0
;
bottom
:
0
;
text-align
:
center
;
background
:
rgba
(
0
,
0
,
0
,.
6
);
z-index
:
11
;
.free-coupon-content
{
width
:
290px
;
border-radius
:
10px
;
background-color
:
#fff
;
padding
:
20px
;
margin
:
150px
auto
0
auto
;
.coures-content-success
{
height
:
30px
;
line-height
:
30px
;
i
{
font-size
:
34px
;
color
:
#09f
;
}
}
.coures-content-title
{
font-size
:
15px
;
color
:
#333
;
margin-top
:
10px
;
}
.coures-content-img
{
width
:
150px
;
height
:
108px
;
border-radius
:
3px
;
margin-top
:
20px
;
}
.coures-content-tip
{
color
:
#FF3131
;
font-size
:
12px
;
margin-top
:
20px
;
text-align
:
left
;
line-height
:
15px
;
height
:
30px
;
i
{
display
:
inline-block
;
color
:
#FF3131
;
font-size
:
18px
;
position
:
relative
;
top
:
6px
;
}
span
{
display
:
inline-block
;
margin-left
:
20px
;
position
:
relative
;
top
:
-15px
;
}
}
.toStudy
{
display
:
inline-block
;
width
:
138px
;
height
:
30px
;
line-height
:
30px
;
background-color
:
#09f
;
border-radius
:
15px
;
margin-top
:
20px
;
font-size
:
15px
;
color
:
#fff
;
}
}
.free-coupon-close
{
margin-top
:
30px
;
i
{
font-size
:
26px
;
color
:
#fff
;
}
}
}
}
}
\ No newline at end of file
src/components/purchased/index.js
View file @
ed228052
...
@@ -82,6 +82,10 @@ class Purchased extends Component {
...
@@ -82,6 +82,10 @@ class Purchased extends Component {
const
status
=
(
const
status
=
(
item
.
is_aist
&&
<
span
className
=
'status'
>
返现
<
/span
>
item
.
is_aist
&&
<
span
className
=
'status'
>
返现
<
/span
>
)
)
const
courseExpire
=
(
item
.
course_expire
&&
item
.
course_expire
!=
''
&&
<
span
className
=
'course-expire'
>
{
item
.
course_expire
}
<
/span
>
)
return
(
return
(
<
VList
<
VList
key
=
{
index
}
key
=
{
index
}
...
@@ -89,6 +93,7 @@ class Purchased extends Component {
...
@@ -89,6 +93,7 @@ class Purchased extends Component {
id
=
{
item
.
course_id
}
id
=
{
item
.
course_id
}
info
=
{
Info
}
info
=
{
Info
}
status
=
{
status
}
status
=
{
status
}
courseExpire
=
{
courseExpire
}
toDetail
=
{
this
.
toCourseDetail
}
toDetail
=
{
this
.
toCourseDetail
}
/
>
/
>
)
)
...
...
src/components/purchased/index.scss
View file @
ed228052
...
@@ -110,5 +110,18 @@ html, body, #root {
...
@@ -110,5 +110,18 @@ html, body, #root {
color
:
#fff
;
color
:
#fff
;
background
:
linear-gradient
(
to
bottom
,
#FF4000
,
#FD7700
);
background
:
linear-gradient
(
to
bottom
,
#FF4000
,
#FD7700
);
}
}
.course-expire
{
display
:
inline-block
;
text-align
:
center
;
position
:
absolute
;
bottom
:
10px
;
left
:
0
;
width
:
92px
;
height
:
20px
;
line-height
:
21px
;
background-color
:
#FF3A3A
;
border-radius
:
0
10px
10px
0
;
color
:
#fff
;
font-size
:
12px
;
}
}
}
\ No newline at end of file
src/components/study/myCourses/index.js
View file @
ed228052
...
@@ -152,6 +152,10 @@ class MyCourses extends Component {
...
@@ -152,6 +152,10 @@ class MyCourses extends Component {
const
status
=
(
const
status
=
(
item
.
is_aist
&&
<
span
className
=
'status'
>
返现
<
/span
>
item
.
is_aist
&&
<
span
className
=
'status'
>
返现
<
/span
>
)
)
const
courseExpire
=
(
item
.
course_expire
&&
item
.
course_expire
!=
''
&&
<
span
className
=
'course-expire'
>
{
item
.
course_expire
}
<
/span
>
)
return
(
return
(
<
VList
img
=
{
item
.
image_name
}
<
VList
img
=
{
item
.
image_name
}
handleClick
=
{
this
.
handleClick
}
handleClick
=
{
this
.
handleClick
}
...
@@ -159,6 +163,7 @@ class MyCourses extends Component {
...
@@ -159,6 +163,7 @@ class MyCourses extends Component {
key
=
{
index
}
key
=
{
index
}
info
=
{
Info
}
info
=
{
Info
}
status
=
{
status
}
status
=
{
status
}
courseExpire
=
{
courseExpire
}
id
=
{
item
[
'v_course_id'
]}
id
=
{
item
[
'v_course_id'
]}
/
>
/
>
)
)
...
...
src/components/study/myCourses/my-courses.scss
View file @
ed228052
...
@@ -150,4 +150,18 @@
...
@@ -150,4 +150,18 @@
color
:
#fff
;
color
:
#fff
;
background
:
linear-gradient
(
to
bottom
,
#FF4000
,
#FD7700
);
background
:
linear-gradient
(
to
bottom
,
#FF4000
,
#FD7700
);
}
}
.course-expire
{
display
:
inline-block
;
text-align
:
center
;
position
:
absolute
;
bottom
:
10px
;
left
:
0
;
width
:
92px
;
height
:
20px
;
line-height
:
21px
;
background-color
:
#FF3A3A
;
border-radius
:
0
10px
10px
0
;
color
:
#fff
;
font-size
:
12px
;
}
}
}
\ 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