Authored by 李奇

抽奖嵌入app

... ... @@ -47,7 +47,7 @@ export default class wheelSurf extends PureComponent {
// 登录状态
this.state.query = yaSDK.getQueryObj() || {};
this.state.uid = +(cookie.load('uid') || this.state.query.uid || 0);
this.state.uid = +(this.state.query.uid || cookie.load('uid') || 0);
yaSDK.getUid().then(async (uid) => {
if (uid && uid === this.state.uid) {
... ... @@ -56,12 +56,33 @@ export default class wheelSurf extends PureComponent {
isLogin: !!uid
});
// set cookies
if (!cookie.load('uid')) {
cookie.save('uid', this.state.uid);
cookie.save('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: '/' });
switch (yaSDK.env) {
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_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('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_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');
... ... @@ -99,6 +120,7 @@ export default class wheelSurf extends PureComponent {
console.log('开始抽奖');
this.state.canStart = false;
let result = await start({
act_id: +this.state.query.actId,
uid: cookie.load('uid'),
... ...