Commit 95661967 by zhanghaozhe

周年庆

parent 8e30482d
import React, { Component } from 'react'; import React, { Component } from 'react';
import { debounce, groupBy, isEmpty } from "lodash"; import { debounce, groupBy, isEmpty } from "lodash";
import { browser, http } from "@/utils" import { http } from "@/utils"
import { Toast, Carousel } from "antd-mobile"; import { Toast, Carousel } from "antd-mobile";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { connect } from "react-redux"; import { connect } from "react-redux";
...@@ -30,6 +30,7 @@ class Anniversary2020 extends Component { ...@@ -30,6 +30,7 @@ class Anniversary2020 extends Component {
4.每人只能当1次队员哦 4.每人只能当1次队员哦
` `
drawTimer = null drawTimer = null
countDownTimer = null
hasMore = true hasMore = true
state = { state = {
...@@ -81,6 +82,7 @@ class Anniversary2020 extends Component { ...@@ -81,6 +82,7 @@ class Anniversary2020 extends Component {
rankList: [], rankList: [],
isShowAllRankList: false, isShowAllRankList: false,
qrcode: undefined, qrcode: undefined,
countDown: '',
//弹框 //弹框
userAddress: { userAddress: {
name: '', name: '',
...@@ -130,17 +132,18 @@ class Anniversary2020 extends Component { ...@@ -130,17 +132,18 @@ class Anniversary2020 extends Component {
document.removeEventListener('scroll', this.setNavActive) document.removeEventListener('scroll', this.setNavActive)
document.body.style.overflow = 'auto' document.body.style.overflow = 'auto'
clearInterval(this.drawTimer) clearInterval(this.drawTimer)
clearTimeout(this.countDownTimer)
} }
getActivityStage = () => { getActivityStage = () => {
http.get(`${API.home}/activity/anniversary/activityStage`) http.get(`${API.home}/activity/anniversary/activityStage`)
.then(res => { .then(res => {
const {code, msg, data} = res.data const {code, msg, data} = res.data
this.setupCountDown(data.count_down)
if (code === 200) { if (code === 200) {
this.setState({ this.setState({
activityData: data, activityData: data,
}, this.bindNavAction); }, this.bindNavAction())
} else { } else {
Toast.info(msg) Toast.info(msg)
} }
...@@ -420,7 +423,7 @@ class Anniversary2020 extends Component { ...@@ -420,7 +423,7 @@ class Anniversary2020 extends Component {
} }
draw = debounce((i) => { draw = debounce((i) => {
if(this.isGotoLogin()){ if (this.isGotoLogin()) {
return return
} }
const {activityData, prizeData, isDrawing} = this.state const {activityData, prizeData, isDrawing} = this.state
...@@ -528,6 +531,24 @@ class Anniversary2020 extends Component { ...@@ -528,6 +531,24 @@ class Anniversary2020 extends Component {
} }
} }
setupCountDown = (totalSeconds) => {
this.countDownTimer = setTimeout(() => {
totalSeconds--
const d = Math.floor(totalSeconds / 60 / 60 / 24)
const h = Math.floor(totalSeconds / 60 / 60) % 24
const m = Math.floor(totalSeconds / 60) % 60
this.setState({
countDown: `${d}${h}${m}分`,
}, () => {
if (totalSeconds > 0) {
this.setupCountDown(totalSeconds)
} else {
this.getActivityStage()
}
});
}, 1000 * 60)
}
render() { render() {
const { const {
navs, navs,
...@@ -555,6 +576,7 @@ class Anniversary2020 extends Component { ...@@ -555,6 +576,7 @@ class Anniversary2020 extends Component {
isShowAllRankList, isShowAllRankList,
isShowFollow, isShowFollow,
qrcode, qrcode,
countDown,
} = this.state } = this.state
const {history, user} = this.props const {history, user} = this.props
...@@ -565,7 +587,18 @@ class Anniversary2020 extends Component { ...@@ -565,7 +587,18 @@ class Anniversary2020 extends Component {
return ( return (
<div className={'anniversary-2020'}> <div className={'anniversary-2020'}>
<div className="banner"> <div className="banner">
<img src="" alt=""/> <img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active20_717/m/banner.png" alt=""/>
{
countDown &&
<div className="count-down">{countDown} {
activityData.stage === 1
? '后开始'
: activityData.stage === 2
? '后结束'
: null
}
</div>
}
</div> </div>
{ {
!activityData.is_sign && <div className="sign" onClick={this.sign}></div> !activityData.is_sign && <div className="sign" onClick={this.sign}></div>
...@@ -777,9 +810,10 @@ class Anniversary2020 extends Component { ...@@ -777,9 +810,10 @@ class Anniversary2020 extends Component {
{ {
!!team.team_info && team.team_info.length && team.team_info.slice(0, 5).map((item, index) => { !!team.team_info && team.team_info.length && team.team_info.slice(0, 5).map((item, index) => {
return <li key={index}> return <li key={index}>
<img {
src="https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/home/avatar_20191104.png" item.head_img ? <img src={item.head_img} alt=""/>
alt=""/> : <img src={item.avatar_file} alt=""/>
}
</li> </li>
}) })
} }
......
...@@ -3,12 +3,28 @@ ...@@ -3,12 +3,28 @@
padding: 0 10px 75px; padding: 0 10px 75px;
.banner { .banner {
position: relative;
height: 220px; height: 220px;
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.count-down {
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
width: 208px;
height: 30px;
background: linear-gradient(-90deg, rgba(145, 51, 199, 1) 0%, rgba(245, 47, 2, 1) 100%);
border-radius: 15px;
font-size: 16px;
color: #fff;
text-align: center;
line-height: 30px;
}
} }
@mixin button { @mixin button {
...@@ -864,7 +880,7 @@ ...@@ -864,7 +880,7 @@
} }
} }
a{ a {
text-decoration: underline; text-decoration: underline;
} }
......
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