Commit 42ea043a by zhanghaozhe

弹幕

parent 73a1dd12
import React, {Component} from 'react' import React, { Component } from 'react'
import {WingBlank} from 'antd-mobile' import { WingBlank } from 'antd-mobile'
import './index.scss' import './index.scss'
import {api, getParam, http} from "@/utils" import { getParam, http } from "@/utils"
// 课程页面滚动广告 // 课程页面滚动广告
class Carouselw extends Component { class Barrage extends Component {
timer timer
barageTimer barageTimer
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
...@@ -26,7 +27,7 @@ class Carouselw extends Component { ...@@ -26,7 +27,7 @@ class Carouselw extends Component {
] ]
const now = new Date(Date.now()).getHours() const now = new Date(Date.now()).getHours()
for (let period of periods) { for (let period of periods) {
if(now >= period.start && now <= period.end){ if (now >= period.start && now <= period.end) {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.getList() this.getList()
this.setupBarrage() this.setupBarrage()
...@@ -39,9 +40,11 @@ class Carouselw extends Component { ...@@ -39,9 +40,11 @@ class Carouselw extends Component {
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
const {isShow} = this.props const {isShow} = this.props
const {isShow: prevIsShow} = prevProps const {isShow: prevIsShow} = prevProps
if(prevIsShow !== isShow && isShow !== undefined){ if (prevIsShow !== isShow && isShow !== undefined) {
if(isShow){ if (isShow) {
this.setupBarrage() setTimeout(() => {
this.getList()
}, 5000)
} }
this.componentDidUpdate = null this.componentDidUpdate = null
} }
...@@ -66,6 +69,7 @@ class Carouselw extends Component { ...@@ -66,6 +69,7 @@ class Carouselw extends Component {
}, () => { }, () => {
this.barageTimer = setTimeout(() => { this.barageTimer = setTimeout(() => {
this.setState({isShowBarrage: !this.state.isShowBarrage}) this.setState({isShowBarrage: !this.state.isShowBarrage})
this.setupBarrage()
}, 5000) }, 5000)
}); });
} }
...@@ -84,7 +88,7 @@ class Carouselw extends Component { ...@@ -84,7 +88,7 @@ class Carouselw extends Component {
</div> </div>
} }
</div> </div>
{/* {/*
<Carousel className="my-carousel" <Carousel className="my-carousel"
vertical vertical
dots={false} dots={false}
...@@ -106,4 +110,4 @@ class Carouselw extends Component { ...@@ -106,4 +110,4 @@ class Carouselw extends Component {
} }
} }
export default Carouselw export default Barrage
\ No newline at end of file \ No newline at end of file
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