Commit 75adef29 by zhanghaozhe

抽奖预约

parent 5909e197
...@@ -34,35 +34,35 @@ class FormalDraw extends Component { ...@@ -34,35 +34,35 @@ class FormalDraw extends Component {
} }
shouldComponentUpdate(nextProps, nextState, nextContext) { shouldComponentUpdate(nextProps, nextState, nextContext) {
if(this.props.isApp !== nextProps.isApp) { if (this.props.isApp !== nextProps.isApp) {
this.getPrizeData() this.getPrizeData()
return false; return false
} }
return true; return true
} }
getPrizeData = () => { getPrizeData = () => {
http.get(`${API.home}/sys/activity/prize_data`) http.get(`${API.home}/sys/activity/prize_data`)
.then(res => { .then(res => {
const {data, code, msg} = res.data const {data, code, msg} = res.data
if (code == 200) { if (code == 200) {
const {today} = data.value const {today} = data.value
const oneDay = data.list.filter(item => item.date === data.value.today) const oneDay = data.list.filter(item => item.date === data.value.today)
const activeIndex = oneDay[0]['son'].findIndex(item => item.status == 3) const activeIndex = oneDay[0]['son'].findIndex(item => item.status == 3)
this.setState({ this.setState({
tabs: data.list.map(item => ({title: item.date})), tabs: data.list.map(item => ({title: item.date})),
today, today,
initialPageIndex: data.list.findIndex(item => item.date == today) || 0, initialPageIndex: data.list.findIndex(item => item.date == today) || 0,
list: data.list, list: data.list,
userValue: data.value, userValue: data.value,
activeTimeRangeIndex: activeIndex < 0 ? 0 : activeIndex activeTimeRangeIndex: activeIndex < 0 ? 0 : activeIndex
}, () => { }, () => {
this.initializeSwiper() this.initializeSwiper()
}) })
} else { } else {
Toast.info(msg, 2, null, false) Toast.info(msg, 2, null, false)
} }
}) })
} }
initializeSwiper = () => { initializeSwiper = () => {
...@@ -161,25 +161,40 @@ class FormalDraw extends Component { ...@@ -161,25 +161,40 @@ class FormalDraw extends Component {
if (this.subscribePopupInstance) { if (this.subscribePopupInstance) {
return return
} }
http.get(`${API["base-api"]}/sys/activity/create_pre_qrcode`,{params:{id}}) if (!this.state.userValue['is_pre']) {
.then(res => { http.get(`${API["base-api"]}/sys/activity/create_pre_qrcode`, {params: {id}})
const {code, data, msg} = res.data .then(res => {
if (code == 200) { const {code, data, msg} = res.data
this.subscribePopupInstance = QRCode.toDataURL(data.url, (err, url) => { if (code == 200) {
Popup({ this.subscribePopupInstance = QRCode.toDataURL(data.url, (err, url) => {
title: '微信扫码“七月在线”服务号即可预约', Popup({
className: 'subscribe', title: '微信扫码“七月在线”服务号即可预约',
content: <img src={url} alt="" className="qr-code"/>, className: 'subscribe',
close: () => new Promise(resolve => { content: <img src={url} alt="" className="qr-code"/>,
this.subscribePopupInstance = null close: () => new Promise(resolve => {
resolve() this.subscribePopupInstance = null
resolve()
})
}) })
}) })
}) } else {
} else { Toast.info(msg, 2, null, false)
Toast.info(msg, 2, null, false) }
} })
}) } else {
http.get(`${API["base-api"]}/activity_pre/${id}`)
.then(res => {
const {code} = res.data
if (code == 200) {
Toast.info('预约成功', 2, null, false)
}
})
.catch(err => {
console.log(err)
})
}
} }
render() { render() {
......
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