Commit b075e321 by zhanghaozhe

Merge remote-tracking branch 'origin/2020-717-formal' into dev

parents 360fa6ff bf513c26
...@@ -872,7 +872,8 @@ ...@@ -872,7 +872,8 @@
} }
} }
td:nth-of-type(2) { td:nth-of-type(2), td:nth-of-type(4) {
text-align: left;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
...@@ -1117,3 +1118,19 @@ ...@@ -1117,3 +1118,19 @@
} }
} }
} }
.follow {
.tip {
margin-bottom: 15px;
}
.qrcode {
text-align: center;
}
img {
width: 120px;
height: 120px;
margin-bottom: 10px;
}
}
\ No newline at end of file
...@@ -10,7 +10,7 @@ class Anniversary2020Entry extends Component { ...@@ -10,7 +10,7 @@ class Anniversary2020Entry extends Component {
const match = this.props.match const match = this.props.match
return ( return (
<Switch> <Switch>
<Route path={`${match.path}/question/:assistId?`} <Route path={`${match.path}/question/:isPractice?`}
render={routeProps => (<Question {...routeProps}></Question>)}></Route> render={routeProps => (<Question {...routeProps}></Question>)}></Route>
<Route path={`${match.path}/invitation`} render={routeProps => (<Invitation {...routeProps}/>)}></Route> <Route path={`${match.path}/invitation`} render={routeProps => (<Invitation {...routeProps}/>)}></Route>
<Route path={'/anniversary_2020'} <Route path={'/anniversary_2020'}
......
...@@ -4,9 +4,10 @@ import { WithFullSize } from "@/HOCs" ...@@ -4,9 +4,10 @@ import { WithFullSize } from "@/HOCs"
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux"; import { compose } from "redux";
import { HeaderBar } from "@common/index" import { HeaderBar } from "@common/index"
import { getParam, http, browser } from "@/utils" import { getParam, http, browser, wxShare } from "@/utils"
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { CopyToClipboard } from "react-copy-to-clipboard"; import { CopyToClipboard } from "react-copy-to-clipboard";
import { Link } from 'react-router-dom'
class Invitation extends Component { class Invitation extends Component {
...@@ -75,6 +76,7 @@ class Invitation extends Component { ...@@ -75,6 +76,7 @@ class Invitation extends Component {
if (code === 200) { if (code === 200) {
this.setState({ this.setState({
teamInfo: data, teamInfo: data,
isMaster: data.is_captain || !getParam('team_code'),
}); });
} else { } else {
Toast.info(msg) Toast.info(msg)
...@@ -100,7 +102,7 @@ class Invitation extends Component { ...@@ -100,7 +102,7 @@ class Invitation extends Component {
.then(res => { .then(res => {
const {code, msg} = res.data const {code, msg} = res.data
if (code === 200) { if (code === 200) {
Toast.info('加入成功') Toast.info('加入成功', 2, null, false)
this.setState((state, props) => { this.setState((state, props) => {
return { return {
teamInfo: {...state.teamInfo, ...{status: 2}}, teamInfo: {...state.teamInfo, ...{status: 2}},
...@@ -117,13 +119,33 @@ class Invitation extends Component { ...@@ -117,13 +119,33 @@ class Invitation extends Component {
}) })
} }
setupWechatShare = () => {
wxShare({
title: '答题抽华为P40 Pro+',
desc: '这道题你会吗?答题抽奖,100%有奖的,能不能拿华为P40 Pro+,看你自己了--七月在线',
link: `${API.m}${location.pathname}?team_code=${this.state.invitationInfo.team_code || getParam('team_code')}`,
imgUrl: '',
})
this.setState({
isShowGuide: true,
});
}
// 答题抽奖
drawQuestions = () => {
const {history} = this.props
history.push(`/anniversary_2020/question/${0}`)
}
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
return ( return (
<div id={'invitation'}> <div id={'invitation'}>
<HeaderBar title={'答题抽奖'} arrow={true}/> <HeaderBar title={'答题抽奖'} arrow={true} goBack={() => {
this.props.history.push('/anniversary_2020')
}}/>
{ {
isMaster isMaster
? <div className="banner"></div> ? <div className="banner"></div>
...@@ -160,12 +182,9 @@ class Invitation extends Component { ...@@ -160,12 +182,9 @@ class Invitation extends Component {
<div className="tip">再有{invitationInfo.invite_num}位队员答对即可获得{invitationInfo.draw_chance}次抽奖机会</div> <div className="tip">再有{invitationInfo.invite_num}位队员答对即可获得{invitationInfo.draw_chance}次抽奖机会</div>
{ {
browser.isWeixin browser.isWeixin
? <button className={'btn'} onClick={() => { ? <button className={'btn'} onClick={this.setupWechatShare}>立即邀请</button>
this.setState({ : <CopyToClipboard
isShowGuide: true, text={`${API.m}${location.pathname}?team_code=${invitationInfo.team_code || getParam('team_code')}`}
});
}}>立即邀请</button>
: <CopyToClipboard text={`${API.m}${location.pathname}?team_code=${invitationInfo.team_code}`}
onCopy={() => { onCopy={() => {
Toast.info('链接已复制,快去粘贴发给好友吧') Toast.info('链接已复制,快去粘贴发给好友吧')
}}> }}>
...@@ -177,17 +196,12 @@ class Invitation extends Component { ...@@ -177,17 +196,12 @@ class Invitation extends Component {
{ {
teamInfo.status !== 1 && <div className={'tip'}> teamInfo.status !== 1 && <div className={'tip'}>
{ {
teamInfo.status === 2 ? '已加入当前队伍' : teamInfo === 3 ? '已加入其他队伍' : null teamInfo.status === 2 ? '已加入当前队伍' : teamInfo.status === 3 ? '已加入其他队伍' : null
} }
</div> </div>
} }
{ <BottomButton isActivityEnd={isActivityEnd} joinTeam={this.joinTeam} status={teamInfo.status}
isActivityEnd drawQuestions={this.drawQuestions} isAnswered={teamInfo.is_answer}/>
? <button className={'activity-end'}>活动结束</button>
: teamInfo.status === 1
? <button className={'btn'} onClick={this.joinTeam}>加入队伍</button>
: <button className={'btn'}>答题抽奖</button>
}
</> </>
} }
...@@ -208,6 +222,19 @@ class Invitation extends Component { ...@@ -208,6 +222,19 @@ class Invitation extends Component {
} }
} }
function BottomButton({status, isActivityEnd, isAnswered, joinTeam, drawQuestions}) {
if (isActivityEnd) {
return <button className={'activity-end'}>活动结束</button>
}
if (isAnswered) {
return <Link to={`/anniversary_2020#lottery`}>
<button className={'btn'}>去抽奖</button>
</Link>
}
return status === 1 ? <button className={'btn'} onClick={joinTeam}>加入队伍</button> :
<button className={'btn'} onClick={drawQuestions}>答题抽奖</button>
}
export default compose( export default compose(
WithFullSize, WithFullSize,
connect( connect(
......
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'
...@@ -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,
isTeamHead: this.props.match.params.assistId === undefined, isResultConfirm: false,
isTeamHead: this.props.match.params.isPractice == 1,
isActivityEnd: false, isActivityEnd: false,
is_correct: '',
is_sign: '',
} }
componentDidMount() { componentDidMount() {
...@@ -38,8 +41,8 @@ class Question extends Component { ...@@ -38,8 +41,8 @@ class Question extends Component {
} }
getQuestion = () => { getQuestion = () => {
const assistId = this.props.match.params.assistId const isPractice = this.props.match.params.isPractice
http.get(`${API.home}/activity/anniversary/get_question/${assistId ? 2 : 1}/${assistId ? assistId : 0}`) http.get(`${API.home}/activity/anniversary/get_question/${isPractice == 1 ? 1 : 2}`)
.then(res => { .then(res => {
const {code, msg, data} = res.data const {code, msg, data} = res.data
if (code === 200) { if (code === 200) {
...@@ -56,14 +59,14 @@ class Question extends Component { ...@@ -56,14 +59,14 @@ class Question extends Component {
select = (id) => { select = (id) => {
this.setState({ this.setState({
selectedOptionId: id, selectedOptionId: id,
}); })
} }
submit = () => { submit = () => {
const assistId = this.props.match.params.assistId const isPractice = this.props.match.params.isPractice
const {selectedOptionId} = this.state const {selectedOptionId} = this.state
http.post(`${API.home}/activity/anniversary/submit`, { http.post(`${API.home}/activity/anniversary/submit`, {
type: assistId ? 2 : 1, type: isPractice == 1 ? 1 : 2,
option_id: selectedOptionId, option_id: selectedOptionId,
id: this.props.cache.question.id, id: this.props.cache.question.id,
}).then(res => { }).then(res => {
...@@ -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: isPractice != 1,
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,17 +91,35 @@ class Question extends Component { ...@@ -85,17 +91,35 @@ class Question extends Component {
}) })
} }
resultFun = () => {
const {history} = this.props
if (this.state.is_sign) {
history.push('/anniversary_2020#lottery')
} 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
if (isTeamHead) { if (isTeamHead) {
if (result.stage === 4) { if (result.stage === 4) {
this.setState({
isActivityEnd: true,
});
} else { } else {
result.is_correct ? Toast.info('回答正确 抽奖次数+1') : Toast.info('很遗憾 回答错误') result.is_correct ? Toast.info('回答正确 抽奖次数+1') : Toast.info('很遗憾 回答错误')
} }
} else {
} }
} }
...@@ -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,14 @@ class Question extends Component { ...@@ -184,12 +209,14 @@ 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}
isActivityEnd={isActivityEnd}
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,36 +227,52 @@ class Question extends Component { ...@@ -200,36 +227,52 @@ 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 Confirm({submit, cancel}) { function ResultConfirm({resultFun, is_correct, is_sign}) {
return <div className="modal-cover"> return <div className="modal-cover">
<div className="modal"> <div className="modal">
<div className="title">提交确认</div> {
<div className="btns"> is_correct === 1 &&
<button onClick={cancel}>取消</button> <div className="title">回答正确,抽奖次数+1</div>
<button onClick={submit}>确认提交</button> }
{
is_correct === 0 &&
<div className="rusult-title">很遗憾,回答错误 <p>快去抽奖提提神吧</p></div>
}
<div className={'btm-button'}>
<button onClick={resultFun}>{is_sign ? '去抽奖' : '签到领取抽奖机会'}</button>
</div> </div>
</div> </div>
</div> </div>
} }
function Result() { function Confirm({submit, cancel}) {
return <div className={'modal-cover'}> return <div className="modal-cover">
<div className="modal"> <div className="modal">
<div className="title"></div> <div className="title">提交确认</div>
<div className="btns">
<button onClick={cancel}>取消</button>
<button onClick={submit}>确认提交</button>
</div>
</div> </div>
</div> </div>
} }
function BottomButton({result, submit, isTeamHead, redo}) { function BottomButton({resultFun, result, submit, isTeamHead, redo, isActivityEnd}) {
if (result.stage === 4) { if (result.stage === 4 || isActivityEnd) {
return <button className={'activity-end'}>活动已结束</button> return <button className={'activity-end'}>活动已结束</button>
} }
if (isTeamHead) { if (isTeamHead) {
...@@ -237,10 +280,18 @@ function BottomButton({result, submit, isTeamHead, redo}) { ...@@ -237,10 +280,18 @@ function BottomButton({result, submit, isTeamHead, redo}) {
return result.practiceNum === 0 return result.practiceNum === 0
? <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 {
return <button className={'submit'} onClick={submit}>提交</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 +319,4 @@ export default compose( ...@@ -268,4 +319,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;
......
...@@ -146,7 +146,7 @@ export { ...@@ -146,7 +146,7 @@ export {
browser, browser,
isLogin, isLogin,
dateCountDown, dateCountDown,
isValidUrl isValidUrl,
} }
export { export {
default as SendMessageToApp, default as SendMessageToApp,
......
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