Commit ebd1bd9b authored by maxiaoliang's avatar maxiaoliang

修改登录

parent 99d3c8ef
...@@ -44,10 +44,10 @@ android { ...@@ -44,10 +44,10 @@ android {
Facebook { Facebook {
id 8 id 8
sortId 8 sortId 8
appKey "662970168312513" appKey "1156014961815312"
callbackUri "https://www.baidu.com" callbackUri "https://www.baidu.com"
officialVersion "default" officialVersion "default"
faceBookLoginProtocolScheme "fb662970168312513" faceBookLoginProtocolScheme "fb1156014961815312"
shareByAppClient true shareByAppClient true
enable true enable true
} }
......
...@@ -145,6 +145,7 @@ public class NetConfig { ...@@ -145,6 +145,7 @@ public class NetConfig {
public static final String USER_PHONE_CODE_LOGIN = "app/v3/auth/phoneCodeLogin";//验证码登录 public static final String USER_PHONE_CODE_LOGIN = "app/v3/auth/phoneCodeLogin";//验证码登录
public static final String URL_VERSION = "app/v1/version"; public static final String URL_VERSION = "app/v1/version";
public static final String URL_AUTH_GOOGLE_LOGIN = "app/v1/auth/googleLogin";//绑定谷歌登录 public static final String URL_AUTH_GOOGLE_LOGIN = "app/v1/auth/googleLogin";//绑定谷歌登录
public static final String URL_AUTH_FACEBOOK_LOGIN = "app/v1/auth/facebookLogin";//绑定FaceBook登录
///unifiedpay/gateway/google/替换包名/notify/order ///unifiedpay/gateway/google/替换包名/notify/order
......
...@@ -238,4 +238,11 @@ interface IHomeApi { ...@@ -238,4 +238,11 @@ interface IHomeApi {
@Query("nickname") nickname: String?, @Query("nickname") nickname: String?,
@Query("picture") picture: String? @Query("picture") picture: String?
): Observable<Response<WxBindEntity?>> ): Observable<Response<WxBindEntity?>>
@POST(NetConfig.User.URL_AUTH_FACEBOOK_LOGIN)
fun authFaceBookLogin(
@Query("userID") userID: String?,
@Query("nickname") nickname: String?,
@Query("picture") picture: String?
): Observable<Response<WxBindEntity?>>
} }
\ No newline at end of file
...@@ -35,7 +35,7 @@ class WeChatUtils { ...@@ -35,7 +35,7 @@ class WeChatUtils {
} }
fun isWechatLogin( callback: IsLoginCallBack<IsWeChatLoginEntity>?){ fun isWechatLogin(callback: IsLoginCallBack<IsWeChatLoginEntity>?) {
ApiClient.homeApi.isWxLogin().compose(RxSchedulers.observableIO2Main()) ApiClient.homeApi.isWxLogin().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<IsWeChatLoginEntity>() { .subscribe(object : BaseObserver<IsWeChatLoginEntity>() {
override fun onSuccess(result: IsWeChatLoginEntity?) { override fun onSuccess(result: IsWeChatLoginEntity?) {
...@@ -48,7 +48,7 @@ class WeChatUtils { ...@@ -48,7 +48,7 @@ class WeChatUtils {
} }
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) { override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
callback?.onError(code,errorMsg) callback?.onError(code, errorMsg)
} }
}) })
...@@ -159,7 +159,8 @@ class WeChatUtils { ...@@ -159,7 +159,8 @@ class WeChatUtils {
//授权回调监听,监听oncomplete,onerror,oncancel三种状态 //授权回调监听,监听oncomplete,onerror,oncancel三种状态
plat.platformActionListener = object : PlatformActionListener { plat.platformActionListener = object : PlatformActionListener {
override fun onComplete(p0: Platform?, p1: Int, p2: HashMap<String, Any>?) { override fun onComplete(p0: Platform?, p1: Int, p2: HashMap<String, Any>?) {
Log.e("MXL", "FaceBook:onComplete") Log.e("MXL", "Data:" + p0?.db?.exportData()+"Image:"+p0?.db?.userIcon)
bindFaceBookLogin(p0?.db?.userId, p0?.db?.userName, p0?.db?.userIcon)
} }
override fun onError(arg0: Platform, arg1: Int, arg2: Throwable) { override fun onError(arg0: Platform, arg1: Int, arg2: Throwable) {
...@@ -175,8 +176,28 @@ class WeChatUtils { ...@@ -175,8 +176,28 @@ class WeChatUtils {
plat.showUser(null) plat.showUser(null)
} }
fun bindFaceBookLogin(userId: String?, userName: String?, picture: String?) {
ApiClient.homeApi.authFaceBookLogin(userId, userName, picture)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<WxBindEntity>() {
override fun onSuccess(result: WxBindEntity?) {
SettingPreference.saveToken(result?.token)
UserDataUtils.updateUserInfo(null)
Log.e("MXL", "FaceBook登录成功")
// getShareCon tent(mContext)
// callBack.loginSuccess(lottery)
callBack.loginSuccess("")
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
// callBack.loginSuccess(lottery)
}
})
}
fun GoogleLogin() { fun GoogleLogin() {
// MobSDK.submitPolicyGrantResult(true, null) // MobSDK.submitPolicyGrantResult(true, null)
val plat = ShareSDK.getPlatform(GooglePlus.NAME) val plat = ShareSDK.getPlatform(GooglePlus.NAME)
ShareSDK.setActivity(mContext as Activity) ShareSDK.setActivity(mContext as Activity)
//授权回调监听,监听oncomplete,onerror,oncancel三种状态 //授权回调监听,监听oncomplete,onerror,oncancel三种状态
...@@ -188,7 +209,9 @@ class WeChatUtils { ...@@ -188,7 +209,9 @@ class WeChatUtils {
val g = Gson() val g = Gson()
val obj: JsonObject = g.fromJson(p0?.db?.exportData(), JsonObject::class.java) val obj: JsonObject = g.fromJson(p0?.db?.exportData(), JsonObject::class.java)
Log.e("MXL", "PIC:" + obj.get("picture")) Log.e("MXL", "PIC:" + obj.get("picture"))
bindGoogle(p0?.db?.userId, p0?.db?.userName, obj.get("picture").toString()) val pic = obj.get("picture").toString().replace("\"", "")
Log.e("MXL", "image:" + pic)
bindGoogle(p0?.db?.userId, p0?.db?.userName, pic)
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<QZone Enable="false" /> <QZone Enable="false" />
<Renren Enable="false" /> <Renren Enable="false" />
<KaiXin Enable="false" /> <KaiXin Enable="false" />
<Facebook Id="8" SortId="8" OfficialVersion="default" FaceBookLoginProtocolScheme="fb662970168312513" ShareByAppClient="true" Enable="true" ConsumerKey="662970168312513" RedirectUrl="https://www.baidu.com" /> <Facebook Id="8" SortId="8" OfficialVersion="default" FaceBookLoginProtocolScheme="fb1156014961815312" ShareByAppClient="true" Enable="true" ConsumerKey="1156014961815312" RedirectUrl="https://www.baidu.com" />
<Twitter Enable="false" /> <Twitter Enable="false" />
<Evernote Enable="false" /> <Evernote Enable="false" />
<FourSquare Enable="false" /> <FourSquare Enable="false" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment