Commit 4734a33d by xuzhenghua

pull

parents dfe9d9a2 264a3d9a
...@@ -62,8 +62,34 @@ class ReserveCourse extends Component { ...@@ -62,8 +62,34 @@ class ReserveCourse extends Component {
} }
} }
// 立即付尾款 // 立即付尾款
expandPaywk = (courseId, day) => { expandPaywk = (courseId, time,day) => {
Toast.info("付尾款时间将在" + day + "开启", 2); const {user, history} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
if (!getParam('version')) {
this.props.history.push('/passport/login')
} else {
SendMessageToApp("toLogin");
}
} else {
let timeStamp = Date.parse(new Date()) / 1000;
if (timeStamp >= time) {
if (!getParam('version')) {
this.props.history.push(
'/final-deposit-order?source=1',
{
id: courseId,
sourcenum: 1
}
)
} else {
SendMessageToApp("TailMoney");
}
} else {
Toast.info("付尾款时间将在" + day + "开启", 2);
}
}
} }
// 去学习 // 去学习
tostudy = (courseId) => { tostudy = (courseId) => {
...@@ -138,7 +164,7 @@ function CourseList(props) { ...@@ -138,7 +164,7 @@ function CourseList(props) {
{ {
item.is_buy === 1 && item.is_buy === 1 &&
<button className="to-expand-buy2" <button className="to-expand-buy2"
onClick={() => expandPaywk(item.course_id, item.final_start_time)}>立即付尾款</button> onClick={() => expandPaywk(item.course_id, item.start_timestamp,item.final_start_time)}>立即付尾款</button>
} }
{ {
item.is_buy === 2 && item.is_buy === 2 &&
......
...@@ -231,16 +231,22 @@ class CollectBlessing extends Component { ...@@ -231,16 +231,22 @@ class CollectBlessing extends Component {
<i className="collect-blessing__num">{index+1}</i> <i className="collect-blessing__num">{index+1}</i>
<p className="collect-blessing__title">{item}</p> <p className="collect-blessing__title">{item}</p>
{ {
index === 0 && (isLogin && isSign) && index === 0 &&
<a className="collect-blessing__content" data-status="done"> <>
+5<br/>福气值 {
</a> (isLogin && isSign)
} ? (
{ <a className="collect-blessing__content" data-status="done">
index === 0 && (!isLogin || !isSign) && +5<br/>福气值
<span onClick={toLogin} className="collect-blessing__content"> </a>
点击<br/>签到 )
</span> : (
<span onClick={toLogin} className="collect-blessing__content">
点击<br/>签到
</span>
)
}
</>
} }
{ {
index === 1 && index === 1 &&
...@@ -281,7 +287,9 @@ class CollectBlessing extends Component { ...@@ -281,7 +287,9 @@ class CollectBlessing extends Component {
index === 4 && index === 4 &&
<a className="collect-blessing__content" onClick={handleToShowInvite}> <a className="collect-blessing__content" onClick={handleToShowInvite}>
<span>邀请链接</span> <span>邀请链接</span>
<i>已加{inviteBlessing}</i> {
inviteBlessing > 0 && <i>已加{inviteBlessing}</i>
}
</a> </a>
} }
{ {
...@@ -290,7 +298,9 @@ class CollectBlessing extends Component { ...@@ -290,7 +298,9 @@ class CollectBlessing extends Component {
className="collect-blessing__content" className="collect-blessing__content"
onClick={toSection}> onClick={toSection}>
<span>去选课</span> <span>去选课</span>
<i>已加{buyBlessing}</i> {
buyBlessing > 0 && <i>已加{buyBlessing}</i>
}
</a> </a>
} }
</div> </div>
......
...@@ -115,6 +115,7 @@ class Live extends Component { ...@@ -115,6 +115,7 @@ class Live extends Component {
tabBarInactiveTextColor={'#FFF604'} tabBarInactiveTextColor={'#FFF604'}
tabBarUnderlineStyle={{display: 'none'}} tabBarUnderlineStyle={{display: 'none'}}
initialPage={today} initialPage={today}
swipeable={false}
> >
{ {
this.props.isFormal this.props.isFormal
......
...@@ -3,210 +3,221 @@ import './coupon.scss' ...@@ -3,210 +3,221 @@ import './coupon.scss'
import classnames from 'classnames' import classnames from 'classnames'
import { http } from "@/utils" import { http } from "@/utils"
import showAlert from '@common/deposit/end-expansion-alert' import showAlert from '@common/deposit/end-expansion-alert'
import {Toast} from 'antd-mobile' import { Toast } from 'antd-mobile'
import { withRouter } from "react-router-dom"
class Coupon extends PureComponent {
VOUCHER = 1 //代金券
FREE = 2 //免单券
EXPAND = 4 //膨胀全
class Coupon extends PureComponent {
pick = () => { VOUCHER = 1 //代金券
let {useCoupon, invalid} = this.props FREE = 2 //免单券
!invalid && useCoupon && useCoupon(this.props.id) EXPAND = 4 //膨胀全
}
GoToUse = () => { pick = (e) => {
this.props.useCoupon(this.props.id) let {useCoupon, invalid, start_amount, id, location, history, code} = this.props
const {state} = location
if(state && state.from && state.from === '/my'){
history.push(`/expand/index?deposit_code=${code}`)
return
} }
ExchangeCourse = (e) => { if (start_amount) {
this.props.toExchangeCourse(e, this.props.code) this.stopExpanding(id, e)
} else {
!invalid && useCoupon && useCoupon(this.props.id)
} }
stopExpanding = (id, e) => { }
const {amount, limit_amount} = this.props
e.stopPropagation() GoToUse = () => {
showAlert({ this.props.useCoupon(this.props.id)
amount, }
limit_amount, ExchangeCourse = (e) => {
onConfirm: () => { this.props.toExchangeCourse(e, this.props.code)
http.post(`${API.home}/m/end_expansion`, { }
id
}) stopExpanding = (id, e) => {
.then(res => { const {amount, limit_amount} = this.props
const {data} = res e.stopPropagation()
if (data.code == 200) { showAlert({
this.props.endExpansion(id) amount,
}else { limit_amount,
Toast.info(data.msg) onConfirm: () => {
} http.post(`${API.home}/m/end_expansion`, {
}) id
}
}) })
.then(res => {
const {data} = res
if (data.code == 200) {
this.props.endExpansion(id, data.data.coupon_id)
} else {
Toast.info(data.msg)
}
})
}
})
}
render() {
let {
ctype,
amount,
course_title,
showUseButton,
id,
format_expire_time,
start_amount,
limit_amount
} = this.props
let top, bottom
switch (ctype) {
case this.VOUCHER:
top = (
<>
<p className='denomination'>{amount} <span></span></p>
<p className='expire'>有效期至:{format_expire_time}</p>
</>
} )
bottom = (
<>
<span className={'limit'}>可用于大于代金券金额的课程</span>
{
showUseButton && ctype == this.VOUCHER &&
<button
className='use'
onClick={this.GoToUse}
>立即使用
</button>
}
</>
)
break
case this.FREE:
top = (
<>
<p className='course-title'>{course_title}</p>
<p className='expire'>有效期至:{format_expire_time}</p>
</>
)
bottom = (
<>
<span className={'limit'}>{`仅适用于《${course_title}》`}</span>
{
showUseButton && ctype == this.FREE &&
<button
className='use'
onClick={(e) => this.ExchangeCourse(e)}
>立即兑换
</button>
}
</>
render() { )
let { break
ctype, case this.EXPAND:
amount, if (!start_amount) {
course_title, top = (
showUseButton, <>
id, <p className='denomination'>{amount} <span></span></p>
format_expire_time, <p className='expire'>有效期至:{format_expire_time}</p>
start_amount, </>
limit_amount )
} = this.props
} else {
let top, bottom top = (
<>
switch (ctype) { <div className="progress-container">
case this.VOUCHER: <p className='denomination'>{amount} <span></span></p>
top = ( <div className={'progress-bar-container'}>
<>
<p className='denomination'>{amount} <span></span></p>
<p className='expire'>有效期至:{format_expire_time}</p>
</>
)
bottom = (
<>
<span className={'limit'}>可用于大于代金券金额的课程</span>
{
showUseButton && ctype == this.VOUCHER &&
<button
className='use'
onClick={this.GoToUse}
>立即使用
</button>
}
</>
)
break
case this.FREE:
top = (
<>
<p className='course-title'>{course_title}</p>
<p className='expire'>有效期至:{format_expire_time}</p>
</>
)
bottom = (
<>
<span className={'limit'}>{`仅适用于《${course_title}》`}</span>
{
showUseButton && ctype == this.FREE &&
<button
className='use'
onClick={(e) => this.ExchangeCourse(e)}
>立即兑换
</button>
}
</>
)
break
case this.EXPAND:
if (!start_amount) {
top = (
<>
<p className='denomination'>{amount} <span></span></p>
<p className='expire'>有效期至:{format_expire_time}</p>
</>
)
} else {
top = (
<>
<div className="progress-container">
<p className='denomination'>{amount} <span></span></p>
<div className={'progress-bar-container'}>
<span className={'progress-bar'} <span className={'progress-bar'}
style={{width: `${Math.round((amount - start_amount) / limit_amount * 100)}%`}} style={{width: `${Math.round((amount - start_amount) / limit_amount * 100)}%`}}
></span> ></span>
</div> </div>
<div className={'money'}> <div className={'money'}>
<span>{start_amount}</span> <span>{start_amount}</span>
<span>{limit_amount}</span> <span>{limit_amount}</span>
</div> </div>
</div> </div>
</> </>
) )
}
bottom = (
<>
<span className={'limit'}>全场通用</span>
{
start_amount
&& <button className='stop-expanding'
onClick={this.stopExpanding.bind(this, id)}>立即结束膨胀</button>
}
</>
)
break
} }
bottom = (
<>
<span className={'limit'}>全场通用</span>
{
start_amount
&& <button className='stop-expanding'
onClick={this.stopExpanding.bind(this, id)}>立即结束膨胀</button>
}
</>
return (
<BaseCoupon
{...this.props}
top={top}
VOUCHER={this.VOUCHER}
FREE={this.FREE}
EXPAND={this.EXPAND}
pick={this.pick}
bottom={bottom}
/>
) )
break
} }
}
function BaseCoupon(
{
pick,
ctype,
invalid,
top,
VOUCHER,
FREE,
EXPAND,
selectedCouponId,
id,
bottom
}) {
let couponTypes = {
[VOUCHER]: '代金券',
[FREE]: '课程券',
[EXPAND]: '膨胀券'
}
return ( return (
<li className='coupon' onClick={pick}> <BaseCoupon
<div className={classnames('coupon-info', invalid ? 'invalid' : `coupon-type${ctype}`)}> {...this.props}
<p className='type'>{couponTypes[ctype]}</p> top={top}
{top} VOUCHER={this.VOUCHER}
{ FREE={this.FREE}
selectedCouponId === id && EXPAND={this.EXPAND}
<i className={classnames('iconfont icondanseshixintubiao-5', { pick={this.pick}
check: !invalid bottom={bottom}
})} />
/>
}
<ul>
{
new Array(19).fill('a').map((item, index) => {
return <li key={index}/>
})
}
</ul>
</div>
<div className="coupon-des">
{bottom}
</div>
</li>
) )
}
}
function BaseCoupon(
{
pick,
ctype,
invalid,
top,
VOUCHER,
FREE,
EXPAND,
selectedCouponId,
id,
bottom
}) {
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}
{
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">
{bottom}
</div>
</li>
)
} }
export default Coupon export default withRouter(Coupon)
...@@ -6,389 +6,388 @@ import Coupon from '../Coupon' ...@@ -6,389 +6,388 @@ 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 { connect } from 'react-redux' import { connect } from 'react-redux'
@connect() @connect()
class UseCoupon extends PureComponent { class UseCoupon extends PureComponent {
state = { state = {
selectedCouponId: 0, selectedCouponId: 0,
redeemCode: '', redeemCode: '',
couponList: [], couponList: [],
valid_coupons: [], valid_coupons: [],
invalid_coupons: [], invalid_coupons: [],
courseId: getParam('id'), courseId: getParam('id'),
showUseButton: false, showUseButton: false,
courseCouponExchange: false, // 课程券兑换弹窗 courseCouponExchange: false, // 课程券兑换弹窗
courseCouponData: '' // 兑换课程信息 courseCouponData: '' // 兑换课程信息
}
componentDidMount() {
const {history, location} = this.props
const {state} = this.props.location
if (state && state.from) {
if (state.from === '/my') {
this.getMyCoupons()
this.setState({
showUseButton: true
})
} else {
if (!this.state.courseId) {
location.state && location.state.from ? history.replace(location.state.from) : history.goBack()
}
this.getAllCoupons()
}
} }
}
handleChange = e => {
let value = e ? e.target.value : ''
this.setState({redeemCode: value})
}
// 兑换
exchange = () => {
const {location: {state = {}}} = this.props
if (this.state.redeemCode !== '') {
http.post(`${API.home}/m/coupon/exchange`, {
code: this.state.redeemCode,
type: state.from.substr(1)
})
.then(res => {
const data = res.data
if (data.code === 200) {
// 如果从我的页面进来,点击兑换直接兑换成功课程,弹出弹窗
// 如果从订单页面进来,点击兑换兑换成券
const coupon = data.data
componentDidMount() {
const {history, location} = this.props
const {state} = this.props.location
if (state && state.from) {
if (state.from === '/my') { if (state.from === '/my') {
this.getMyCoupons() if (coupon['ctype'] == 2) {
this.setState({ this.setState({
showUseButton: true courseCouponData: coupon,
courseCouponExchange: true,
redeemCode: ''
}) })
} else { } else {
if (!this.state.courseId) { this.setState({
location.state && location.state.from ? history.replace(location.state.from) : history.goBack() couponList: [...this.state.couponList, coupon],
} redeemCode: ''
this.getAllCoupons()
}
}
}
handleChange = e => {
let value = e ? e.target.value : ''
this.setState({redeemCode: value})
}
// 兑换
exchange = () => {
const {location: {state = {}}} = this.props
if (this.state.redeemCode !== '') {
http.post(`${API.home}/m/coupon/exchange`, {
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,
courseCouponExchange: true,
redeemCode: ''
})
} else {
this.setState({
couponList: [...this.state.couponList, coupon],
redeemCode: ''
})
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('兑换成功')
this.getAllCoupons()
}
} else {
Toast.info(data.msg)
}
}) })
} else { Toast.info('兑换成功')
Toast.info('请输入兑换码') this.getMyCoupons()
} }
}
getMyCoupons = () => {
Promise.all([
http.get(`${API.home}/m/coupon/all`),
http.get(`${API.home}/m/coupon/expansion`)
]).then((coupons) => {
let myCoupons = []
const [allCoupons, expansionCoupons] = coupons
const {data: all} = allCoupons
const {data: expansion} = expansionCoupons
if (all.code == 200) {
Array.isArray(all.data) && (myCoupons = myCoupons.concat(all.data))
} else {
Toast.info(all.msg)
}
if (expansion.code == 200) {
Array.isArray(expansion.data)
&& (expansion.data = expansion.data.map(item => (item.ctype = 4, item)))
&& (myCoupons = myCoupons.concat(expansion.data))
} else {
Toast.info(expansion.msg)
} }
if (state.from === '/order') {
const coupon = data.data
this.setState({ if (coupon['ctype'] == 2
couponList: myCoupons && coupon['limit_course'] != this.state.courseId) {
})
})
}
getAllCoupons = () => {
Promise.all([
http.post(`${API.home}/m/coupon/select`, {course_id: this.state.courseId}),
http.get(`${API.home}/m/coupon/expansion`)
]).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({ this.setState({
valid_coupons: inuse_coupon invalid_coupons: [...this.state.invalid_coupons, coupon],
? [...inuse_coupon, ...select.data.valid_coupons] showUseButton: null,
: select.data.valid_coupons, redeemCode: ''
invalid_coupons: select.data.invalid_coupons,
selectedCouponId: inuse_coupon.length ? inuse_coupon[0].id : 0
}) })
} else {
} else {
Toast.info(data.msg)
}
if (expansion.code == 200) {
Array.isArray(expansion.data)
&& (expansion.data = expansion.data.map(item => (item.ctype = 4, item)))
&& (this.setState({
valid_coupons: this.state.valid_coupons.concat(expansion.data)
}))
} else {
Toast.info(expansion.msg)
}
})
}
// 立即兑换课程
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({ this.setState({
courseCouponExchange: true, valid_coupons: [...this.state.valid_coupons, coupon],
courseCouponData: res.data.data redeemCode: ''
}) })
this.getMyCoupons() }
} else { Toast.info('兑换成功')
Toast.info(data.msg) this.getAllCoupons()
} }
} else {
Toast.info(data.msg)
}
}) })
} else {
Toast.info('请输入兑换码')
} }
}
getMyCoupons = () => {
Promise.all([
http.get(`${API.home}/m/coupon/expansion`),
http.get(`${API.home}/m/coupon/all`)
]).then((coupons) => {
let myCoupons = []
const [expansionCoupons, allCoupons] = coupons
const {data: all} = allCoupons
const {data: expansion} = expansionCoupons
if (expansion.code == 200) {
Array.isArray(expansion.data)
&& (expansion.data = expansion.data.map(item => (item.ctype = 4, item)))
&& (myCoupons = myCoupons.concat(expansion.data))
} else {
Toast.info(expansion.msg)
}
if (all.code == 200) {
Array.isArray(all.data) && (myCoupons = myCoupons.concat(all.data))
} else {
Toast.info(all.msg)
}
this.setState({
couponList: myCoupons
})
})
}
getAllCoupons = () => {
Promise.all([
http.get(`${API.home}/m/coupon/expansion`),
http.post(`${API.home}/m/coupon/select`, {course_id: this.state.courseId})
]).then((coupons) => {
const [expansionCoupons, selectCoupons] = coupons
const {data: select} = selectCoupons
const {data: expansion} = expansionCoupons
if (expansion.code == 200) {
Array.isArray(expansion.data)
&& (expansion.data = expansion.data.map(item => (item.ctype = 4, item)))
&& (this.setState({
valid_coupons: this.state.valid_coupons.concat(expansion.data)
}))
} else {
Toast.info(expansion.msg)
}
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
})
useCoupon = val => { } else {
const {history} = this.props Toast.info(data.msg)
const coupon = this.state.couponList.find(item => item.id === val) }
if (val) {
if (this.state.showUseButton) {
if (coupon['limit_course'] === 0) {
history.push(`/classify`)
} else {
history.push(`/detail?id=${coupon['limit_course']}`)
return false
}
} else {
const {courseId, selectedCouponId} = this.state })
}
if (selectedCouponId === val) { // 立即兑换课程
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 => {
const {history} = this.props
const coupon = this.state.couponList.find(item => item.id === val)
if (val) {
if (this.state.showUseButton) {
if (coupon['limit_course'] === 0) {
history.push(`/classify`)
} else {
history.push(`/detail?id=${coupon['limit_course']}`)
return false
}
} else {
http.post(`${API.home}/m/coupon/cancel`, { const {courseId, selectedCouponId} = this.state
course_id: courseId
}).then(res => {
const data = res.data
if (data.code === 200) {
if (selectedCouponId === val) {
this.setState({
selectedCouponId: 0
})
http.post(`${API.home}/m/coupon/cancel`, {
course_id: courseId
}).then(res => {
const data = res.data
if (data.code === 200) {
} else {
Toast.info(data.msg)
}
})
this.setState({
selectedCouponId: 0
})
} else {
http.post(`${API.home}/m/coupon/use`, {
course_id: this.state.courseId,
coupon_id: val
})
.then(res => {
const data = res && res.data
if (data.code === 200) {
this.setState({selectedCouponId: val}) } else {
this.props.history.goBack() Toast.info(data.msg)
}
})
} else { } else {
Toast.info(data.msg) http.post(`${API.home}/m/coupon/use`, {
} course_id: this.state.courseId,
}) coupon_id: val
})
.then(res => {
const data = res && res.data
if (data.code === 200) {
} this.setState({selectedCouponId: val})
this.props.history.goBack()
} } else {
Toast.info(data.msg)
}
})
} else {
Toast.info('未知错误')
location.reload()
} }
}
// 开始学习 }
toStudy = (vCourseId, isHaveVideo) => {
const {history} = this.props
if (isHaveVideo == 0) {
Toast.info('尚未开课,开课后立即上传课程~', 2)
} else {
history.push(`/play/video?id=${vCourseId}`)
}
this.setState({
courseCouponExchange: false
})
}
// 关闭弹窗 } else {
closeFreeCourse = () => { Toast.info('未知错误')
this.setState({ location.reload()
courseCouponExchange: false
})
} }
endExpansion = id => { }
this.setState({
couponList: this.state.couponList.map(item => { // 开始学习
if (item.id === id) { toStudy = (vCourseId, isHaveVideo) => {
delete item.start_amount const {history} = this.props
} if (isHaveVideo == 0) {
return item Toast.info('尚未开课,开课后立即上传课程~', 2)
}) } else {
}) history.push(`/play/video?id=${vCourseId}`)
} }
this.setState({
courseCouponExchange: false
})
}
// 关闭弹窗
closeFreeCourse = () => {
this.setState({
courseCouponExchange: false
})
}
endExpansion = (id, validId) => {
this.setState({
valid_coupons: this.state.valid_coupons.map(item => {
if (item.id === id) {
delete item.start_amount
item.id = validId
}
return item
})
})
}
render() { render() {
const {state} = this.props.location const {state} = this.props.location
const {showUseButton, selectedCouponId} = this.state const {showUseButton, selectedCouponId} = this.state
return ( return (
<div className='use-coupon'> <div className='use-coupon'>
<RedeemBar onChange={this.handleChange} <RedeemBar onChange={this.handleChange}
exchange={this.exchange} exchange={this.exchange}
redeemCode={this.state.redeemCode}/> redeemCode={this.state.redeemCode}/>
<div className="coupons-area"> <div className="coupons-area">
<Content <Content
coupons={ coupons={
state state
&& state.from && state.from
&& state.from === '/my' && state.from === '/my'
? this.state.couponList ? this.state.couponList
: this.state.valid_coupons : this.state.valid_coupons
} }
showUseButton={showUseButton} showUseButton={showUseButton}
selectedCouponId={selectedCouponId} selectedCouponId={selectedCouponId}
select={this.select} select={this.select}
useCoupon={this.useCoupon} useCoupon={this.useCoupon}
toExchangeCourse={this.toExchangeCourse} toExchangeCourse={this.toExchangeCourse}
endExpansion={this.endExpansion} endExpansion={this.endExpansion}
/> />
{ {
this.state.invalid_coupons.length > 0 && this.state.invalid_coupons.length > 0 &&
( (
<> <>
<div className='invalid-title'>- 不可使用的优惠券 -</div> <div className='invalid-title'>- 不可使用的优惠券 -</div>
<Content <Content
coupons={this.state.invalid_coupons} coupons={this.state.invalid_coupons}
selectedCouponId={selectedCouponId} selectedCouponId={selectedCouponId}
select={this.select} select={this.select}
purpose={'use'} purpose={'use'}
invalid={'invalid'} invalid={'invalid'}
/> />
</> </>
) )
} }
</div> </div>
{ {
this.state.courseCouponExchange && this.state.courseCouponExchange &&
<FreeCouponCourse toStudy={this.toStudy} closeFreeCourse={this.closeFreeCourse} <FreeCouponCourse toStudy={this.toStudy} closeFreeCourse={this.closeFreeCourse}
courseCouponData={this.state.courseCouponData}/> courseCouponData={this.state.courseCouponData}/>
} }
</div> </div>
) )
} }
} }
function Content({coupons, ...rest}) { function Content({coupons, ...rest}) {
if (coupons.length === 0) { if (coupons.length === 0) {
return (
<div className='empty'>
<p>暂无可使用的优惠券</p>
</div>
)
}
return ( return (
<ul> <div className='empty'>
{ <p>暂无可使用的优惠券</p>
coupons.map(item => { </div>
return (
<Coupon
key={item.id}
{...item}
id={item.id}
{...rest}
/>
)
})
}
</ul>
) )
}
return (
<ul>
{
coupons.map(item => {
return (
<Coupon
key={item.id}
{...item}
id={item.id}
{...rest}
/>
)
})
}
</ul>
)
} }
function FreeCouponCourse(props) { function FreeCouponCourse(props) {
const {toStudy, closeFreeCourse, courseCouponData} = props const {toStudy, closeFreeCourse, courseCouponData} = props
return ( return (
<div className="free-coupon-box"> <div className="free-coupon-box">
<div className="free-coupon-content"> <div className="free-coupon-content">
<div className="coures-content-success"><i className={'iconfont icondanseshixintubiao-5'}/></div> <div className="coures-content-success"><i className={'iconfont icondanseshixintubiao-5'}/></div>
<div className="coures-content-title">恭喜你课程兑换成功!赶快去学习吧~</div> <div className="coures-content-title">恭喜你课程兑换成功!赶快去学习吧~</div>
<img className="coures-content-img" src={courseCouponData.image_name} alt=""/> <img className="coures-content-img" src={courseCouponData.image_name} alt=""/>
{ {
courseCouponData.course_expire != 0 && courseCouponData.course_expire != 0 &&
<div className="coures-content-tip"><i <div className="coures-content-tip"><i
className={'iconfont icondanseshixintubiao-8'}/><span>课程有效期:自今日起{courseCouponData.course_expire}天内,请在有效期内学习该课程哦~</span> className={'iconfont icondanseshixintubiao-8'}/><span>课程有效期:自今日起{courseCouponData.course_expire}天内,请在有效期内学习该课程哦~</span>
</div> </div>
} }
<a className='toStudy' <a className='toStudy'
onClick={() => toStudy(courseCouponData.v_course_id, courseCouponData.is_is_start)}>去学习</a> onClick={() => toStudy(courseCouponData.v_course_id, courseCouponData.is_is_start)}>去学习</a>
</div> </div>
<div className="free-coupon-close"> <div className="free-coupon-close">
<i className={'iconfont iconiconfront-2'} onClick={() => closeFreeCourse()}/> <i className={'iconfont iconiconfront-2'} onClick={() => closeFreeCourse()}/>
</div> </div>
</div> </div>
) )
} }
export default WithFullSize(UseCoupon) export default WithFullSize(UseCoupon)
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
font-size: 14px; font-size: 14px;
color: $color_666; color: $color_666;
margin-top: 10px; margin-top: 10px;
line-height: 16px;
} }
.des { .des {
......
...@@ -164,8 +164,7 @@ class ExpandShare extends Component { ...@@ -164,8 +164,7 @@ class ExpandShare extends Component {
step: 2, step: 2,
helpData: data helpData: data
}) })
this.getListorData()
console.log(data)
} else if (errno === 17018 || errno === 17020) { } else if (errno === 17018 || errno === 17020) {
this.setState({ this.setState({
isShow: true, isShow: true,
......
...@@ -569,6 +569,7 @@ ...@@ -569,6 +569,7 @@
color: #fff; color: #fff;
font-size: 15px; font-size: 15px;
margin-top: 20px; margin-top: 20px;
border: none;
} }
} }
...@@ -596,6 +597,7 @@ ...@@ -596,6 +597,7 @@
border-radius: 17px; border-radius: 17px;
color: #fff; color: #fff;
font-size: 15px; font-size: 15px;
border: none;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment