Commit f5187301 by zhanghaozhe

大咖直播预约弹窗重复

parent 87e43860
...@@ -12,6 +12,8 @@ import { withRouter } from 'react-router-dom' ...@@ -12,6 +12,8 @@ import { withRouter } from 'react-router-dom'
@connect(state => ({user: state.user})) @connect(state => ({user: state.user}))
class Live extends Component { class Live extends Component {
popupInstance = null
state = { state = {
tabs: [], tabs: [],
lives: {}, lives: {},
...@@ -89,11 +91,11 @@ class Live extends Component { ...@@ -89,11 +91,11 @@ class Live extends Component {
saveImage = () => { saveImage = () => {
let version = getParam('version') let version = getParam('version')
version = typeof version === 'string' ? version.replace('.', '').replace('.', '').slice(0, 3) : '' version = typeof version === 'string' ? version.replace('.', '').replace('.', '').slice(0, 3) : ''
const {QRCodeUrl} = this.state; const {QRCodeUrl} = this.state
if (version && parseInt(version) < 451) { if (version && parseInt(version) < 451) {
Toast.info('当前不支持此功能,升级到最新版本app可以点击保存二维码!', 2, null, false) Toast.info('当前不支持此功能,升级到最新版本app可以点击保存二维码!', 2, null, false)
} else { } else {
SendMessageToApp('generateQRCode', QRCodeUrl); SendMessageToApp('generateQRCode', QRCodeUrl)
} }
} }
...@@ -106,26 +108,29 @@ class Live extends Component { ...@@ -106,26 +108,29 @@ class Live extends Component {
.then(res => { .then(res => {
const {data} = res const {data} = res
if (data.errno == 200) { if (data.errno == 200) {
this.setState(()=>({ this.setState(() => ({
QRCodeUrl: data.data.url, QRCodeUrl: data.data.url,
})); }))
QRCode.toDataURL(data.data.url, (err, url) => { QRCode.toDataURL(data.data.url, (err, url) => {
Popup({ if (!this.popupInstance) {
title: '扫码关注“七月在线”服务号即可预约', this.popupInstance = Popup({
content: ( title: '扫码关注“七月在线”服务号即可预约',
<> content: (
<img id={'live-qr-code'} src={url} alt=""/> <>
{ <img id={'live-qr-code'} src={url} alt=""/>
browser.isAndroidApp ? ( {
<button className={'save-image'} onClick={this.saveImage}>保存二维码</button> browser.isAndroidApp ? (
) : ( <button className={'save-image'} onClick={this.saveImage}>保存二维码</button>
null ) : null
) }
</>
} ),
</> close: () => new Promise(resolve => {
) this.popupInstance = null
}) resolve()
})
})
}
}) })
} else { } else {
Toast.info(data.msg, 2, null, false) Toast.info(data.msg, 2, null, false)
......
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