Commit 93d8d984 by xuzhenghua

detail

parent e85cbfb3
......@@ -12,13 +12,15 @@ class Single extends Component {
constructor(props) {
super(props)
this.state = {
status: 3,
status: 1,
orderId: '',
nowPrice: '',
laterPrice: '',
hour: '',
min: '',
sec: '',
endTime: '',
groupOrderId: '',
payType: '0', // 1支付宝 0微信
}
}
......@@ -169,11 +171,55 @@ class Single extends Component {
}
// 0元参团
zerogroupBuy = () => {
this.setState({
status: 7
this.getOrderId()
}
// 获取订单号-0元参团
getOrderId = () => {
let data = {
course_id: getParam('id')
}
http.post(`${api['pay-api']}/pdd/sys`, data).then((res) => {
if (res.data.errno === 0) {
this.setState({
groupOrderId: res.data.data.order_id
})
this.getOrderStatus(res.data.data.order_id)
} else {
Toast.info(res.data.msg, 2)
}
})
}
// 获取订单状态-0元参团
getOrderStatus = (id) => {
http.get(`${api.home}/m/pdd/order_status/${id}`).then((res) => {
if (res.data.code === 200) {
this.getTime(res.data.data.pdd_order_id)
} else {
Toast.info(res.data.msg, 2)
}
})
}
// 获取倒计时-0元参团
getTime = (id) => {
http.get(`${api.home}/m/pdd_order_end_time/${id}`).then((res) => {
if (res.data.code === 200) {
this.setState({
endTime: res.data.data.end_time,
status: 7
})
} else {
Toast.info(res.data.msg, 2)
}
})
}
// 邀请好友参团
toGroup = () => {
this.props.history.push(`/togroup?id=${this.state.groupOrderId}`)
}
// 关闭弹窗
colse = () => {
this.props.boxHide(false);
......@@ -183,24 +229,21 @@ class Single extends Component {
}
render() {
// if (this.state.bargainData.expire_time) {
let date = 1561140170*1000
let now = Date.now()
setInterval(() => {
date -= 1000
let s = differenceInSeconds(new Date(date), now) % 60,
m = differenceInMinutes(new Date(date), now) % 60,
h = differenceInHours(new Date(date), now) % 24
this.setState({
hour: h,
min: m,
sec: s,
})
}, 1000)
// }
if (this.state.endTime) {
let date = this.state.endTime * 1000
let now = Date.now()
setInterval(() => {
date -= 1000
let s = differenceInSeconds(new Date(date), now) % 60,
m = differenceInMinutes(new Date(date), now) % 60,
h = differenceInHours(new Date(date), now) % 24
this.setState({
hour: h,
min: m,
sec: s,
})
}, 1000)
}
return (
<div>
......@@ -305,7 +348,7 @@ class Single extends Component {
alt=""/>
</div>
<div className='btn-l btn-FF4000'>
<div className='btn-l btn-FF4000' onClick={this.toGroup}>
剩余{String(this.state.hour).padStart(2, 0)}{String(this.state.min).padStart(2, 0)}{String(this.state.sec).padStart(2, 0)}
邀请好友参团
</div>
......
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