dev_aliyun2
harry 5 years ago
parent e8099e82f1
commit 7c1afec61d

@ -1,7 +1,15 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Redirect } from 'react-router'; import { Redirect } from 'react-router';
import { Rate } from 'antd'
import PropTypes from 'prop-types';
import Rate from 'rc-rate';
import Tooltip from 'material-ui/Tooltip';
import './TaskResultLayer.css' import './TaskResultLayer.css'
import moment from 'moment';
import passallImg from '../../../images/tpi/passall.png' import passallImg from '../../../images/tpi/passall.png'
import passpartImg from '../../../images/tpi/passpart.png' import passpartImg from '../../../images/tpi/passpart.png'
import empiricgreenImg from '../../../images/tpi/empiricgreen.png' import empiricgreenImg from '../../../images/tpi/empiricgreen.png'
@ -20,27 +28,22 @@ class TaskResultLayer extends Component {
stared: false, stared: false,
timeRemain: 0, timeRemain: 0,
} }
}
componentWillReceiveProps(newProps, newContext) { componentWillReceiveProps(newProps, newContext) {
if (newProps.currentGamePassed && (!this.props.currentGamePassed if (newProps.currentGamePassed && (!this.props.currentGamePassed
|| (newProps.currentGamePassed !== this.props.currentGamePassed))) { || (newProps.currentGamePassed !== this.props.currentGamePassed))) {
// this.fakeRanking = this._fakeRanking() // this.fakeRanking = this._fakeRanking()
const $ = window.$; const $ = window.$;
let isLastGame = newProps.game_count === newProps.challenge.position; let isLastGame = newProps.game_count === newProps.challenge.position;
setTimeout(() => { setTimeout(() => {
// true || // true ||
if (isLastGame) { if (isLastGame) {
var dClass = 'zoomInDown'; $('.passTaskContent').show().addClass(dClass + ' animated'); var dClass = 'zoomInDown'; $('.passTaskContent').show().addClass(dClass + ' animated');
setTimeout(function () { $('.passTaskContent').removeClass(dClass + ' animated') }, 1000) setTimeout(function () { $('.passTaskContent').removeClass(dClass + ' animated') }, 1000)
} else { } else {
var dClass = 'zoomIn'; $('.passTaskContent').show().addClass(dClass + ' animated'); var dClass = 'zoomIn'; $('.passTaskContent').show().addClass(dClass + ' animated');
setTimeout(function () { $('.passTaskContent').removeClass(dClass + ' animated') }, 1000) setTimeout(function () { $('.passTaskContent').removeClass(dClass + ' animated') }, 1000)
}
}, 100)
if (newProps.challenge.showLanguagePictrue == true) {
// 开启倒计时
// this.initEffectDisplayServerTimer()
} }
}, 100) }, 100)
@ -49,13 +52,22 @@ class TaskResultLayer extends Component {
// this.initEffectDisplayServerTimer() // this.initEffectDisplayServerTimer()
} }
} }
}
onStarChange(challenge, index, value) {
this.props.onStarChange(challenge, index, value);
onStarChange(challenge, index, value) { this.setState({
this.props.onStarChange(challenge, index, value); stared: value ? true : false,
})
}
this.setState({ onFinish(goNext) {
stared: value ? true : false, const { stared } = this.state;
}) const { game, challenge, shixun, showSnackbar, next_game } = this.props;
if (!stared && !this.props.game.star && shixun.status >= 2) { // 没点评星 && 未评星 && 实训已发布(模拟实战可以继续)
showSnackbar('请先给该任务评星,谢谢。')
return;
} }
// 点击了查看效果,而非查看下一关 // 点击了查看效果,而非查看下一关
@ -67,35 +79,6 @@ class TaskResultLayer extends Component {
} else { } else {
trigger('showWebDisplayEvent') trigger('showWebDisplayEvent')
} }
// 点击了查看效果,而非查看下一关
if (!goNext) {
if (challenge.showWebDisplayButton === true && challenge.webDisplayUrl) {
// 打开web效果查看页面
window.open(challenge.webDisplayUrl, '_blank');
return;
} else {
trigger('showWebDisplayEvent')
}
}
if (!game.star) { // 当前关卡没有评星,评星后再跳转
this.props.saveChallengeStar(game, challenge.position);
}
// 跳转到下一关
// https://stackoverflow.com/questions/29244731/react-router-how-to-manually-invoke-link
// this.context.router.push('/sample');
if (goNext === true) {
if (next_game) { // https://www.trustie.net/issues/18573
this.goNext = true;
}
// 隐藏掉效果查看页面
window.$('#picture_display').hide()
}
this.props.onGamePassed();
this.setState({
stared: false
})
} }
if (!game.star) { // 当前关卡没有评星,评星后再跳转 if (!game.star) { // 当前关卡没有评星,评星后再跳转
this.props.saveChallengeStar(game, challenge.position); this.props.saveChallengeStar(game, challenge.position);
@ -111,30 +94,15 @@ class TaskResultLayer extends Component {
// 隐藏掉效果查看页面 // 隐藏掉效果查看页面
window.$('#picture_display').hide() window.$('#picture_display').hide()
} }
// componentDidUpdate(prevProps) { this.props.onGamePassed();
// if (!this.props.challenge) { this.setState({
// return; stared: false
// } })
// const { showLanguagePictrue } = this.props.challenge; }
// if ( prevProps.challenge.showLanguagePictrue != showLanguagePictrue && _fakeRanking() {
// showLanguagePictrue == true ) { const { cost_time } = this.props.game
if (cost_time > 60 * 10) {
// } return Math.floor(Math.random() * 11) + 20
// }
initEffectDisplayServerTimer = () => {
this.setState({ timeRemain: 5 * 60 }, () => {
this.intervalHandler = setInterval(() => {
let timeRemain = this.state.timeRemain
if (timeRemain > 0) {
timeRemain = timeRemain - 1;
} else {
clearInterval(this.intervalHandler);
}
this.setState({ timeRemain })
}, 1000)
})
} }
return Math.floor(((600 - cost_time) / 600) * 100) return Math.floor(((600 - cost_time) / 600) * 100)
@ -269,10 +237,9 @@ class TaskResultLayer extends Component {
</div> </div>
</div> </div>
</div> </div>
</div>
: :
<div></div> <div></div>
} }
</div> </div>
); );
} }

Loading…
Cancel
Save