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