...
|
...
|
@@ -11,6 +11,7 @@ import { |
|
|
|
|
|
import Resource from '../components/resource';
|
|
|
import BottomButton from '../components/bottom-button';
|
|
|
import TipModal from '../components/tip-modal';
|
|
|
|
|
|
export default class wheelSurf extends PureComponent {
|
|
|
constructor(props) {
|
...
|
...
|
@@ -24,6 +25,7 @@ export default class wheelSurf extends PureComponent { |
|
|
slowEnding: false, // 减速结束
|
|
|
startEnded: false, // 已结束
|
|
|
|
|
|
startType: true,
|
|
|
isLogin: false,
|
|
|
|
|
|
conf: {
|
...
|
...
|
@@ -32,6 +34,11 @@ export default class wheelSurf extends PureComponent { |
|
|
totalParts: '',
|
|
|
remainCount: '',
|
|
|
|
|
|
showTipModal: false,
|
|
|
modalTip: '',
|
|
|
modalBtnText: '',
|
|
|
|
|
|
gotDesc: '',
|
|
|
angle: 0, // 当前旋转角度
|
|
|
speed: 0, // 旋转速度
|
|
|
stopAngle: 0, // 停止的角度
|
...
|
...
|
@@ -58,7 +65,7 @@ export default class wheelSurf extends PureComponent { |
|
|
case 'h5':
|
|
|
if (!cookie.load('uid')) {
|
|
|
cookie.save('uid', this.state.uid);
|
|
|
cookie.save('session_key', this.state.query.session_key, { path: '/' });
|
|
|
cookie.save('app_session_key', this.state.query.session_key, { path: '/' });
|
|
|
cookie.save('app_client_type', this.state.query.app_client_type, { path: '/' });
|
|
|
cookie.save('app_version', this.state.query.app_version, { path: '/' });
|
|
|
}
|
...
|
...
|
@@ -66,14 +73,14 @@ export default class wheelSurf extends PureComponent { |
|
|
|
|
|
case 'miniprogram':
|
|
|
cookie.save('uid', this.state.uid);
|
|
|
cookie.save('session_key', this.state.query.session_key, { path: '/' });
|
|
|
cookie.save('app_session_key', this.state.query.session_key, { path: '/' });
|
|
|
cookie.save('app_client_type', this.state.query.client_type, { path: '/' });
|
|
|
cookie.save('app_version', '6.6.0', { path: '/' });
|
|
|
break;
|
|
|
|
|
|
case 'app':
|
|
|
cookie.save('uid', this.state.uid);
|
|
|
cookie.save('session_key', this.state.query.session_key, { path: '/' });
|
|
|
cookie.save('app_session_key', this.state.query.session_key, { path: '/' });
|
|
|
cookie.save('app_client_type', this.state.query.client_type, { path: '/' });
|
|
|
cookie.save('app_version', this.state.query.app_version, { path: '/' });
|
|
|
break;
|
...
|
...
|
@@ -84,7 +91,7 @@ export default class wheelSurf extends PureComponent { |
|
|
}
|
|
|
} else {
|
|
|
cookie.remove('uid');
|
|
|
cookie.remove('session_key');
|
|
|
cookie.remove('app_session_key');
|
|
|
cookie.remove('app_client_type');
|
|
|
cookie.remove('app_version');
|
|
|
}
|
...
|
...
|
@@ -102,6 +109,8 @@ export default class wheelSurf extends PureComponent { |
|
|
conf: result.data.conf,
|
|
|
totalParts: result.data.prize,
|
|
|
remainCount: result.data.residueCount,
|
|
|
startType: result.data.startType !== false,
|
|
|
startErrorMsg: result.data.errorMsg || ''
|
|
|
});
|
|
|
this.setWxShare();
|
|
|
} else {
|
...
|
...
|
@@ -121,19 +130,17 @@ export default class wheelSurf extends PureComponent { |
|
|
};
|
|
|
|
|
|
begin = async () => {
|
|
|
// 抽奖前验证是否可以抽奖
|
|
|
if (!this.state.remainCount) {
|
|
|
console.log('抽奖机会已经用完了');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
console.log('开始抽奖');
|
|
|
|
|
|
this.state.canStart = false;
|
|
|
this.setState({
|
|
|
remainCount: this.state.remainCount - 1
|
|
|
});
|
|
|
|
|
|
let result = await start({
|
|
|
act_id: +this.state.query.actId,
|
|
|
uid: cookie.load('uid'),
|
|
|
sessionKey: cookie.load('app_session_key'),
|
|
|
sessionKey: cookie.load('session_key'),
|
|
|
sessionType: cookie.load('app_client_type'),
|
|
|
appVersion: cookie.load('app_version')
|
|
|
});
|
...
|
...
|
@@ -145,6 +152,7 @@ export default class wheelSurf extends PureComponent { |
|
|
let timer = setTimeout(() => {
|
|
|
clearTimeout(timer);
|
|
|
this.state.stopAngle = this.calcStopAngle(result.data.prize_idx);
|
|
|
this.state.gotDesc = result.data.desc;
|
|
|
this.setState({
|
|
|
slowEnding: true
|
|
|
});
|
...
|
...
|
@@ -161,6 +169,24 @@ export default class wheelSurf extends PureComponent { |
|
|
if (!isLogin) {
|
|
|
return yaSDK.goLogin();
|
|
|
}
|
|
|
|
|
|
// 抽奖前验证是否可以抽奖
|
|
|
if (!this.state.startType) {
|
|
|
return this.setState({
|
|
|
showTipModal: true,
|
|
|
modalTip: '活动尚未开始',
|
|
|
modalBtnText: '确定'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 抽奖前验证是否可以抽奖
|
|
|
if (!this.state.remainCount) {
|
|
|
return this.setState({
|
|
|
showTipModal: true,
|
|
|
modalTip: '您今天的抽奖次数已经用完<br/>请明天再来',
|
|
|
modalBtnText: '确定'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (!canStart) {
|
|
|
return;
|
...
|
...
|
@@ -173,7 +199,7 @@ export default class wheelSurf extends PureComponent { |
|
|
rotate = () => {
|
|
|
let {slowEnding, startEnded, remainCount} = this.state;
|
|
|
|
|
|
if (startEnded || !remainCount) {
|
|
|
if (startEnded) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -270,17 +296,25 @@ export default class wheelSurf extends PureComponent { |
|
|
};
|
|
|
|
|
|
shareInApp = () => {
|
|
|
const {conf} = this.state;
|
|
|
|
|
|
let shareData = {
|
|
|
title: '测试title',
|
|
|
link: 'http://www.baidu.com',
|
|
|
desc: '测试描述',
|
|
|
imgUrl: 'http://img11.static.yhbimg.com/yhb-img01/2018/10/11/10/0157b624efd3c0db2e2b0c1c5b84a1fff7.png',
|
|
|
title: conf.share_title,
|
|
|
link: conf.share_url,
|
|
|
desc: conf.share_desc,
|
|
|
imgUrl: conf.share_img,
|
|
|
hideType: ['7', '8', '9']
|
|
|
};
|
|
|
|
|
|
yaSDK.invokeMethod({method: 'go.showshareaction', args: shareData});
|
|
|
};
|
|
|
|
|
|
confirm = () => {
|
|
|
this.setState({
|
|
|
showTipModal: false
|
|
|
});
|
|
|
};
|
|
|
|
|
|
jump = e => {
|
|
|
let $el = e.currentTarget;
|
|
|
let url = $el.getAttribute('data-url');
|
...
|
...
|
@@ -292,7 +326,7 @@ export default class wheelSurf extends PureComponent { |
|
|
};
|
|
|
|
|
|
render() {
|
|
|
const {conf, slowEnding, isLogin, startEnded, remainCount, tryAgainTip} = this.state;
|
|
|
const {conf, slowEnding, isLogin, startEnded, remainCount} = this.state;
|
|
|
|
|
|
if (!conf.id) {
|
|
|
return (
|
...
|
...
|
@@ -320,18 +354,21 @@ export default class wheelSurf extends PureComponent { |
|
|
</div>) : ''
|
|
|
}
|
|
|
|
|
|
<BottomButton links={links}/>
|
|
|
<BottomButton links={links} login={isLogin}/>
|
|
|
<Resource code={conf.bottomContentCode}/>
|
|
|
|
|
|
{slowEnding ? (<img className="prize-hit-bg transition" src={conf.win_prize_bg}/>) : ''}
|
|
|
{startEnded ? (
|
|
|
<div className="got-tip">
|
|
|
<div className="prize-tip">{'恭喜您!中奖了'}</div>
|
|
|
<div className="prize-tip">{this.state.gotDesc}</div>
|
|
|
<span onClick={this.setCanStart} className="try-again">确定</span>
|
|
|
</div>
|
|
|
) : ''}
|
|
|
{slowEnding ? (<span onClick={this.setCanStart} className="close-prize-hit-bg">关闭</span>) : ''}
|
|
|
{slowEnding ? (<img className="prize-hit-start-bg" src={conf.prize_btn_bg}/>) : ''}
|
|
|
{
|
|
|
this.state.showTipModal ? <TipModal tip={this.state.modalTip} btnText={this.state.modalBtnText} confirm={() => {this.confirm()}} /> : ''
|
|
|
}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
...
|
...
|
|