1.网站接入QQ登录的好处

QQ登录使网站可以免除注册的流程,并充分利用庞大的QQ用户群来实现快速传播;网站接入QQ登录后,简化用户注册流程,更有效率的提高转化用户流量。

2.网站接入QQ登录之前需要申请 let nowUrl = location.href; let result = /code=(\w*)&state=([0-9]*)/.exec(nowUrl); if(result){ window.parent.postMessage(nowUrl,'*'); }

4.网站前端打开QQ登录授权页面 !function () { const state = Number(new Date()).toString(); window.sessionStorage.setItem('state', state) const appid = "101886199" const redirect_uri = "http%3A%2F%2Fwww.zeropaas.com%2FQQLogin" const url = "" + appid + "&redirect_uri=" + redirect_uri + "&state=" + state; window.open(url, '', 'width=750,height=450') }()

5.网站前端QQ登录授权成功之后的处理 window.onmessage = (e)=> { const codeObj = e.data let oldState = window.sessionStorage.getItem('state'); let newState = codeObj.state; if(oldState === newState){ thirdLogin(1,codeObj.code,1,$this.sessionID,0,null) //向云端发送第三登录事件,code是QQ登录码 if ($lm_para.$result [0] === null) { $this.$router.push('/') //QQ登录成功,并且不要绑定手机号 } else { $this.openID = result[0] //QQ登录成功,并且不要绑定手机号 $this.compShow('bindingPhone') } } window.onmessage = null },

6.网站云端获取QQopenid和access_token function getOpenid_QQ(appid, appSecret,code, successCB, errorCB) { const request = require(global.nodePath + "/node_modules/request"); const redirectURI = require('./qqConfig').getRedirectUrl(); let url_1 = " grant_type=authorization_code&client_id=" + appid + "&client_secret=" + appSecret + "&redirect_uri=" + encodeURIComponent(redirectURI) + "&code=" + code; request.get( { url: url1, method: "GET", json: true, headers: { "Content-type": "application/json", }, }, function (error, response, body) { if (response.statusCode == 200) { let data = JSON.stringify(body, null, 4); let data1 = (JSON.parse(data)); let access_token = data1.access_token; request.get({ url: "" + access_token }, function (error, response, body) { if (response.statusCode == 200) { var userinfo = JSON.parse(body); let openid = userinfo.openid; success(access_token,openid); } else { console.log('获取openid失败!', response.statusCode); } } ); let openid = data1.openid; successCB(access_token, openid); } else { errorCB(['获取access_token失败!状态码:'+ response.statusCode]); } } );

7.微信登录和QQ登录的区别

微信登录可以内嵌网站登录页面,也可以打开微信登录授权页面,QQ登录不可以内嵌网站登录授权页面,必须打开QQ登录授权页面,如果是打开微信或QQ登录授权页面,则登录授权成功后必须关闭该页面。

本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。