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
967f31f1
Commit
967f31f1
authored
Oct 18, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券
parent
3f991cb0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
157 additions
and
21 deletions
+157
-21
src/components/coupons/Coupon/index.js.bak
+131
-0
src/components/coupons/myCoupons/index.js
+26
-21
No files found.
src/components/coupons/Coupon/index.js.bak
0 → 100644
View file @
967f31f1
import React, { PureComponent } from 'react'
import './coupon.scss'
import classnames from 'classnames'
class Coupon extends PureComponent {
VOUCHER = 1 //代金券
FREE = 2 //免单券
EXPAND = 4 //膨胀全
pick = () => {
let {useCoupon, invalid} = this.props
!invalid && useCoupon && useCoupon(this.props.id)
}
GoToUse = () => {
this.props.useCoupon(this.props.id)
}
ExchangeCourse = (e) => {
this.props.toExchangeCourse(e, this.props.code)
}
render() {
let {
ctype,
amount,
format_expire_time,
limit_course,
invalid,
course_title,
id,
code,
selectedCouponId,
showUseButton
} = this.props
return (
<li className='coupon' onClick={this.pick}>
<div className={classnames('coupon-info', invalid ? 'invalid' : `coupon-type${ctype}`)}>
<p className='type'>{ctype === this.VOUCHER ? '代金券' : '课程券'}</p>
{
ctype === this.VOUCHER ? <p className='denomination'>{amount} <span>元</span></p>
: <p className='course-title'>{course_title}</p>
}
<p className='expire'>有效期至:{format_expire_time}</p>
{
selectedCouponId === id &&
<i className={classnames('iconfont icondanseshixintubiao-5', {
check: !invalid
})}
/>
}
<ul>
{
new Array(19).fill('a').map((item, index) => {
return <li key={index}/>
})
}
</ul>
</div>
<div className="coupon-des">
<span className='limit'>{
limit_course === 0 ? '可用于大于代金券金额的课程' : `仅适用于《${course_title}》`
}</span>
{
showUseButton && ctype == this.VOUCHER &&
<button
className='use'
onClick={this.GoToUse}
>立即使用
</button>
}
{
showUseButton && ctype == this.FREE &&
<button
className='use'
onClick={(e) => this.ExchangeCourse(e)}
>立即兑换
</button>
}
</div>
</li>
)
}
}
function BaseCoupon(
{
pick,
ctype,
invalid,
top,
VOUCHER,
FREE,
EXPAND,
limitMessage,
bottomButton
}) {
let couponTypes = {
[VOUCHER]: '代金券',
[FREE]: '课程券',
[EXPAND]: '膨胀券'
}
return (
<li className='coupon' onClick={pick}>
<div className={classnames('coupon-info', invalid ? 'invalid' : `coupon-type${ctype}`)}>
<p className='type'>{couponTypes[ctype]}</p>
{top}
<ul>
{
new Array(19).fill('a').map((item, index) => {
return <li key={index}/>
})
}
</ul>
</div>
<div className="coupon-des">
<span className='limit'>
{limitMessage}
</span>
{bottomButton}
</div>
</li>
)
}
export default Coupon
src/components/coupons/myCoupons/index.js
View file @
967f31f1
...
@@ -140,31 +140,36 @@ class UseCoupon extends PureComponent {
...
@@ -140,31 +140,36 @@ class UseCoupon extends PureComponent {
getAllCoupons
=
()
=>
{
getAllCoupons
=
()
=>
{
Promise
.
all
([
Promise
.
all
([
http
.
post
(
`
${
API
.
home
}
/m/coupon/select`
,
{
course_id
:
this
.
state
.
courseId
}),
http
.
post
(
`
${
API
.
home
}
/m/coupon/select`
,
{
course_id
:
this
.
state
.
courseId
}),
http
.
get
(
`
${
API
.
home
}
/m/expansion`
)
http
.
get
(
`
${
API
.
home
}
/m/
coupon/
expansion`
)
]).
then
((
coupons
)
=>
{
]).
then
((
coupons
)
=>
{
const
[
selectCoupons
,
expansionCoupons
]
=
coupons
const
{
data
:
select
}
=
selectCoupons
const
{
data
:
expansion
}
=
expansionCoupons
if
(
select
.
code
===
200
)
{
const
inuse_coupon
=
select
.
data
[
'inuse_coupon'
]
this
.
setState
({
valid_coupons
:
inuse_coupon
?
[...
inuse_coupon
,
...
select
.
data
.
valid_coupons
]
:
select
.
data
.
valid_coupons
,
invalid_coupons
:
select
.
data
.
invalid_coupons
,
selectedCouponId
:
inuse_coupon
.
length
?
inuse_coupon
[
0
].
id
:
0
})
})
}
else
{
/*http.post(`${API.home}/m/coupon/select`, {course_id: this.state.courseId})
Toast
.
info
(
data
.
msg
)
.then(res => {
}
const data = res.data
if
(
expansion
.
code
==
200
)
{
if (data.code === 200) {
Array
.
isArray
(
expansion
.
data
)
&&
(
expansion
.
data
=
expansion
.
data
.
map
(
item
=>
(
item
.
ctype
=
4
,
item
)))
const inuse_coupon = data.data['inuse_coupon']
&&
(
this
.
setState
({
valid_coupons
:
this
.
state
.
valid_coupons
.
concat
(
expansion
.
data
)
}))
}
else
{
Toast
.
info
(
expansion
.
msg
)
}
this.setState({
valid_coupons: inuse_coupon
? [...inuse_coupon, ...data.data.valid_coupons]
: data.data.valid_coupons,
invalid_coupons: data.data.invalid_coupons,
selectedCouponId: inuse_coupon.length ? inuse_coupon[0].id : 0
})
} else {
})
Toast.info(data.msg)
}
})*/
// http.get(`${API.home}/m/expansion`)
}
}
// 立即兑换课程
// 立即兑换课程
...
...
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