...
|
...
|
@@ -15,6 +15,7 @@ export default class wheelSurf extends PureComponent { |
|
|
super(props);
|
|
|
this.state = {
|
|
|
uid: 0,
|
|
|
user: {},
|
|
|
epPrize: {},
|
|
|
query: {},
|
|
|
canStart: true, // 可以抽奖
|
...
|
...
|
@@ -46,81 +47,81 @@ export default class wheelSurf extends PureComponent { |
|
|
}
|
|
|
|
|
|
init = async () => {
|
|
|
|
|
|
// 登录状态
|
|
|
this.state.query = yaSDK.getQueryObj() || {};
|
|
|
this.state.uid = +(this.state.query.uid || cookie.load('uid') || 0);
|
|
|
|
|
|
yaSDK.getUid().then(async (uid) => {
|
|
|
if (uid && uid === this.state.uid) {
|
|
|
this.setState({
|
|
|
uid,
|
|
|
isLogin: !!uid
|
|
|
});
|
|
|
|
|
|
switch (yaSDK.env) {
|
|
|
case 'h5':
|
|
|
if (!cookie.load('uid')) {
|
|
|
cookie.save('uid', this.state.uid);
|
|
|
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: '/' });
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case 'miniprogram':
|
|
|
cookie.save('uid', this.state.uid);
|
|
|
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('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;
|
|
|
|
|
|
default:
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
cookie.remove('uid');
|
|
|
cookie.remove('app_session_key');
|
|
|
cookie.remove('app_client_type');
|
|
|
cookie.remove('app_version');
|
|
|
}
|
|
|
|
|
|
let params = {act_id: +this.state.query.actId};
|
|
|
let user = await yaSDK.getUser();
|
|
|
let {uid, sessionKey, sessionType, appVersion} = user;
|
|
|
|
|
|
this.state.user = user;
|
|
|
|
|
|
if (uid) {
|
|
|
this.setState({
|
|
|
uid,
|
|
|
isLogin: !!uid
|
|
|
});
|
|
|
|
|
|
if (this.state.uid) {
|
|
|
params.uid = this.state.uid;
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
cookie.remove('uid');
|
|
|
cookie.remove('app_session_key');
|
|
|
cookie.remove('app_client_type');
|
|
|
cookie.remove('app_version');
|
|
|
}
|
|
|
|
|
|
let params = {act_id: +this.state.query.actId};
|
|
|
|
|
|
if (uid) {
|
|
|
params.uid = uid;
|
|
|
}
|
|
|
|
|
|
let result = await conf(params);
|
|
|
let result = await conf(params);
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
|
|
|
if (yaSDK.env === 'miniprogram') {
|
|
|
this.simplifyUrl(result.data.conf);
|
|
|
}
|
|
|
|
|
|
this.setState({
|
|
|
conf: result.data.conf,
|
|
|
epPrize: result.data.emptyPrize,
|
|
|
totalParts: result.data.prize,
|
|
|
remainCount: result.data.residueCount,
|
|
|
dayLeftTimesTip: result.data.conf.btm_tip_one,
|
|
|
startType: result.data.startType !== false,
|
|
|
startErrorMsg: result.data.errorMsg || ''
|
|
|
});
|
|
|
this.setWxShare();
|
|
|
} else {
|
|
|
console.log(result.message)
|
|
|
if (result.code === 200) {
|
|
|
|
|
|
if (yaSDK.env === 'miniprogram') {
|
|
|
this.simplifyUrl(result.data.conf);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.setState({
|
|
|
conf: result.data.conf,
|
|
|
epPrize: result.data.emptyPrize,
|
|
|
totalParts: result.data.prize,
|
|
|
remainCount: result.data.residueCount,
|
|
|
dayLeftTimesTip: result.data.conf.btm_tip_one,
|
|
|
startType: result.data.startType !== false,
|
|
|
startErrorMsg: result.data.errorMsg || ''
|
|
|
});
|
|
|
this.setWxShare();
|
|
|
} else {
|
|
|
console.log(result.message)
|
|
|
}
|
|
|
};
|
|
|
|
|
|
simplifyUrl = (conf) => {
|
...
|
...
|
@@ -166,13 +167,14 @@ export default class wheelSurf extends PureComponent { |
|
|
});
|
|
|
|
|
|
let result;
|
|
|
|
|
|
try {
|
|
|
result = await start({
|
|
|
act_id: +this.state.query.actId,
|
|
|
uid: cookie.load('uid'),
|
|
|
sessionKey: cookie.load('app_session_key'),
|
|
|
sessionType: cookie.load('app_client_type'),
|
|
|
appVersion: cookie.load('app_version')
|
|
|
uid: this.state.user.uid,
|
|
|
sessionKey: this.state.user.sessionKey,
|
|
|
sessionType: this.state.user.sessionType,
|
|
|
appVersion: this.state.user.appVersion
|
|
|
});
|
|
|
|
|
|
if (result.code !== 200) {
|
...
|
...
|
|