From 49a281e51d55df864f79a65a1e2688a49ec20480 Mon Sep 17 00:00:00 2001
From: hubingliang
Date: Tue, 3 Apr 2018 09:45:10 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E7=99=BB=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
fangija-zsyf/js/login/wxLogin.js | 52 ++++++++++++++++++++++++----
fangija-zsyf/manifest.json | 14 ++------
fangija-zsyf/views/user/codeSms.html | 6 ++--
3 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/fangija-zsyf/js/login/wxLogin.js b/fangija-zsyf/js/login/wxLogin.js
index 1b144a1..64ae6cd 100644
--- a/fangija-zsyf/js/login/wxLogin.js
+++ b/fangija-zsyf/js/login/wxLogin.js
@@ -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)
+ }
+ })
}
diff --git a/fangija-zsyf/manifest.json b/fangija-zsyf/manifest.json
index 98399d1..e9cc7b5 100644
--- a/fangija-zsyf/manifest.json
+++ b/fangija-zsyf/manifest.json
@@ -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
diff --git a/fangija-zsyf/views/user/codeSms.html b/fangija-zsyf/views/user/codeSms.html
index dd132a4..bcde2e6 100644
--- a/fangija-zsyf/views/user/codeSms.html
+++ b/fangija-zsyf/views/user/codeSms.html
@@ -71,9 +71,9 @@
第三方登录
-
-
-
+
+
+