Authored by 李奇

登录相关sdk api升级

... ... @@ -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) {
... ...
... ... @@ -51,17 +51,18 @@ export default class Prize extends PureComponent {
yaSDK.link(e);
};
componentDidMount() {
yaSDK.getUid().then(async uid => {
let result = await prize({
act_id: +yaSDK.getQueryObj().actId,
uid: uid || +yaSDK.getQueryObj().uid
});
async componentDidMount() {
let user = await yaSDK.getUser();
let {uid} = user;
this.setState({
pending: false,
prizes: result.data
});
let result = await prize({
act_id: +yaSDK.getQueryObj().actId,
uid: uid || +yaSDK.getQueryObj().uid
});
this.setState({
pending: false,
prizes: result.data
});
}
... ...
... ... @@ -67,7 +67,7 @@
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.3",
"webpack-merge": "^4.1.4",
"yoho-activity-sdk": "1.0.7"
"yoho-activity-sdk": "1.0.8"
},
"author": "陈峰 <feng.chen@yoho.cn>",
"license": "ISC",
... ...
... ... @@ -6444,6 +6444,6 @@ yargs@^7.0.0:
y18n "^3.2.1"
yargs-parser "^5.0.0"
yoho-activity-sdk@1.0.7:
version "1.0.7"
resolved "http://npm.yohops.com/yoho-activity-sdk/-/yoho-activity-sdk-1.0.7.tgz#c7a7f28b0f80a783a1dac3e8bde08b4d99e2b2a6"
yoho-activity-sdk@1.0.8:
version "1.0.8"
resolved "http://npm.yohops.com/yoho-activity-sdk/-/yoho-activity-sdk-1.0.8.tgz#e78bb0dbf25c22e97dd6aa283e1e4fc27659c154"
... ...