Commit b0264eac by wangshuo

Merge branch '00' into dev

parents a2de889c d877e94e
...@@ -28,13 +28,20 @@ class Landing extends Component { ...@@ -28,13 +28,20 @@ class Landing extends Component {
treasure_code: getParam('treasure_code'), treasure_code: getParam('treasure_code'),
activityEnd: false, activityEnd: false,
notices: [], notices: [],
rule: '' rule: '',
isCaptain: sessionStorage.getItem('status')
} }
componentDidMount() { componentDidMount() {
this.fetchPageData() this.fetchPageData()
} }
componentDidUpdate(prevProps) {
if(prevProps.user.hasError !== this.props.user.hasError && !this.props.user.hasError){
this.fetchPageData()
}
}
fetchPageData = ({origin = this.state.origin, treasure_code = this.state.treasure_code} = {}) => { fetchPageData = ({origin = this.state.origin, treasure_code = this.state.treasure_code} = {}) => {
http.post(`${API.home}/sys/treasure/team`, { http.post(`${API.home}/sys/treasure/team`, {
...@@ -51,6 +58,7 @@ class Landing extends Component { ...@@ -51,6 +58,7 @@ class Landing extends Component {
let searchParams = new URLSearchParams(window.location.search) let searchParams = new URLSearchParams(window.location.search)
if (searchParams.get('origin') === '1' && !browser.isWeixin) { if (searchParams.get('origin') === '1' && !browser.isWeixin) {
sessionStorage.setItem('isCaptain', '1')
searchParams.set('origin', '2') searchParams.set('origin', '2')
window.history.replaceState(null, '', `landing?${searchParams.toString()}`) window.history.replaceState(null, '', `landing?${searchParams.toString()}`)
} }
...@@ -157,7 +165,7 @@ class Landing extends Component { ...@@ -157,7 +165,7 @@ class Landing extends Component {
wxShare({ wxShare({
title: `@${user.data.username} 邀您一起组队拿豪礼!`, title: `@${user.data.username} 邀您一起组队拿豪礼!`,
desc: `加我我的队伍,机械键盘,纸质书籍等超多奖品等你拿!`, desc: `加我我的队伍,机械键盘,纸质书籍等超多奖品等你拿!`,
link: encodeURIComponent(`${window.location.origin}/${location.pathname}?treasure_code=${treasure_code}&origin=2`), link: `${window.location.origin}/${location.pathname}?treasure_code=${treasure_code}&origin=2`,
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newIndex/community/tou5_bj.png' imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newIndex/community/tou5_bj.png'
}) })
} }
...@@ -334,7 +342,8 @@ class Landing extends Component { ...@@ -334,7 +342,8 @@ class Landing extends Component {
prize_info, prize_info,
my_team my_team
}, },
activityEnd activityEnd,
isCaptain
} = this.state } = this.state
/* /*
...@@ -355,9 +364,10 @@ class Landing extends Component { ...@@ -355,9 +364,10 @@ class Landing extends Component {
<img className='main-avatar' <img className='main-avatar'
src={head_img} alt=""/> src={head_img} alt=""/>
{ {
status === 1 && <div className="des">邀请好友加入队伍,开宝箱领取丰厚奖品~</div> status === 1
? <div className="des">邀请好友加入队伍,开宝箱领取丰厚奖品~</div>
: <div className="des">加入我的<span>{team_num}</span>号队伍,一起开宝箱领取丰厚奖品~</div>
} }
<div className="des">加入我的<span>{team_num}</span>号队伍,一起开宝箱领取丰厚奖品~</div>
<Prizes showSystemNotices={false}/> <Prizes showSystemNotices={false}/>
<BulletScreen/> <BulletScreen/>
<div className="group"> <div className="group">
...@@ -465,7 +475,7 @@ class Landing extends Component { ...@@ -465,7 +475,7 @@ class Landing extends Component {
</button> </button>
} }
{ {
prize_info && !activityEnd && <div className="certainly-prompt"> !isCaptain && prize_info && !activityEnd && <div className="certainly-prompt">
{prize_info.stage_no}次必中 {prize_info.name} {prize_info.stage_no}次必中 {prize_info.name}
</div> </div>
} }
...@@ -481,7 +491,9 @@ class Landing extends Component { ...@@ -481,7 +491,9 @@ class Landing extends Component {
</div> </div>
</BoxContainer> </BoxContainer>
<WhiteSpace size={'xl'}/> <WhiteSpace size={'xl'}/>
<YearCourse></YearCourse> {
isCaptain && <YearCourse/>
}
</div> </div>
) )
} }
......
...@@ -7,9 +7,10 @@ import TreasureNav from './nav' ...@@ -7,9 +7,10 @@ import TreasureNav from './nav'
import CommonPopup from './../common/commonPopup/index' import CommonPopup from './../common/commonPopup/index'
import cookie from "js-cookie" import cookie from "js-cookie"
import {setCurrentUser, startFetchUser} from "@/store/userAction" import {setCurrentUser, startFetchUser} from "@/store/userAction"
import {SendMessageToApp, getParam} from '@/utils' import {SendMessageToApp, getParam, http} from '@/utils'
import {addDays} from "date-fns" import {addDays} from "date-fns"
import {connect} from "react-redux" import {connect} from "react-redux"
import { Toast } from 'antd-mobile';
@connect(state => ({ @connect(state => ({
user: state.user user: state.user
...@@ -19,6 +20,8 @@ export default class index extends Component { ...@@ -19,6 +20,8 @@ export default class index extends Component {
state = { state = {
removable: 0, // 未拆宝箱的数量 removable: 0, // 未拆宝箱的数量
currentOpenId: 0, // 当前要拆的宝箱的队伍的ID currentOpenId: 0, // 当前要拆的宝箱的队伍的ID
treasure_stage: 0, // 宝箱的活动阶段
active_stage: 0, // 整个活动的阶段
userInfoList: [], userInfoList: [],
userInfo: {}, userInfo: {},
isAppUpdate: false, isAppUpdate: false,
...@@ -32,6 +35,8 @@ export default class index extends Component { ...@@ -32,6 +35,8 @@ export default class index extends Component {
window['loginInfo'] = result => { window['loginInfo'] = result => {
_this.loginInfo(result) _this.loginInfo(result)
} }
_this.getStage();
} }
// 获取app登录数据 // 获取app登录数据
...@@ -118,6 +123,21 @@ export default class index extends Component { ...@@ -118,6 +123,21 @@ export default class index extends Component {
} }
} }
// 获取活动以及宝箱的阶段
getStage = () => {
http.get(`${API.home}/activity/stage`).then(res => {
const { code, data, msg } = res.data;
if(code === 200) {
// treasure_stage,宝箱阶段,0-不在活动时间,1-活动时间内
this.setState({
treasure_stage: data.treasure_stage
})
}else{
Toast.info(msg, 2);
}
});
}
toYearWish = () => { toYearWish = () => {
const isLogin = !this.props.user.hasError const isLogin = !this.props.user.hasError
if (isLogin) { if (isLogin) {
...@@ -139,14 +159,14 @@ export default class index extends Component { ...@@ -139,14 +159,14 @@ export default class index extends Component {
} }
render() { render() {
const {banner, removable} = this.state const {banner, removable, treasure_stage} = this.state
return ( return (
<div className={'year-index'}> <div className={'year-index'}>
<div className="banner-treasure"> <div className="banner-treasure">
<div id="banner" className="banner-treasure__header" <div id="banner" className="banner-treasure__header"
style={{backgroundImage: `url(${banner})`}}></div> style={{backgroundImage: `url(${banner})`}}></div>
<div className="banner-treasure__nav"> <div className="banner-treasure__nav">
<TreasureNav id="banner"/> <TreasureNav id="banner" treasure_stage={treasure_stage}/>
</div> </div>
<div className="banner-treasure__decorate"></div> <div className="banner-treasure__decorate"></div>
</div> </div>
...@@ -165,7 +185,9 @@ export default class index extends Component { ...@@ -165,7 +185,9 @@ export default class index extends Component {
<LiveRoom/> <LiveRoom/>
{/* 组队开宝箱 */} {/* 组队开宝箱 */}
<TreasureBox getRemovable={this.getRemovable} /> {
treasure_stage === 1 && <TreasureBox getRemovable={this.getRemovable} />
}
{/*课程*/} {/*课程*/}
<YearCourse isAppUpdate={this.state.isAppUpdate} getSum={this.sonToPar.bind(this)}/> <YearCourse isAppUpdate={this.state.isAppUpdate} getSum={this.sonToPar.bind(this)}/>
......
...@@ -40,7 +40,6 @@ class TreasureNav extends Component { ...@@ -40,7 +40,6 @@ class TreasureNav extends Component {
} }
componentDidMount() { componentDidMount() {
this.initNav();
window.addEventListener('scroll', this.calcNavActive) window.addEventListener('scroll', this.calcNavActive)
} }
...@@ -48,14 +47,14 @@ class TreasureNav extends Component { ...@@ -48,14 +47,14 @@ class TreasureNav extends Component {
window.removeEventListener('scroll', this.calcNavActive); window.removeEventListener('scroll', this.calcNavActive);
} }
initNav = () => { componentWillReceiveProps(nextProps) {
const { navs } = this.state; this.initNav(nextProps.treasure_stage);
http.get(`${API.home}/activity/stage`).then(res => { }
const { code, data } = res.data;
if(code === 200) {
initNav = (treasure_stage) => {
let {navs} = this.state;
// treasure_stage,宝箱阶段,0-不在活动时间,1-活动时间内 // treasure_stage,宝箱阶段,0-不在活动时间,1-活动时间内
if(data.treasure_stage === 0) { if(treasure_stage === 0) {
this.setState({ this.setState({
formatNavs: navs.filter(item => item.id !== 'year-treasure') formatNavs: navs.filter(item => item.id !== 'year-treasure')
}); });
...@@ -65,8 +64,6 @@ class TreasureNav extends Component { ...@@ -65,8 +64,6 @@ class TreasureNav extends Component {
}) })
} }
} }
});
}
calcNavActive = () => { calcNavActive = () => {
const { formatNavs } = this.state; const { formatNavs } = this.state;
......
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