第三方登录
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
var auths = {}
|
||||
function plusReady() {
|
||||
plus.oauth.getServices(function(services) {
|
||||
alert("111111111111111111111111")
|
||||
auths = services;
|
||||
for(var i in services){
|
||||
var service=services[i];
|
||||
auths[service.id]=service;
|
||||
}
|
||||
}, function(e) {
|
||||
alert("获取登录服务列表失败:" + e.message + " - " + e.code);
|
||||
});
|
||||
}
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
// 登录认证
|
||||
function webChatLogin(){
|
||||
var auth=auths['weixin'];
|
||||
function loginInfo(dest){
|
||||
var auth=auths[dest];
|
||||
console.log(JSON.stringify(auth))
|
||||
if(auth){
|
||||
var w=null;
|
||||
if(plus.os.name=="Android"){
|
||||
@@ -34,6 +37,43 @@ function webChatLogin(){
|
||||
}
|
||||
}
|
||||
|
||||
function authLogin(type) {
|
||||
console.log("hhhhhhhhhhhhhhhhhhh")
|
||||
//wx获取用户信息
|
||||
function userinfo(a){
|
||||
a.getUserInfo(function(){
|
||||
console.log(JSON.stringify(a))
|
||||
$.showPreloader();
|
||||
if(a.id=='weixin'){
|
||||
var nickname=a.userInfo.nickname||a.userInfo.name||a.userInfo.miliaoNick;
|
||||
var openid = a.authResult.openid;
|
||||
var accessToken = a.authResult.access_token;
|
||||
var unionid = a.userInfo.unionid;
|
||||
var headImg = a.userInfo.headimgurl;
|
||||
wxlogin(openid,unionid,accessToken,nickname,headImg)
|
||||
}else if(a.id=='qq'){
|
||||
var nickname=a.userInfo.nickname;
|
||||
var openid = a.authResult.openid;
|
||||
var accessToken = a.authResult.access_token;
|
||||
var headImg = a.userInfo.headimgurl;
|
||||
}else{
|
||||
//微博信息获取
|
||||
}
|
||||
|
||||
},function(e){
|
||||
$.toast("获取微信用户信息失败:["+e.code+"]:"+e.message);
|
||||
});
|
||||
}
|
||||
|
||||
function wxlogin(openid, unionid, accessToken, nickname, headImg) {
|
||||
axios.post("/rest/user/wxLogin", {openid:openid, unionid:unionid, accessToken: accessToken, nickname:nickname,headImg:headImg})
|
||||
.then(function (response) {
|
||||
$.hidePreloader();
|
||||
if(response.data.status){
|
||||
console.log(JSON.stringify(response.data))
|
||||
//跳转页面
|
||||
|
||||
}else{
|
||||
//登录失败
|
||||
$.toast(response.data.data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"icons": {
|
||||
"144": "icon.png"
|
||||
},
|
||||
"launch_path": "main.html",/*应用的入口页面,默认为根目录下的index.html;支持网络地址,必须以http://或https://开头*/
|
||||
"launch_path": "/views/user/codeSms.html",/*应用的入口页面,默认为根目录下的index.html;支持网络地址,必须以http://或https://开头*/
|
||||
"developer": {
|
||||
"name": "",/*开发者名称*/
|
||||
"email": "",/*开发者邮箱地址*/
|
||||
@@ -101,9 +101,7 @@
|
||||
"Maps": {
|
||||
"description": "地图"
|
||||
},
|
||||
"OAuth": {
|
||||
"description": "登录授权"
|
||||
},
|
||||
"OAuth": {},
|
||||
|
||||
"Push": {
|
||||
"description": "消息推送"
|
||||
@@ -312,12 +310,6 @@
|
||||
"description": "可选,微信分享",
|
||||
"appid": "wx734a9e3085abcd90",
|
||||
"appsecret": "47ce59f3c52984c4e193880fb09b12af"
|
||||
},
|
||||
"sina": {
|
||||
"appkey": "3194052034",
|
||||
"appsecret": "e863ae4e4f14d41af3142e5ae06867dd",
|
||||
"redirect_uri": "http://sh.fangjia.com/",
|
||||
"description": "可选,新浪微博分享"
|
||||
}
|
||||
},
|
||||
"payment": {},
|
||||
@@ -325,7 +317,7 @@
|
||||
"weixin": {
|
||||
"appid": "wx734a9e3085abcd90",
|
||||
"appsecret": "47ce59f3c52984c4e193880fb09b12af"
|
||||
}
|
||||
},"qq":{"appid":"1106734669"}
|
||||
}
|
||||
},
|
||||
"debug": true
|
||||
|
||||
@@ -71,9 +71,9 @@
|
||||
<span>第三方登录</span>
|
||||
</p>
|
||||
<p>
|
||||
<a class="icon icon-loginMode01" id="wxLogin" onclick="webChatLogin()"></a>
|
||||
<a href="05_mine00_login04_set.html" class="icon icon-loginMode02"></a>
|
||||
<a href="05_mine00_login04_set.html" class="icon icon-loginMode03" id="qqLogin"></a>
|
||||
<a class="icon icon-loginMode01" id="wxLogin" onclick="loginInfo('weixin')"></a>
|
||||
<a class="icon icon-loginMode02" id="qqLogin" onclick="loginInfo('sinaweibo')"></a>
|
||||
<a class="icon icon-loginMode03" id="qqLogin" onclick="loginInfo('qq')"></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user