|
|
|
@ -39,7 +39,7 @@ |
|
|
|
<view class="cellphone-minBox" v-if="cellphone == 2" @click="apple()"> <image src="../../static/img/AppleD.png" mode=""></image></view> |
|
|
|
<!-- v-if="cellphone == 2" --> |
|
|
|
<view class="cellphone-minBox" @click="facebook()"><image src="../../static/img/FacebookD.png" mode=""></image></view> |
|
|
|
<view class="cellphone-minBox" @click="google()"> <image src="../../static/img/GoogleD.png" mode=""></image></view> |
|
|
|
<view class="cellphone-minBox" v-if="cellphone == 1" @click="google()"> <image src="../../static/img/GoogleD.png" mode=""></image></view> |
|
|
|
<!-- v-if="cellphone == 1" --> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -274,22 +274,26 @@ |
|
|
|
} |
|
|
|
appleOauth.login( function(oauth){ |
|
|
|
console.log(oauth); |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}); |
|
|
|
// 授权成功,苹果授权返回的信息在 oauth.target.appleInfo 中 |
|
|
|
// const openid = JSON.parse(oauth.target.appleInfo.identityToken) |
|
|
|
// console.log(openid); |
|
|
|
let data = { |
|
|
|
_action: 'loginbyapple', |
|
|
|
ap_user_id: oauth.target.appleInfo.user, |
|
|
|
ap_user_name: oauth.target.appleInfo.familyName+oauth.target.appleInfo.giveName, |
|
|
|
ap_user_name: oauth.target.appleInfo.familyName, |
|
|
|
ap_user_first_name: oauth.target.appleInfo.familyName, |
|
|
|
ap_user_middle_name: oauth.target.appleInfo.givenName, |
|
|
|
ap_user_last_name: oauth.target.appleInfo.familyName, |
|
|
|
ap_user_email: oauth.target.appleInfo.email |
|
|
|
} |
|
|
|
uni.setStorageSync('user_info', {nickname: oauth.target.appleInfo.familyName}) |
|
|
|
uni.setStorageSync('user_info', {email: oauth.target.appleInfo.email}) |
|
|
|
defaultRequest(data).then(res => { |
|
|
|
console.info(res) |
|
|
|
if (res.error == 0) { |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}); |
|
|
|
uni.showToast({ |
|
|
|
title:'Login is successful, please reopen the App to load information', |
|
|
|
icon:'none', |
|
|
|
@ -297,6 +301,18 @@ |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
// defaultRequest(data).then(res => { |
|
|
|
// console.info(res) |
|
|
|
// console.log('===================================='); |
|
|
|
// if (res.error == 0) { |
|
|
|
// console.log(openid); |
|
|
|
// uni.showToast({ |
|
|
|
// title:'Login is successful, please reopen the App to load information', |
|
|
|
// icon:'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
|
|
|
|
}, function(err) { |
|
|
|
console.log(err); |
|
|
|
@ -387,17 +403,23 @@ |
|
|
|
fb_user_last_name: '', |
|
|
|
fb_user_email: info.userInfo.email |
|
|
|
} |
|
|
|
uni.setStorageSync('user_info', {nickname: info.userInfo.nickName}) |
|
|
|
uni.setStorageSync('user_info', {email: info.userInfo.email}) |
|
|
|
// uni.setStorageSync('user_info', 'info.userInfo'); |
|
|
|
defaultRequest(data).then(res => { |
|
|
|
console.info(res) |
|
|
|
if (res.error == 0) { |
|
|
|
uni.showLoading({ |
|
|
|
title: '加载中' |
|
|
|
}); |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}); |
|
|
|
uni.showLoading({ |
|
|
|
title: '脸书用户登录成功', |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
// uni.showLoading({ |
|
|
|
// title: '脸书用户登录成功', |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
@ -408,110 +430,128 @@ |
|
|
|
// 登录授权失败 |
|
|
|
// err.code是错误码 |
|
|
|
uni.showLoading({ |
|
|
|
title: '脸书用户授权失败', |
|
|
|
title: err.errMsg + err.errCode + err.code, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
// uni.showLoading({ |
|
|
|
// title: '脸书用户授权失败', |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 谷歌 |
|
|
|
google(){ |
|
|
|
// var googleOauth = null; |
|
|
|
// plus.oauth.getServices(function(services) { |
|
|
|
// for (var i in services) { |
|
|
|
// var service = services[i]; |
|
|
|
// // 获取微信登录对象 |
|
|
|
// if (service.id == 'google') { |
|
|
|
// googleOauth = service; |
|
|
|
// break; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// googleOauth.login( function(oauth){ |
|
|
|
// // 授权成功,googleOauth.authResult 中保存授权信息 |
|
|
|
// console.log(googleOauth.authResult); |
|
|
|
// let data = { |
|
|
|
// _action: 'loginbygoogle', |
|
|
|
// fb_user_id: googleOauth.authResult.openid, |
|
|
|
// fb_user_name: '', |
|
|
|
// fb_user_first_name: '', |
|
|
|
// fb_user_middle_name: '', |
|
|
|
// fb_user_last_name: '', |
|
|
|
// fb_user_email: googleOauth.authResult.email |
|
|
|
// } |
|
|
|
// defaultRequest(data).then(res => { |
|
|
|
// console.info(res) |
|
|
|
// if (res.error == 0) { |
|
|
|
// uni.navigateBack({ |
|
|
|
// delta: 1 |
|
|
|
// }); |
|
|
|
// uni.showLoading({ |
|
|
|
// title: '谷歌用户登录成功', |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// }, function(err) { |
|
|
|
// console.log(err); |
|
|
|
// uni.showLoading({ |
|
|
|
// title: '谷歌用户登录失败', |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// // 登录授权失败 |
|
|
|
// // err.code是错误码 |
|
|
|
// }) |
|
|
|
// }, function(err) { |
|
|
|
// console.log(err); |
|
|
|
// // 获取 services 失败 |
|
|
|
// }) |
|
|
|
|
|
|
|
uni.login({ |
|
|
|
provider: 'google', |
|
|
|
success: function (loginRes) { |
|
|
|
// 登录成功 |
|
|
|
uni.getUserInfo({ |
|
|
|
provider: 'google', |
|
|
|
success: function(info) { |
|
|
|
// 获取用户信息成功, info.authResult保存用户信息 |
|
|
|
console.log(info); |
|
|
|
let data = { |
|
|
|
_action: 'loginbygoogle', |
|
|
|
fb_user_id: info.authResult.openid, |
|
|
|
fb_user_name: '', |
|
|
|
fb_user_first_name: '', |
|
|
|
fb_user_middle_name: '', |
|
|
|
fb_user_last_name: '', |
|
|
|
fb_user_email: info.authResult.email |
|
|
|
} |
|
|
|
defaultRequest(data).then(res => { |
|
|
|
console.info(res) |
|
|
|
if (res.error == 0) { |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}); |
|
|
|
uni.showLoading({ |
|
|
|
title: '谷歌用户登录成功', |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
fail: function (err) { |
|
|
|
var googleOauth = null; |
|
|
|
plus.oauth.getServices(function(services) { |
|
|
|
for (var i in services) { |
|
|
|
var service = services[i]; |
|
|
|
// 获取微信登录对象 |
|
|
|
if (service.id == 'google') { |
|
|
|
googleOauth = service; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
googleOauth.login( function(oauth){ |
|
|
|
// 授权成功,googleOauth.authResult 中保存授权信息 |
|
|
|
console.log(googleOauth.authResult); |
|
|
|
let data = { |
|
|
|
_action: 'loginbygoogle', |
|
|
|
gg_user_id: googleOauth.authResult.openid, |
|
|
|
gg_user_name: googleOauth.authResult.nickName, |
|
|
|
gg_user_first_name: '', |
|
|
|
gg_user_middle_name: '', |
|
|
|
gg_user_last_name: '', |
|
|
|
gg_user_email: googleOauth.authResult.email |
|
|
|
} |
|
|
|
uni.setStorageSync('user_info', {email: googleOauth.authResult.email}) |
|
|
|
uni.setStorageSync('user_info', {nickname: googleOauth.authResult.nickName}) |
|
|
|
// uni.setStorageSync('user_info.data.nickname', 'googleOauth.authResult.nickName'); |
|
|
|
defaultRequest(data).then(res => { |
|
|
|
console.info(res) |
|
|
|
if (res.error == 0) { |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}); |
|
|
|
uni.showLoading({ |
|
|
|
title: '谷歌用户登录成功', |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, function(err) { |
|
|
|
console.log(err); |
|
|
|
uni.showLoading({ |
|
|
|
title: '谷歌用户授权失败', |
|
|
|
title: err.errMsg + err.errCode + err.code, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
// 登录授权失败 |
|
|
|
// err.code是错误码 |
|
|
|
} |
|
|
|
}); |
|
|
|
// uni.showLoading({ |
|
|
|
// title: '谷歌用户登录失败', |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// 登录授权失败 |
|
|
|
// err.code是错误码 |
|
|
|
}) |
|
|
|
}, function(err) { |
|
|
|
console.log(err); |
|
|
|
uni.showLoading({ |
|
|
|
title: err.errMsg + err.errCode + err.code, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
// 获取 services 失败 |
|
|
|
}) |
|
|
|
|
|
|
|
// uni.login({ |
|
|
|
// provider: 'google', |
|
|
|
// success: function (loginRes) { |
|
|
|
// // 登录成功 |
|
|
|
// uni.getUserInfo({ |
|
|
|
// provider: 'google', |
|
|
|
// success: function(info) { |
|
|
|
// // 获取用户信息成功, info.authResult保存用户信息 |
|
|
|
// console.log(info); |
|
|
|
// let data = { |
|
|
|
// _action: 'loginbygoogle', |
|
|
|
// gg_user_id: info.authResult.openid, |
|
|
|
// gg_user_name: info.authResult.nickName, |
|
|
|
// gg_user_first_name: '', |
|
|
|
// gg_user_middle_name: '', |
|
|
|
// gg_user_last_name: '', |
|
|
|
// gg_user_email: info.authResult.email |
|
|
|
// } |
|
|
|
// defaultRequest(data).then(res => { |
|
|
|
// console.info(res) |
|
|
|
// if (res.error == 0) { |
|
|
|
// uni.navigateBack({ |
|
|
|
// delta: 1 |
|
|
|
// }); |
|
|
|
// uni.showLoading({ |
|
|
|
// title: '谷歌用户登录成功', |
|
|
|
// icon: 'none', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// }, |
|
|
|
// fail: function (err) { |
|
|
|
// console.log(err); |
|
|
|
// uni.showLoading({ |
|
|
|
// title: err.errMsg + err.errCode + err.code, |
|
|
|
// icon: 'none', |
|
|
|
// duration: 20000000 |
|
|
|
// }) |
|
|
|
// // 登录授权失败 |
|
|
|
// // err.code是错误码 |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
}, |
|
|
|
// 登录 |
|
|
|
|