// facebook sdk
export const insertFacebookSdk = () => {
const url = https://connect.facebook.net/${lang}/sdk.js
;
return insertSDK('facebookSDK', url);
};
// 插入三方登录sdk
insertFacebookSdk().then(() => {
this.fbLoaded = true;
});
// facebook sdk 初始化
if (!window.fbAsyncInit) {
window.fbAsyncInit = () => {
window.FB.init({
appId: window.baseConfig.facebookClientId,
cookie: true,
xfbml: true,
version: 'v4.0'
});
window.FB.AppEvents.logPageView();
};
}
// 点击Facebook登录按钮
faceBookLoginHandler () {
this.parent.parent.resetLoginData();
logReport({ eventId: '106-1-1-37' });
window.FB.login((response) => { }, { scope: 'public_profile,user_birthday,user_gender' });
window.FB.getLoginStatus((response) => {
console.log(response, 'facebook---');
if (response.status === 'connected') {
const accessToken = response.authResponse.accessToken;
// 正常登录接口
this.loginHandler({
accessToken: accessToken,
loginType: 2,
});
} else {
logReport({
eventId: '106-1-1-38',
freeName2: {
reason: response.status
}
});
}
});
},