Commit ffd2edad by wangshuo

Merge branch '11-11' of gitlab.julyedu.com:baiguangyao/mr-julyedu into 11-11

parents 685cdb40 b04ec87d
...@@ -404,7 +404,7 @@ class BlessingPreheat extends Component { ...@@ -404,7 +404,7 @@ class BlessingPreheat extends Component {
<RankList></RankList> <RankList></RankList>
<Live></Live> <Live isFormal={isFormal}></Live>
</div> </div>
) )
} }
......
import React, { Component } from 'react' import React, { Component } from 'react'
import './index.scss' import './index.scss'
import { Tabs, Toast } from "antd-mobile" import { Tabs, Toast } from "antd-mobile"
import { http } from "@/utils" import { getParam, http, SendMessageToApp } from "@/utils"
import { Popup } from "@common/index" import { Popup } from "@common/index"
import QRCode from 'qrcode' import QRCode from 'qrcode'
import { uniqBy } from 'lodash' import { uniqBy } from 'lodash'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
const isFormal = false
@connect(state => ({user: state.user}))
class Live extends Component { class Live extends Component {
state = { state = {
...@@ -16,7 +18,8 @@ class Live extends Component { ...@@ -16,7 +18,8 @@ class Live extends Component {
preheatLives: [], preheatLives: [],
visible: false, visible: false,
qrcode: '', qrcode: '',
today: '' today: '',
isApp: getParam('version')
} }
...@@ -36,7 +39,7 @@ class Live extends Component { ...@@ -36,7 +39,7 @@ class Live extends Component {
}, {}) }, {})
let tabs, today let tabs, today
if (isFormal) { if (this.props.isFormal) {
tabs = Object.keys(lives).map(item => ({title: item})) tabs = Object.keys(lives).map(item => ({title: item}))
today = uniqBy(data.data['data_active'], value => value.date).findIndex(item => item['is_today']) today = uniqBy(data.data['data_active'], value => value.date).findIndex(item => item['is_today'])
} else { } else {
...@@ -59,7 +62,19 @@ class Live extends Component { ...@@ -59,7 +62,19 @@ class Live extends Component {
}) })
} }
toLiveRoom = id => {
if (this.state.isApp) {
SendMessageToApp('toLiveRoom', id)
} else {
window.location.href = `${window.location.protocol}//www.julyedu.com/live/m_room/${id}`
}
}
makeSubscribe = id => { makeSubscribe = id => {
const {user, history} = this.props
if (user.hasError) {
history.push('/passport/login')
}
http.get(`${API.home}/sys/createLiveQrcode/${id}`) http.get(`${API.home}/sys/createLiveQrcode/${id}`)
.then(res => { .then(res => {
const {data} = res const {data} = res
...@@ -102,7 +117,7 @@ class Live extends Component { ...@@ -102,7 +117,7 @@ class Live extends Component {
initialPage={today} initialPage={today}
> >
{ {
isFormal this.props.isFormal
? tabs.map((item, index) => { ? tabs.map((item, index) => {
const todayLives = lives[item.title] const todayLives = lives[item.title]
return ( return (
...@@ -172,7 +187,7 @@ function LiveContent({item, makeSubscribe}) { ...@@ -172,7 +187,7 @@ function LiveContent({item, makeSubscribe}) {
</div> </div>
{ {
item['on_live'] item['on_live']
? <button className={'on-living'}>正在直播</button> ? <button className={'on-living'} onClick={this.toLiveRoom.bind(this, item['live_id'])}>正在直播</button>
: :
item['is_subscribe'] item['is_subscribe']
? <button className={'subscribed'}>已预约</button> ? <button className={'subscribed'}>已预约</button>
...@@ -183,4 +198,4 @@ function LiveContent({item, makeSubscribe}) { ...@@ -183,4 +198,4 @@ function LiveContent({item, makeSubscribe}) {
) )
} }
export default Live export default withRouter(Live)
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