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
5b7c6e53
Commit
5b7c6e53
authored
Sep 27, 2019
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
免单券优化
parent
abc3e1e1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
src/components/coupons/myCoupons/index.js
+23
-14
No files found.
src/components/coupons/myCoupons/index.js
View file @
5b7c6e53
...
...
@@ -53,14 +53,17 @@ class UseCoupon extends PureComponent {
const
{
location
:
{
state
=
{}}}
=
this
.
props
;
if
(
this
.
state
.
redeemCode
!==
''
)
{
http
.
post
(
`
${
API
.
home
}
/m/coupon/exchange`
,
{
code
:
this
.
state
.
redeemCode
code
:
this
.
state
.
redeemCode
,
type
:
state
.
from
.
substr
(
1
)
})
.
then
(
res
=>
{
const
data
=
res
.
data
if
(
data
.
code
===
200
)
{
// 如果从我的页面进来,点击兑换直接兑换成功课程,弹出弹窗
// 如果从订单页面进来,点击兑换兑换成券
const
coupon
=
data
.
data
if
(
state
.
from
===
'/my'
)
{
if
(
coupon
[
'ctype'
]
==
2
)
{
this
.
setState
({
courseCouponData
:
coupon
,
...
...
@@ -68,27 +71,34 @@ class UseCoupon extends PureComponent {
redeemCode
:
''
})
}
else
{
if
(
this
.
state
.
showUseButton
)
{
this
.
setState
({
couponList
:
[...
this
.
state
.
couponList
,
coupon
],
redeemCode
:
''
})
}
else
{
Toast
.
info
(
'兑换成功'
)
this
.
getMyCoupons
()
}
}
if
(
state
.
from
===
'/order'
)
{
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
,
redeemCode
:
''
});
}
else
{
this
.
setState
({
valid_coupons
:
[...
this
.
state
.
valid_coupons
,
coupon
],
redeemCode
:
''
})
}
Toast
.
info
(
'兑换成功'
)
if
(
state
.
from
===
'/my'
)
{
this
.
getMyCoupons
()
}
if
(
state
.
from
===
'/order'
)
{
this
.
getAllCoupons
()
}
}
}
else
{
Toast
.
info
(
data
.
msg
)
}
...
...
@@ -136,15 +146,14 @@ class UseCoupon extends PureComponent {
}
// 立即兑换课程
toExchangeCourse
=
(
e
,
code
)
=>
{
toExchangeCourse
=
(
e
,
code
)
=>
{
e
.
stopPropagation
();
http
.
post
(
`
${
API
[
'base-api'
]}
/pay/miandan/
${
code
}
`
,
{
}).
then
(
res
=>
{
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
courseCouponData
:
res
.
data
.
data
})
this
.
getMyCoupons
()
}
else
{
...
...
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