Commit 6c7b4f9e by zhanghaozhe

大咖直播

parent d3982e50
...@@ -16,9 +16,9 @@ class Live extends Component { ...@@ -16,9 +16,9 @@ class Live extends Component {
state = { state = {
tabs: [], tabs: [],
lives: {}, lives: [],
preheatLives: [], preheatLives: [],
today: '', todayIndex: '',
isApp: getParam('version'), isApp: getParam('version'),
QRCodeUrl: '', QRCodeUrl: '',
} }
...@@ -27,45 +27,20 @@ class Live extends Component { ...@@ -27,45 +27,20 @@ class Live extends Component {
componentDidMount() { componentDidMount() {
http.get(`${API.home}/sys/get_live_info`) http.get(`${API.home}/sys/get_live_info`)
.then(res => { .then(res => {
const {data} = res const {data, code, msg} = res.data
if (data.code == 200) { if (code == 200) {
let tabs = uniqBy(data, item => item.date)
const lives = data.data['data_active'].reduce((accu, current) => { tabs = tabs.map(item => ({title: item.date}))
if (!(current.date in accu)) { let todayIndex = data.findIndex(item => item['is_today'])
accu[current.date] = [current]
} else {
accu[current.date].push(current)
}
return accu
}, {})
const preheatLives = data.data['data_hot'].reduce((accu, current) => {
if (!(current.date in accu)) {
accu[current.date] = [current]
} else {
accu[current.date].push(current)
}
return accu
}, {})
let tabs, today
if (this.props.isFormal) {
tabs = Object.keys(lives).map(item => ({title: item}))
today = uniqBy(data.data['data_active'], value => value.date).findIndex(item => item['is_today'])
} else {
tabs = Object.keys(preheatLives).map(item => ({title: item}))
today = uniqBy(data.data['data_hot'], value => value.date).findIndex(item => item['is_today'])
}
this.setState({ this.setState({
tabs, tabs,
lives, lives: data,
today, todayIndex: todayIndex < 0 ? 0 : todayIndex,
preheatLives
}) })
} else { } else {
Toast.info(data.msg, 2, null, false) Toast.info(msg, 2, null, false)
} }
}) })
...@@ -73,9 +48,9 @@ class Live extends Component { ...@@ -73,9 +48,9 @@ class Live extends Component {
toLiveRoom = id => { toLiveRoom = id => {
const {history, isLogin} = this.props const {history, isLogin} = this.props
var _czc = _czc || []; var _czc = _czc || []
var name = '直播间id=' + id; var name = '直播间id=' + id
_czc.push(["_trackEvent", name, 'm端双十一大咖直播-正在直播']); _czc.push(["_trackEvent", name, 'm端双十一大咖直播-正在直播'])
if (this.state.isApp) { if (this.state.isApp) {
if (isLogin) { if (isLogin) {
SendMessageToApp('toLiveRoom', id) SendMessageToApp('toLiveRoom', id)
...@@ -108,8 +83,8 @@ class Live extends Component { ...@@ -108,8 +83,8 @@ class Live extends Component {
history.push('/passport/login') history.push('/passport/login')
} }
var name = '直播间id=' + id; var name = '直播间id=' + id
_czc.push(["_trackEvent", name, 'm端双十一大咖直播-立即预约']); _czc.push(["_trackEvent", name, 'm端双十一大咖直播-立即预约'])
http.get(`${API['base-api']}/sys/createLiveQrcode/${id}`) http.get(`${API['base-api']}/sys/createLiveQrcode/${id}`)
.then(res => { .then(res => {
...@@ -146,7 +121,7 @@ class Live extends Component { ...@@ -146,7 +121,7 @@ class Live extends Component {
} }
render() { render() {
const {tabs, lives, preheatLives, today} = this.state const {tabs, lives, today} = this.state
return ( return (
<div id={'live'}> <div id={'live'}>
<div className="title"> <div className="title">
...@@ -167,24 +142,8 @@ class Live extends Component { ...@@ -167,24 +142,8 @@ class Live extends Component {
swipeable={false} swipeable={false}
> >
{ {
this.props.isFormal tabs.map((item, index) => {
? tabs.map((item, index) => { const todayLives = lives.filter(liveItem => liveItem.date === item.title)
const todayLives = lives[item.title]
return (
<div key={index}>
{
todayLives && todayLives.map((item, index) => {
return (
<LiveContent item={item} key={index} makeSubscribe={this.makeSubscribe}
toLiveRoom={this.toLiveRoom}/>
)
})
}
</div>
)
})
: tabs.map((item, index) => {
const todayLives = preheatLives[item.title]
return ( return (
<div key={index}> <div key={index}>
{ {
......
...@@ -182,6 +182,7 @@ ...@@ -182,6 +182,7 @@
color: #fff; color: #fff;
& .am-tabs-default-bar-tab:nth-last-of-type(2) { & .am-tabs-default-bar-tab:nth-last-of-type(2) {
width: 21% !important;
&::after { &::after {
display: none; display: none;
} }
...@@ -211,14 +212,17 @@ ...@@ -211,14 +212,17 @@
} }
} }
.am-tabs-default-bar-tab-active { .am-tabs-default-bar-tab-active {
background: #FFF604; background: #FFF604;
border-radius: 0 0 5px 5px; border-radius: 0 0 5px 5px;
} }
.am-tabs-default-bar-top{
.am-tabs-default-bar-content{ .am-tabs-default-bar-top {
.am-tabs-default-bar-content {
border: 1px solid rgba(255, 246, 4, 1); border: 1px solid rgba(255, 246, 4, 1);
border-radius: 0 0 6px 6px; border-radius: 0 0 6px 6px;
overflow: hidden;
} }
} }
......
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