qq login
This commit is contained in:
@@ -48,21 +48,23 @@ function userinfo(a){
|
||||
var accessToken = a.authResult.access_token;
|
||||
var unionid = a.userInfo.unionid;
|
||||
var headImg = a.userInfo.headimgurl;
|
||||
wxLogin(openid,unionid,accessToken,nickname,headImg,"weixin")
|
||||
login(openid, unionid, accessToken, nickname, headImg, "weixin", "/rest/user/wxLogin")
|
||||
}else if(a.id=='qq'){
|
||||
var nickname=a.userInfo.nickname;
|
||||
var nickname= a.userInfo.nickname;
|
||||
var openid = a.authResult.openid;
|
||||
var accessToken = a.authResult.access_token;
|
||||
var headImg = a.userInfo.headimgurl;
|
||||
qqLogin(openid,accessToken,nickname,headImg,"qq")
|
||||
var unionid = "";
|
||||
login(openid, unionid, accessToken, nickname, headImg, "qq", "/rest/user/qqLogin")
|
||||
}else{
|
||||
//微博信息获取
|
||||
var nickname=a.userInfo.name||a.userInfo.screen_name;
|
||||
var nickname = a.userInfo.name||a.userInfo.screen_name;
|
||||
var openid = a.authResult.openid;
|
||||
var accessToken = a.authResult.access_token;
|
||||
var headImg = a.userInfo.profile_image_url;
|
||||
var uid = a.authResult.uid
|
||||
weiboLogin(openid,accessToken,nickname,headImg,"sinaweibo")
|
||||
var uid = a.authResult.uid;
|
||||
var unionid = "";
|
||||
login(openid, unionid, accessToken, nickname, headImg, "sinaweibo", "/rest/user/sinaweiboLogin")
|
||||
}
|
||||
|
||||
},function(e){
|
||||
@@ -70,52 +72,24 @@ function userinfo(a){
|
||||
});
|
||||
}
|
||||
|
||||
function wxLogin(openid, unionid, accessToken, nickname, headImg,loginFrom) {
|
||||
axios.post("/rest/user/wxLogin", {loginFrom:loginFrom,openid:openid, unionid:unionid, accessToken: accessToken, nickname:nickname,headImg:headImg})
|
||||
function login(openid, unionid, accessToken, nickname, headImg, loginFrom, uri) {
|
||||
axios.post(uri, {loginFrom:loginFrom,openid:openid, unionid:unionid, accessToken: accessToken, nickname:nickname,headImg:headImg})
|
||||
.then(function (response) {
|
||||
$.hidePreloader();
|
||||
if(response.data.status){
|
||||
if("no"==response.data.message){
|
||||
var resData = response.data;
|
||||
if(resData.status){
|
||||
if(resData.data == ""){
|
||||
//跳转绑定手机号码页面
|
||||
console.log(response.data.message)
|
||||
clicked('../user/bindingMobile.html',true,false,{},{loginFrom:loginFrom,openid:openid, unionid:unionid, accessToken: accessToken, nickname:nickname,headImg:headImg},function(){
|
||||
back();
|
||||
})
|
||||
}else{
|
||||
|
||||
localStorage.setItem("user_token", resData.data);
|
||||
back();
|
||||
}
|
||||
}else{
|
||||
//登录失败
|
||||
$.toast(response.data.data)
|
||||
}
|
||||
})
|
||||
}
|
||||
function qqLogin(openid, accessToken, nickname, headImg,loginFrom) {
|
||||
axios.post("/rest/user/qqLogin", {loginFrom:loginFrom,openid:openid, accessToken: accessToken, nickname:nickname,headImg:headImg})
|
||||
.then(function (response) {
|
||||
$.hidePreloader();
|
||||
if(response.data.status){
|
||||
if("no"==response.data.message){
|
||||
//跳转绑定手机号码页面
|
||||
}else{
|
||||
|
||||
}
|
||||
}else{
|
||||
//登录失败
|
||||
$.toast(response.data.data)
|
||||
}
|
||||
})
|
||||
}
|
||||
function weiboLogin(openid, accessToken, nickname, headImg,loginFrom) {
|
||||
axios.post("/rest/user/sinaweiboLogin", {loginFrom:loginFrom,openid:openid, accessToken: accessToken, nickname:nickname,headImg:headImg})
|
||||
.then(function (response) {
|
||||
$.hidePreloader();
|
||||
if(response.data.status){
|
||||
if("no"==response.data.message){
|
||||
//跳转绑定手机号码页面
|
||||
}else{
|
||||
|
||||
}
|
||||
}else{
|
||||
//登录失败
|
||||
$.toast(response.data.data)
|
||||
$.toast(resData.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<div class="page-group" id="app">
|
||||
<div class="page page-current">
|
||||
<header class="bar bar-nav">
|
||||
<button class="button button-link button-nav pull-left" onclick="history.go(-1)">
|
||||
<button class="button button-link button-nav pull-left" onclick="back()">
|
||||
<span class="icon icon-left"></span>
|
||||
</button>
|
||||
<h1 class="title">绑定账号</h1>
|
||||
@@ -85,6 +85,7 @@ $.config = {router: false}
|
||||
<script type="text/javascript" src="../../js/axios.min.js"></script>
|
||||
<script type="text/javascript" src="../../js/axiosPlugin.js"></script>
|
||||
<script type="text/javascript" src="../../js/plus.info.js" ></script>
|
||||
<script type="text/javascript" src="../../js/common.js" ></script>
|
||||
<script>
|
||||
|
||||
timer = {
|
||||
@@ -110,11 +111,18 @@ timer = {
|
||||
}
|
||||
}
|
||||
|
||||
new Vue({
|
||||
var vue = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
mobile:'',
|
||||
smsCode:''
|
||||
mobile:'', // 手机号码
|
||||
smsCode:'', // 短信验证码
|
||||
loginFrom:'', // 登录类型(weixin,qq,sinaweibo)
|
||||
openid:'', // 微信ID
|
||||
unionid:'', // 微信unionid,
|
||||
accessToken: '',// 微信授权token
|
||||
nickname:'', // 微信昵称
|
||||
headImg:'', // 微信头像
|
||||
deviceId:'' // 设备ID
|
||||
},
|
||||
methods: {
|
||||
// 手机号码检查
|
||||
@@ -169,12 +177,26 @@ new Vue({
|
||||
binding: function() {
|
||||
if (this.checkMobile() && this.checkSmsCode()) {
|
||||
axios.post("/rest/user/bindMobile", {
|
||||
mobile:this.mobile, smsCode:this.smsCode, province:province, city:city, region:region, pushClientId:getPushInfo()
|
||||
mobile:this.mobile,
|
||||
smsCode:this.smsCode,
|
||||
province:province,
|
||||
city:city,
|
||||
region:region,
|
||||
pushClientId:getPushInfo(),
|
||||
loginFrom:this.loginFrom,
|
||||
openid:this.openid,
|
||||
unionid:this.unionid,
|
||||
accessToken:this.accessToken,
|
||||
nickname:this.nickname,
|
||||
headImg:this.headImg,
|
||||
deviceId:this.deviceId
|
||||
})
|
||||
.then(function (response) {
|
||||
var resData = response.data;
|
||||
if (resData.status) {
|
||||
$.toast(resData.message);
|
||||
localStorage.setItem("user_token", resData.data);
|
||||
back();
|
||||
} else {
|
||||
$.toast(resData.message);
|
||||
}
|
||||
@@ -187,6 +209,19 @@ new Vue({
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.addEventListener('plusready', onPlusReady, false);
|
||||
function onPlusReady() {
|
||||
var self = plus.webview.currentWebview();
|
||||
vue.$data.loginFrom = self.loginFrom;
|
||||
vue.$data.openid = self.openid;
|
||||
vue.$data.unionid = self.unionid;
|
||||
vue.$data.accessToken = self.accessToken;
|
||||
vue.$data.nickname = self.nickname;
|
||||
vue.$data.headImg = self.headImg;
|
||||
vue.$data.deviceId = plus.device.uuid;
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -94,7 +94,7 @@ $.config = {router: false}
|
||||
<script type="text/javascript" src="../../js/axiosPlugin.js"></script>
|
||||
<script type="text/javascript" src="../../js/plus.info.js" ></script>
|
||||
<script type="text/javascript" src="../../js/common.js" ></script>
|
||||
|
||||
<script type="text/javascript" src="../../js/login/thirdLogin.js" ></script>
|
||||
<script>
|
||||
|
||||
new Vue({
|
||||
|
||||
Reference in New Issue
Block a user