...
|
...
|
@@ -25,6 +25,7 @@ export default class wheelSurf extends PureComponent { |
|
|
startType: true,
|
|
|
isLogin: false,
|
|
|
dayLeftTimesTip: '',
|
|
|
showRemain: false,
|
|
|
|
|
|
conf: {
|
|
|
loading: ''
|
...
|
...
|
@@ -50,51 +51,82 @@ export default class wheelSurf extends PureComponent { |
|
|
this.state.query = yaSDK.getQueryObj() || {};
|
|
|
|
|
|
let user = await yaSDK.getUser();
|
|
|
let {uid, sessionKey, sessionType, appVersion} = user;
|
|
|
let {uid, sessionKey} = user;
|
|
|
|
|
|
this.state.user = user;
|
|
|
|
|
|
if (uid) {
|
|
|
let setLogin = userInfo => {
|
|
|
this.setState({
|
|
|
uid,
|
|
|
isLogin: !!uid
|
|
|
uid: userInfo.uid,
|
|
|
isLogin: true
|
|
|
});
|
|
|
|
|
|
|
|
|
switch (yaSDK.env) {
|
|
|
case 'h5':
|
|
|
if (!cookie.load('uid')) {
|
|
|
cookie.save('uid', uid);
|
|
|
cookie.save('app_session_key', sessionKey, { path: '/' });
|
|
|
cookie.save('app_client_type', sessionType, { path: '/' });
|
|
|
cookie.save('app_version', appVersion, { path: '/' });
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case 'miniprogram':
|
|
|
cookie.save('uid', uid);
|
|
|
cookie.save('app_session_key', sessionKey, { path: '/' });
|
|
|
cookie.save('app_client_type', sessionType, { path: '/' });
|
|
|
cookie.save('app_version', '6.6.0', { path: '/' });
|
|
|
break;
|
|
|
|
|
|
case 'app':
|
|
|
cookie.save('uid', uid);
|
|
|
cookie.save('app_session_key', sessionKey, { path: '/' });
|
|
|
cookie.save('app_client_type', sessionType, { path: '/' });
|
|
|
cookie.save('app_version', appVersion, { path: '/' });
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
break;
|
|
|
|
|
|
case 'h5':
|
|
|
if (!cookie.load('uid')) {
|
|
|
cookie.save('uid', userInfo.uid);
|
|
|
cookie.save('app_session_key', userInfo.sessionKey, { path: '/' });
|
|
|
cookie.save('app_client_type', userInfo.sessionType, { path: '/' });
|
|
|
cookie.save('app_version', userInfo.appVersion, { path: '/' });
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case 'miniprogram':
|
|
|
cookie.save('uid', userInfo.uid);
|
|
|
cookie.save('app_session_key', userInfo.sessionKey, { path: '/' });
|
|
|
cookie.save('app_client_type', userInfo.sessionType, { path: '/' });
|
|
|
cookie.save('app_version', '6.6.0', { path: '/' });
|
|
|
break;
|
|
|
|
|
|
case 'app':
|
|
|
cookie.save('uid', userInfo.uid);
|
|
|
cookie.save('app_session_key', userInfo.sessionKey, { path: '/' });
|
|
|
cookie.save('app_client_type', userInfo.sessionType, { path: '/' });
|
|
|
cookie.save('app_version', userInfo.appVersion, { path: '/' });
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let updateCount = async (user) => {
|
|
|
let result = await conf({
|
|
|
uid: user.uid,
|
|
|
act_id: +this.state.query.actId
|
|
|
});
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
this.setState({
|
|
|
remainCount: result.data.residueCount,
|
|
|
showRemain: true
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
if (uid && sessionKey) {
|
|
|
setLogin(user);
|
|
|
} else {
|
|
|
cookie.remove('uid');
|
|
|
cookie.remove('app_session_key');
|
|
|
cookie.remove('app_client_type');
|
|
|
cookie.remove('app_version');
|
|
|
|
|
|
// fix android can't auto reload page after login
|
|
|
if (yaSDK.env === 'app') {
|
|
|
let timer = setInterval(async () => {
|
|
|
let user = await yaSDK.getUser();
|
|
|
|
|
|
if (user.uid && user.sessionKey) {
|
|
|
clearInterval(timer);
|
|
|
setLogin(user);
|
|
|
updateCount(user);
|
|
|
}
|
|
|
}, 2000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
let params = {act_id: +this.state.query.actId};
|
|
|
|
|
|
if (uid) {
|
...
|
...
|
@@ -114,6 +146,7 @@ export default class wheelSurf extends PureComponent { |
|
|
epPrize: result.data.emptyPrize,
|
|
|
totalParts: result.data.prize,
|
|
|
remainCount: result.data.residueCount,
|
|
|
showRemain: +uid > 0,
|
|
|
dayLeftTimesTip: result.data.conf.btm_tip_one,
|
|
|
startType: result.data.startType !== false,
|
|
|
startErrorMsg: result.data.errorMsg || ''
|
...
|
...
|
@@ -143,7 +176,7 @@ export default class wheelSurf extends PureComponent { |
|
|
|
|
|
delete query['openby:yohobuy'];
|
|
|
|
|
|
conf[key] = `${url}?${queryString.stringify(query)}`
|
|
|
conf[key] = `${url}?${queryString.stringify(query)}`;
|
|
|
|
|
|
console.log(conf[key])
|
|
|
});
|
...
|
...
|
@@ -358,7 +391,7 @@ export default class wheelSurf extends PureComponent { |
|
|
};
|
|
|
|
|
|
render() {
|
|
|
let {conf, slowEnding, isLogin, startEnded, remainCount} = this.state;
|
|
|
let {conf, slowEnding, isLogin, startEnded, remainCount, showRemain} = this.state;
|
|
|
|
|
|
if (!conf.id) {
|
|
|
return (
|
...
|
...
|
@@ -380,7 +413,7 @@ export default class wheelSurf extends PureComponent { |
|
|
<img className="wheel-bg" id="rotateWheel" src={conf.wheel_bg}/>
|
|
|
<img onClick={()=>{this.start()}} className="start-btn-bg" src={conf.prize_btn_bg}/>
|
|
|
{
|
|
|
isLogin ?
|
|
|
isLogin && showRemain ?
|
|
|
(<div className="tips">
|
|
|
<p className="tip-1">{`今日剩余次数:${remainCount}次`}</p>
|
|
|
</div>) : ''
|
...
|
...
|
|