Commit 5fcc8bf1 by xuzhenghua

717-邀请好友组队答题

parent 307f4f0f
...@@ -117,6 +117,12 @@ class Invitation extends Component { ...@@ -117,6 +117,12 @@ class Invitation extends Component {
}) })
} }
// 答题抽奖
drawQuestions=()=>{
const {history,user} = this.props
history.push(`/anniversary_2020/question/${user.data.uid}`)
}
render() { render() {
const {prizes, invitationInfo, isShowGuide, teamInfo, isMaster, isActivityEnd} = this.state const {prizes, invitationInfo, isShowGuide, teamInfo, isMaster, isActivityEnd} = this.state
const {location} = this.props const {location} = this.props
...@@ -186,7 +192,7 @@ class Invitation extends Component { ...@@ -186,7 +192,7 @@ class Invitation extends Component {
? <button className={'activity-end'}>活动结束</button> ? <button className={'activity-end'}>活动结束</button>
: teamInfo.status === 1 : teamInfo.status === 1
? <button className={'btn'} onClick={this.joinTeam}>加入队伍</button> ? <button className={'btn'} onClick={this.joinTeam}>加入队伍</button>
: <button className={'btn'}>答题抽奖</button> : <button className={'btn'} onClick={this.drawQuestions}>答题抽奖</button>
} }
</> </>
} }
......
import React, { Component } from 'react'; import React, {Component} from 'react'
import './index.scss' import './index.scss'
import { Toast } from "antd-mobile"; import {Toast} from "antd-mobile"
import classnames from 'classnames' import classnames from 'classnames'
import { browser, http } from "@/utils" import {browser, http} from "@/utils"
import { WithFullSize } from "@/HOCs" import {WithFullSize} from "@/HOCs"
import { Link } from "react-router-dom"; import {Link} from "react-router-dom"
import { compose } from 'redux' import {compose} from 'redux'
import { connect } from 'react-redux' import {connect} from 'react-redux'
import { addData, ADD_RECOMMENDS, ADD_QUESTION, ADD_RESULT, REDO } from './store/reducer' import {addData, ADD_RECOMMENDS, ADD_QUESTION, ADD_RESULT, REDO} from './store/reducer'
class Question extends Component { class Question extends Component {
...@@ -17,8 +17,11 @@ class Question extends Component { ...@@ -17,8 +17,11 @@ class Question extends Component {
recommends: [], recommends: [],
selectedOptionId: 0, selectedOptionId: 0,
isShowConfirm: false, isShowConfirm: false,
isResultConfirm: false,
isTeamHead: this.props.match.params.assistId === undefined, isTeamHead: this.props.match.params.assistId === undefined,
isActivityEnd: false, isActivityEnd: false,
is_correct: '',
is_sign: '',
} }
componentDidMount() { componentDidMount() {
...@@ -56,7 +59,7 @@ class Question extends Component { ...@@ -56,7 +59,7 @@ class Question extends Component {
select = (id) => { select = (id) => {
this.setState({ this.setState({
selectedOptionId: id, selectedOptionId: id,
}); })
} }
submit = () => { submit = () => {
...@@ -73,8 +76,11 @@ class Question extends Component { ...@@ -73,8 +76,11 @@ class Question extends Component {
this.afterSubmitted(data) this.afterSubmitted(data)
this.setState({ this.setState({
isShowConfirm: false, isShowConfirm: false,
isResultConfirm: true,
selectedOptionId: undefined, selectedOptionId: undefined,
}); is_correct: data.is_correct,
is_sign: data.is_sign
})
this.props.addData({ this.props.addData({
payload: data, payload: data,
type: ADD_RESULT, type: ADD_RESULT,
...@@ -85,6 +91,24 @@ class Question extends Component { ...@@ -85,6 +91,24 @@ class Question extends Component {
}) })
} }
resultFun = () => {
const {history} = this.props
if (this.state.is_sign) {
history.push('/anniversary_2020')
} else {
http.get(`${API.home}/activity/anniversary/sign`)
.then(res => {
const {code, msg} = res.data
if (code === 200) {
Toast.info('签到成功 抽奖次数+1')
history.push('/anniversary_2020')
} else {
Toast.info(msg)
}
})
}
}
afterSubmitted = (result) => { afterSubmitted = (result) => {
const {isTeamHead} = this.state const {isTeamHead} = this.state
...@@ -131,6 +155,7 @@ class Question extends Component { ...@@ -131,6 +155,7 @@ class Question extends Component {
selectedOptionId, selectedOptionId,
isShowConfirm, isShowConfirm,
isActivityEnd, isActivityEnd,
isResultConfirm,
isTeamHead, isTeamHead,
} = this.state } = this.state
...@@ -184,12 +209,13 @@ class Question extends Component { ...@@ -184,12 +209,13 @@ class Question extends Component {
} }
<div className="submit-bar"> <div className="submit-bar">
<BottomButton result={result} <BottomButton result={result}
resultFun={this.resultFun}
isTeamHead={isTeamHead} isTeamHead={isTeamHead}
submit={() => { submit={() => {
if (this.state.selectedOptionId) { if (this.state.selectedOptionId) {
this.setState({ this.setState({
isShowConfirm: true, isShowConfirm: true,
}); })
} }
}} }}
redo={this.redo} redo={this.redo}
...@@ -200,14 +226,38 @@ class Question extends Component { ...@@ -200,14 +226,38 @@ class Question extends Component {
<Confirm submit={this.submit} cancel={() => { <Confirm submit={this.submit} cancel={() => {
this.setState({ this.setState({
isShowConfirm: false, isShowConfirm: false,
}); })
}}></Confirm> }}></Confirm>
} }
{
isResultConfirm &&
<ResultConfirm resultFun={this.resultFun} is_correct={this.state.is_correct}
is_sign={this.state.is_sign}></ResultConfirm>
}
</div> </div>
); )
} }
} }
function ResultConfirm({resultFun, is_correct, is_sign}) {
return <div className="modal-cover">
<div className="modal">
{
is_correct === 1 &&
<div className="title">回答正确,抽奖次数+1</div>
}
{
is_correct === 0 &&
<div className="rusult-title">很遗憾,回答错误 <p>快去抽奖提提神吧</p></div>
}
<div className={'btm-button'}>
<button onClick={resultFun}>{is_sign ? '去抽奖' : '签到领取抽奖机会'}</button>
</div>
</div>
</div>
}
function Confirm({submit, cancel}) { function Confirm({submit, cancel}) {
return <div className="modal-cover"> return <div className="modal-cover">
<div className="modal"> <div className="modal">
...@@ -228,7 +278,7 @@ function Result() { ...@@ -228,7 +278,7 @@ function Result() {
</div> </div>
} }
function BottomButton({result, submit, isTeamHead, redo}) { function BottomButton({resultFun, result, submit, isTeamHead, redo}) {
if (result.stage === 4) { if (result.stage === 4) {
return <button className={'activity-end'}>活动已结束</button> return <button className={'activity-end'}>活动已结束</button>
} }
...@@ -238,9 +288,15 @@ function BottomButton({result, submit, isTeamHead, redo}) { ...@@ -238,9 +288,15 @@ function BottomButton({result, submit, isTeamHead, redo}) {
? <button className={'lottery-related'}><Link to={`/anniversary_2020/invitation`}>组队答题抽奖</Link></button> ? <button className={'lottery-related'}><Link to={`/anniversary_2020/invitation`}>组队答题抽奖</Link></button>
: <button className={'submit'} onClick={redo}>继续答题</button> : <button className={'submit'} onClick={redo}>继续答题</button>
} }
} else {
if (result.analysis) {
return !result.is_sign
? <button className={'lottery-related'} onClick={resultFun}>签到领取抽奖机会</button>
: <button className={'submit'} onClick={resultFun}>去抽奖</button>
}
return <button className={'submit'} onClick={submit}>提交</button>
} }
return <button className={'submit'} onClick={submit}>提交</button>
} }
function Recommends({recommends}) { function Recommends({recommends}) {
...@@ -268,4 +324,4 @@ export default compose( ...@@ -268,4 +324,4 @@ export default compose(
addData: data => dispatch(addData(data)), addData: data => dispatch(addData(data)),
}), }),
), ),
)(Question); )(Question)
\ No newline at end of file \ No newline at end of file
...@@ -204,6 +204,40 @@ ...@@ -204,6 +204,40 @@
color: #525C65; color: #525C65;
} }
.rusult-title {
text-align: center;
padding-top: 20px;
color: #525C65;
font-size: 18px;
font-weight: 500;
margin-bottom: 20px;
p {
margin-top: 10px;
color: #525C65;
font-size: 15px;
font-weight: 400;
}
}
.btm-button {
width: 100%;
margin: 0 0 20px 0;
text-align: center;
button {
min-width: 128px;
height: 33px;
background: rgba(250, 228, 77, 1);
border-radius: 4px;
border: none;
color: #2034F5;
font-size: 16px;
font-weight: 500;
padding: 0 17px;
}
}
.btns { .btns {
border-top: 1px solid #DDD; border-top: 1px solid #DDD;
height: 44px; height: 44px;
......
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