Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
a2965c7e
Commit
a2965c7e
authored
Jan 11, 2021
by
YKai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:登录代码提交
parent
15c1f497
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
306 additions
and
647 deletions
+306
-647
config.gradle
config.gradle
+3
-3
build.gradle
m-user/build.gradle
+1
-2
crashshield-release.aar
m-user/libs/crashshield-release.aar
+0
-0
EncryptionParams.java
m-user/src/main/java/com/yidianling/user/http/EncryptionParams.java
+56
-0
LoginApiRequestUtil.kt
m-user/src/main/java/com/yidianling/user/http/LoginApiRequestUtil.kt
+3
-2
MD5.java
m-user/src/main/java/com/yidianling/user/http/MD5.java
+37
-0
UserApi.kt
m-user/src/main/java/com/yidianling/user/http/UserApi.kt
+5
-8
PhoneLoginAutoParam.kt
m-user/src/main/java/com/yidianling/user/http/request/PhoneLoginAutoParam.kt
+6
-1
AccountSettingActivity.java
m-user/src/main/java/com/yidianling/user/mine/AccountSettingActivity.java
+3
-1
OneKeyLoginHelp.kt
m-user/src/main/java/com/yidianling/user/ui/login/OneKeyLoginHelp.kt
+71
-5
RegisterAndLoginActivity.kt
m-user/src/main/java/com/yidianling/user/ui/login/RegisterAndLoginActivity.kt
+11
-5
ILoginContract.kt
m-user/src/main/java/com/yidianling/user/ui/login/contract/ILoginContract.kt
+2
-2
LoginModelImpl.kt
m-user/src/main/java/com/yidianling/user/ui/login/model/LoginModelImpl.kt
+2
-2
LoginPresenterImpl.kt
m-user/src/main/java/com/yidianling/user/ui/login/presenter/LoginPresenterImpl.kt
+2
-2
testLoginActivity.kt
m-user/src/main/java/com/yidianling/user/ui/login/testLoginActivity.kt
+0
-604
EncryptionParams.java
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/EncryptionParams.java
+50
-0
GlobalConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/GlobalConfig.kt
+2
-1
HttpConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
+31
-5
GatewayRequestDTO.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/bean/GatewayRequestDTO.kt
+9
-0
ApiRequestUtil.java
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/ApiRequestUtil.java
+4
-2
NetApiStore.java
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/NetApiStore.java
+2
-2
api.properties
ydl-platform/src/main/res/raw/api.properties
+6
-0
No files found.
config.gradle
View file @
a2965c7e
...
...
@@ -8,7 +8,7 @@ ext {
"m-confide"
:
"0.0.48.91"
,
"m-consultant"
:
"0.0.59.40"
,
"m-fm"
:
"0.0.30.00"
,
"m-user"
:
"0.0.60.
38
"
,
"m-user"
:
"0.0.60.
44
"
,
"m-home"
:
"0.0.22.51"
,
"m-im"
:
"0.0.18.30"
,
"m-dynamic"
:
"0.0.7.13"
,
...
...
@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.39.6
6
"
,
"ydl-platform"
:
"0.0.39.6
7
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.33"
,
...
...
@@ -91,7 +91,7 @@ ext {
"m-confide"
:
"0.0.48.91"
,
"m-consultant"
:
"0.0.51.16"
,
"m-fm"
:
"0.0.23.5"
,
"m-user"
:
"0.0.60.
37
"
,
"m-user"
:
"0.0.60.
43
"
,
"m-home"
:
"0.0.22.51"
,
"m-im"
:
"0.0.3.15"
,
"m-dynamic"
:
"0.0.1.7"
,
...
...
m-user/build.gradle
View file @
a2965c7e
...
...
@@ -65,6 +65,7 @@ android {
}
}
compileOptions
{
sourceCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
...
...
@@ -79,8 +80,6 @@ dependencies {
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
kapt
'com.alibaba:arouter-compiler:1.2.2'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// crashshield-release.aar依赖了uc的crash收集库,因此还需要集成uc的crash收集库。
implementation
'com.ucweb.wpk:crashsdk-java:3.2.0.1'
api
rootProject
.
ext
.
dependencies
[
"ydl-user-router"
]
if
(
rootProject
.
ext
.
dev_mode
){
...
...
m-user/libs/crashshield-release.aar
deleted
100644 → 0
View file @
15c1f497
File deleted
m-user/src/main/java/com/yidianling/user/http/EncryptionParams.java
0 → 100644
View file @
a2965c7e
package
com
.
yidianling
.
user
.
http
;
import
android.os.Build
;
import
android.support.annotation.RequiresApi
;
import
android.util.Log
;
import
com.ydl.burypointlib.MD5Util
;
import
com.ydl.ydlcommon.base.BaseApp
;
import
com.ydl.ydlcommon.base.config.HttpConfig
;
import
com.yidianling.common.tools.RxAppTool
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* Created by Ykai on 2021/1/11.
*
* 获取加密参数类
*/
public
class
EncryptionParams
{
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
public
static
Map
<
String
,
String
>
getParams
(
String
path
){
String
timestamp
=
String
.
valueOf
(
System
.
currentTimeMillis
());
//值应该为毫秒数的字符串形式
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"timestamp"
,
timestamp
);
map
.
put
(
"path"
,
path
);
map
.
put
(
"version"
,
"1.0.0"
);
List
<
String
>
storedKeys
=
Arrays
.
stream
(
map
.
keySet
()
.
toArray
(
new
String
[]{}))
.
sorted
(
Comparator
.
naturalOrder
())
.
collect
(
Collectors
.
toList
());
String
sign
=
storedKeys
.
stream
()
// .map(key -> String.join("", key, map.get(key)))
.
map
(
key
->
key
+
map
.
get
(
key
))
.
collect
(
Collectors
.
joining
()).
trim
()
.
concat
(
"ABA88F2FF7E64A688D2213B20A9B3A3E"
);
Log
.
e
(
"sign"
,
sign
);
sign
=
MD5Util
.
md5
(
sign
).
toUpperCase
();
// sign = MD5.md5(sign).toUpperCase();
Log
.
e
(
"sign"
,
sign
);
Map
<
String
,
String
>
headersMap
=
new
HashMap
<>();
headersMap
.
put
(
"appKey"
,
"20BB42485BD448DE888DD745899C457D"
);
headersMap
.
put
(
"sign"
,
sign
);
// headersMap.put("sign","2410C6CDC7235DC6318F5CF0FFFAA0B7");
headersMap
.
put
(
"timestamp"
,
timestamp
);
// headersMap.put("timestamp","1610352010360");
return
headersMap
;
}
}
m-user/src/main/java/com/yidianling/user/http/LoginApiRequestUtil.kt
View file @
a2965c7e
package
com.yidianling.user.http
import
com.google.gson.Gson
import
com.ydl.ydlcommon.base.config.HttpConfig
import
com.ydl.ydlcommon.data.http.BaseResponse
import
com.ydl.ydlnet.YDLHttpUtils
import
com.yidianling.user.api.bean.UserResponseBean
...
...
@@ -33,8 +34,8 @@ class LoginApiRequestUtil {
/**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/
fun
checkPhoneStatus
(
phone
:
String
,
countryCode
:
String
?):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
{
return
getUserApi
().
checkPhoneStatus
(
phone
,
countryCode
!!
)
fun
checkPhoneStatus
(
map
:
Map
<
String
,
String
>,
phone
:
String
,
countryCode
:
String
?):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
{
return
getUserApi
().
checkPhoneStatus
(
map
,
phone
,
countryCode
!!
)
}
/**
...
...
m-user/src/main/java/com/yidianling/user/http/MD5.java
0 → 100644
View file @
a2965c7e
package
com
.
yidianling
.
user
.
http
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
public
class
MD5
{
public
static
final
char
HEX_DIGITS
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
public
static
String
toHexString
(
byte
[]
b
)
{
StringBuffer
sb
=
new
StringBuffer
(
b
.
length
*
2
);
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++)
{
sb
.
append
(
HEX_DIGITS
[(
b
[
i
]
&
0xf0
)
>>>
4
]);
sb
.
append
(
HEX_DIGITS
[
b
[
i
]
&
0x0f
]);
}
return
sb
.
toString
();
}
/**
* md5加密字符串
*
* @param s
* @return
*/
public
static
String
md5
(
String
s
)
{
try
{
MessageDigest
digest
=
MessageDigest
.
getInstance
(
"MD5"
);
digest
.
update
(
s
.
getBytes
());
byte
messageDigest
[]
=
digest
.
digest
();
return
toHexString
(
messageDigest
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
}
m-user/src/main/java/com/yidianling/user/http/UserApi.kt
View file @
a2965c7e
package
com.yidianling.user.http
import
com.google.gson.internal.LinkedTreeMap
import
com.ydl.ydlcommon.base.config.YDLConstants
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN_LOGIN_BASE_URL
import
com.ydl.ydlcommon.base.config.*
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.ydl.ydlcommon.data.http.BaseResponse
import
com.yidianling.user.api.bean.UserResponseBean
...
...
@@ -160,7 +157,7 @@ interface UserApi {
* 绑定手机号
*/
@POST
(
"/login/v2/bind_phone"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_LOGIN_BASE_URL
,
LOGIN_USER_PORT
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_LOGIN_BASE_URL
,
LOGIN_USER_PORT
)
fun
bindPhone
(
@Body
body
:
RequestBody
):
Observable
<
BaseResponse
<
Any
>>
/**
...
...
@@ -197,7 +194,7 @@ interface UserApi {
*/
@GET
(
"login/v2/phone_detection"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_LOGIN_BASE_URL
,
LOGIN_USER_PORT
)
fun
checkPhoneStatus
(
@Query
(
"phone"
)
phone
:
String
,
@Query
(
"countryCode"
)
countryCode
:
String
):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
fun
checkPhoneStatus
(
@
HeaderMap
headMap
:
Map
<
String
,
String
>,
@
Query
(
"phone"
)
phone
:
String
,
@Query
(
"countryCode"
)
countryCode
:
String
):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
/**
* 验证重置密码的短信验证码
...
...
@@ -210,14 +207,14 @@ interface UserApi {
* 重置密码
*/
@POST
(
"/login/v2/reset_pwd"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_
JAVA
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_
LOGIN_BASE_URL
,
LOGIN_USER_PORT
)
fun
resetPwd
(
@Body
body
:
RequestBody
):
Observable
<
BaseResponse
<
UserResponseBean
>>
/**
* 发送登录验证码
*/
@GET
(
"user/send_login_sms"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_
JAVA
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_
LOGIN_BASE_URL
,
LOGIN_USER_PORT
)
fun
sendLoginMsgCode
(
@Query
(
"phone"
)
phone
:
String
,
@Query
(
"countryCode"
)
countryCode
:
String
):
Observable
<
BaseResponse
<
Any
>>
/**
...
...
m-user/src/main/java/com/yidianling/user/http/request/PhoneLoginAutoParam.kt
View file @
a2965c7e
...
...
@@ -9,6 +9,10 @@ package com.yidianling.user.http.request
*/
data class
PhoneLoginAutoParam
(
var
accessCode
:
String
,
//sdk token
var
channelId
:
String
?,
var
deviceType
:
Int
=
2
,
var
directType
:
Int
,
// 登录类型:1本机号码检验(需要传手机号和token); 2一键登录(只需要token)
var
phoneNumber
:
String
,
//手机号
var
type
:
Int
=
2
var
version
:
String
)
\ No newline at end of file
m-user/src/main/java/com/yidianling/user/mine/AccountSettingActivity.java
View file @
a2965c7e
...
...
@@ -31,6 +31,7 @@ import com.yidianling.user.UserConstants;
import
com.yidianling.user.UserHelper
;
import
com.yidianling.user.api.event.RefreshRecentContactListEvent
;
import
com.yidianling.user.event.UpdateBindStatusEvent
;
import
com.yidianling.user.http.EncryptionParams
;
import
com.yidianling.user.http.LoginApiRequestUtil
;
import
com.yidianling.user.http.UserHttp
;
import
com.yidianling.user.http.UserHttpImpl
;
...
...
@@ -117,7 +118,8 @@ public class AccountSettingActivity extends BaseActivity implements View.OnClick
return
;
}
showProgressDialog
();
LoginApiRequestUtil
.
Companion
.
checkPhoneStatus
(
UserHelper
.
INSTANCE
.
getUserInfo
().
getUserInfo
().
getPhone
(),
UserHelper
.
INSTANCE
.
getUserInfo
().
getUserInfo
().
getCountry_code
())
Map
<
String
,
String
>
map
=
EncryptionParams
.
getParams
(
"/api/api/login/v2/phone_detection"
);
LoginApiRequestUtil
.
Companion
.
checkPhoneStatus
(
map
,
UserHelper
.
INSTANCE
.
getUserInfo
().
getUserInfo
().
getPhone
(),
UserHelper
.
INSTANCE
.
getUserInfo
().
getUserInfo
().
getCountry_code
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
response
->
{
...
...
m-user/src/main/java/com/yidianling/user/ui/login/OneKeyLoginHelp.kt
View file @
a2965c7e
...
...
@@ -2,6 +2,7 @@ package com.yidianling.user.ui.login
import
android.content.pm.ActivityInfo
import
android.graphics.Color
import
android.text.TextUtils
import
android.util.TypedValue
import
android.view.Gravity
import
android.view.View
...
...
@@ -13,12 +14,30 @@ import com.meituan.android.walle.WalleChannelReader
import
com.mobile.auth.gatewayauth.*
import
com.mobile.auth.gatewayauth.model.TokenRet
import
com.ydl.ydlcommon.base.BaseActivity
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.base.config.HttpConfig
import
com.ydl.ydlcommon.base.config.YDL_DOMAIN_LOGIN_BASE_URL
import
com.ydl.ydlcommon.utils.ActivityManager
import
com.ydl.ydlcommon.utils.JPushUtils
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.YDLCacheUtils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.utils.log.LogHelper
import
com.ydl.ydlnet.builder.manage.HttpUrlManager
import
com.yidianling.common.tools.RxAppTool
import
com.yidianling.common.tools.RxDeviceTool
import
com.yidianling.common.tools.RxImageTool
import
com.yidianling.user.LoginUtils
import
com.yidianling.user.StatusUtils
import
com.yidianling.user.api.bean.UserResponseBean
import
com.yidianling.user.bean.AliAuthBean
import
com.yidianling.user.constants.UserBIConstants
import
com.yidianling.user.http.LoginApiRequestUtil
import
com.yidianling.user.http.request.PhoneLoginAutoParam
import
com.yidianling.user.route.UserIn
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
java.math.BigDecimal
/**
* Created by Ykai on 2020/12/22.
...
...
@@ -59,8 +78,6 @@ object OneKeyLoginHelp {
it
.
setAuthSDKInfo
(
YDL_EXPERT_APP_KEY
)
}
}
// 配置动态网关
HttpUrlManager
.
Companion
.
getInstance
()
?.
addUrl
(
YDL_DOMAIN_LOGIN_BASE_URL
,
HttpConfig
.
JAVA_LOGIN_BASE_URL
)
// 获取渠道
val
channel
=
WalleChannelReader
.
getChannel
(
activity
)
checkBoxHidden
=
!(
channel
==
"huawei"
||
channel
==
"vivo"
)
...
...
@@ -314,9 +331,32 @@ object OneKeyLoginHelp {
LogUtil
.
e
(
"唤起授权页成功:$s"
)
}
ResultCode
.
CODE_SUCCESS
->
{
// 获取token成功
val
token
=
tokenRet
.
token
mPhoneNumberAuthHelper
?.
setAuthListener
(
null
)
val
param
=
PhoneLoginAutoParam
(
tokenRet
.
token
,
JPushUtils
.
getRegistrationID
(),
2
,
2
,
""
,
RxAppTool
.
getAppVersionName
(
BaseApp
.
Companion
.
getApp
()))
LoginApiRequestUtil
.
autoLogin
(
param
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
if
(
it
.
code
==
200
)
{
saveUserData
(
it
.
data
)
if
(
it
.
data
.
firstLogin
==
1
)
{
//第一次登录:是注册
StatusUtils
.
isFirstLogin
=
true
// 埋点
ActionCountUtils
.
baiduCount
(
it
.
data
.
uid
,
UserBIConstants
.
APP_REGISTER_PAGE
,
UserBIConstants
.
POSITION_ALIYUN_REGISTER_CLICK
,
""
,
""
,
25
)
}
else
{
ActionCountUtils
.
countUid
(
UserBIConstants
.
POSITION_LOGIN_SUCCESS_CLICK
,
it
.
data
.
uid
!!
,
UserBIConstants
.
ACTION_TYPE_DIRECT_LOGIN
)
}
mPhoneNumberAuthHelper
?.
let
{
helper
->
helper
.
hideLoginLoading
()
helper
.
quitLoginPage
()
helper
.
setAuthListener
(
null
)
}
mIsGetTokenSuccess
=
false
LoginUtils
.
LoginSuccessOperate
(
mActivity
)
}
},
{
toLoginActivity
()
})
}
}
}
...
...
@@ -334,7 +374,10 @@ object OneKeyLoginHelp {
// 一键登录
when
(
tokenRet
.
code
)
{
ResultCode
.
CODE_ERROR_USER_CANCEL
->
{
// 用户主动取消一键登录
if
(
mIsFromGuide
){
// 如果是从引导页首次打开
ActivityManager
.
finishOtherActivity
(
mActivity
)
UserIn
.
mainIntent
(
mActivity
,
4
)
}
}
else
->
{
// 其它失败原因
// 跳转到原生登录界面
...
...
@@ -359,4 +402,27 @@ object OneKeyLoginHelp {
verifyTokenResultListener
=
listener
}
/**
* 保存登录信息
*/
private
fun
saveUserData
(
userResponse
:
UserResponseBean
)
{
if
(!
TextUtils
.
isEmpty
(
userResponse
.
userInfo
!!
.
phone
))
{
YDLCacheUtils
.
saveUserPhone
(
userResponse
.
userInfo
!!
.
phone
)
YDLCacheUtils
.
saveCountryPhoneCode
(
userResponse
.
userInfo
!!
.
country_code
)
}
if
(
userResponse
.
uid
!!
.
contains
(
"."
))
{
val
bd
=
BigDecimal
(
userResponse
.
uid
)
var
uid
=
bd
.
toPlainString
()
if
(
uid
.
endsWith
(
".0"
))
{
uid
=
uid
.
replace
(
".0"
,
""
)
}
userResponse
.
userInfo
!!
.
uid
=
uid
userResponse
.
uid
=
uid
}
LoginUtils
.
saveData
(
userResponse
)
LogHelper
.
getInstance
().
writeLogSync
(
"登录成功"
)
LoginUtils
.
onLogin
(
userResponse
)
}
}
m-user/src/main/java/com/yidianling/user/ui/login/RegisterAndLoginActivity.kt
View file @
a2965c7e
...
...
@@ -24,14 +24,17 @@ import com.tbruyelle.rxpermissions2.RxPermissions
import
com.umeng.socialize.UMShareAPI
import
com.umeng.socialize.UMShareConfig
import
com.umeng.socialize.bean.SHARE_MEDIA
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.base.BaseMvpActivity
import
com.ydl.ydlcommon.data.PlatformRamImpl
import
com.ydl.ydlcommon.utils.ActivityManager
import
com.ydl.ydlcommon.utils.JPushUtils
import
com.ydl.ydlcommon.utils.StatusBarUtils
import
com.ydl.ydlcommon.utils.YDLCacheUtils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.view.dialog.CommonDialog
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxAppTool
import
com.yidianling.common.tools.RxKeyboardTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.user.LoginUtils
...
...
@@ -41,6 +44,7 @@ import com.yidianling.user.UserHelper
import
com.yidianling.user.api.bean.UserResponseBean
import
com.yidianling.user.bean.AliAuthBean
import
com.yidianling.user.constants.UserBIConstants
import
com.yidianling.user.http.EncryptionParams
import
com.yidianling.user.http.request.BindPhoneJavaParam
import
com.yidianling.user.http.request.PhoneLoginAutoParam
import
com.yidianling.user.http.response.ChcekPhoneResponeBean
...
...
@@ -182,12 +186,12 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
}
ResultCode
.
CODE_SUCCESS
->
{
// 获取token成功
val
aliAuthBean
=
AliAuthBean
()
aliAuthBean
.
accessCode
=
result
aliAuthBean
.
accessCode
=
tokenRet
.
token
if
(
isUmengLoginState
)
{
//绑定手机号码
umengLoginBindPhone
(
aliAuthBean
.
accessCode
)
}
else
{
autoLogin
(
aliAuthBea
n
)
autoLogin
(
tokenRet
.
toke
n
)
}
OneKeyLoginHelp
.
mPhoneNumberAuthHelper
?.
setAuthListener
(
null
)
OneKeyLoginHelp
.
mIsGetTokenSuccess
=
false
...
...
@@ -392,7 +396,8 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
return
@setOnClickListener
}
if
(
checkPhone
())
{
mPresenter
.
checkPhoneStatus
(
userPhoneNumber
!!
,
countryCode
!!
,
isUmengLoginState
)
val
map
=
EncryptionParams
.
getParams
(
"/api/api/login/v2/phone_detection"
)
mPresenter
.
checkPhoneStatus
(
map
,
userPhoneNumber
!!
,
countryCode
!!
,
isUmengLoginState
)
}
}
...
...
@@ -546,8 +551,9 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
/**
* 通过阿里sdk一键认证服务登陆
*/
private
fun
autoLogin
(
bean
:
AliAuthBean
)
{
var
param
=
PhoneLoginAutoParam
(
bean
.
accessCode
!!
,
userPhoneNumber
!!
)
private
fun
autoLogin
(
token
:
String
)
{
val
param
=
PhoneLoginAutoParam
(
token
,
JPushUtils
.
getRegistrationID
(),
2
,
1
,
userPhoneNumber
!!
,
RxAppTool
.
getAppVersionName
(
BaseApp
.
Companion
.
getApp
()))
mPresenter
.
autoLogin
(
param
)
}
...
...
m-user/src/main/java/com/yidianling/user/ui/login/contract/ILoginContract.kt
View file @
a2965c7e
...
...
@@ -97,7 +97,7 @@ interface ILoginContract {
/**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/
fun
checkPhoneStatus
(
phone
:
String
,
countryCode
:
String
,
isBind
:
Boolean
)
fun
checkPhoneStatus
(
map
:
Map
<
String
,
String
>,
phone
:
String
,
countryCode
:
String
,
isBind
:
Boolean
)
/**
* 通过一键认证服务登陆
...
...
@@ -120,7 +120,7 @@ interface ILoginContract {
/**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/
fun
checkPhoneStatus
(
phone
:
String
,
countryCode
:
String
):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
fun
checkPhoneStatus
(
map
:
Map
<
String
,
String
>,
phone
:
String
,
countryCode
:
String
):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
/**
...
...
m-user/src/main/java/com/yidianling/user/ui/login/model/LoginModelImpl.kt
View file @
a2965c7e
...
...
@@ -48,8 +48,8 @@ class LoginModelImpl : ILoginContract.Model {
/**
* 校验手机号:是否是用户版号码、是否有设置密码、是否被绑定
*/
override
fun
checkPhoneStatus
(
phone
:
String
,
countryCode
:
String
):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
{
return
LoginApiRequestUtil
.
checkPhoneStatus
(
phone
,
countryCode
)
override
fun
checkPhoneStatus
(
map
:
Map
<
String
,
String
>,
phone
:
String
,
countryCode
:
String
):
Observable
<
BaseResponse
<
ChcekPhoneResponeBean
>>
{
return
LoginApiRequestUtil
.
checkPhoneStatus
(
map
,
phone
,
countryCode
)
}
/**
...
...
m-user/src/main/java/com/yidianling/user/ui/login/presenter/LoginPresenterImpl.kt
View file @
a2965c7e
...
...
@@ -131,9 +131,9 @@ class LoginPresenterImpl(view: ILoginContract.View) : BasePresenter<ILoginContra
*@param isBind 是否是第三方登录成功后的绑定操作
*/
@SuppressLint
(
"CheckResult"
)
override
fun
checkPhoneStatus
(
phone
:
String
,
countryCode
:
String
,
isBind
:
Boolean
)
{
override
fun
checkPhoneStatus
(
map
:
Map
<
String
,
String
>,
phone
:
String
,
countryCode
:
String
,
isBind
:
Boolean
)
{
mView
.
showLoading
(
true
)
mModel
.
checkPhoneStatus
(
phone
,
countryCode
)
mModel
.
checkPhoneStatus
(
map
,
phone
,
countryCode
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
...
...
m-user/src/main/java/com/yidianling/user/ui/login/testLoginActivity.kt
deleted
100644 → 0
View file @
15c1f497
package
com.yidianling.user.ui.login
import
android.Manifest
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Intent
import
android.graphics.Color
import
android.net.Uri
import
android.os.Handler
import
android.provider.Settings
import
android.text.*
import
android.text.style.AbsoluteSizeSpan
import
android.util.Log
import
android.view.View
import
android.view.animation.AnimationUtils
import
com.alibaba.android.arouter.facade.annotation.Route
import
com.meituan.android.walle.WalleChannelReader
import
com.mobile.auth.gatewayauth.AuthUIConfig
import
com.mobile.auth.gatewayauth.PhoneNumberAuthHelper
import
com.mobile.auth.gatewayauth.PreLoginResultListener
import
com.mobile.auth.gatewayauth.TokenResultListener
import
com.mobile.auth.gatewayauth.model.InitResult
import
com.mobile.auth.gatewayauth.model.VendorConfig
import
com.tbruyelle.rxpermissions2.RxPermissions
import
com.umeng.socialize.UMShareAPI
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.base.BaseMvpActivity
import
com.ydl.ydlcommon.data.PlatformRamImpl
import
com.ydl.ydlcommon.utils.ActivityManager
import
com.ydl.ydlcommon.utils.StatusBarUtils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.ydl.ydlcommon.view.dialog.CommonDialog
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxKeyboardTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.user.LoginUtils
import
com.yidianling.user.R
import
com.yidianling.user.StatusUtils
import
com.yidianling.user.UserHelper
import
com.yidianling.user.api.bean.UserResponseBean
import
com.yidianling.user.bean.AliAuthBean
import
com.yidianling.user.constants.UserBIConstants
import
com.yidianling.user.http.request.BindPhoneJavaParam
import
com.yidianling.user.http.request.PhoneLoginAutoParam
import
com.yidianling.user.http.response.ChcekPhoneResponeBean
import
com.yidianling.user.route.UserIn
import
com.yidianling.user.safePrivate.FingerPrintCheckActivity
import
com.yidianling.user.safePrivate.FingerPrintUtil
import
com.yidianling.user.safePrivate.HandUnlockCheckActivity
import
com.yidianling.user.ui.login.contract.ILoginContract
import
com.yidianling.user.ui.login.presenter.LoginPresenterImpl
import
com.yidianling.user.widget.ZDialog
import
kotlinx.android.synthetic.main.user_activity_register_and_login.*
/**
* @author jiucheng
* @描述:登录注册页面
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/28
*/
//@Route(path = "/user/login")
class
testLoginActivity
:
BaseMvpActivity
<
ILoginContract
.
View
,
ILoginContract
.
Presenter
>(),
ILoginContract
.
View
{
private
var
mAlicomAuthHelper
:
PhoneNumberAuthHelper
?
=
null
private
var
mTokenListener
:
TokenResultListener
?
=
null
private
var
mAutCheckResult
:
InitResult
?
=
null
private
var
userPhoneNumber
:
String
?
=
null
/**
* 是不是4G网络
*/
private
var
isCan4GAuth
:
Boolean
=
false
/**
* 手机号校验结果
*/
private
var
chcekPhoneResponeBean
:
ChcekPhoneResponeBean
?
=
null
private
var
isUmengLoginState
:
Boolean
=
false
//true 通过第三方登录后绑定手机号码
private
var
countryCode
:
String
?
=
"0086"
//国家或地区手机区号
private
var
handler
:
Handler
?
=
null
private
var
isFromGuide
=
false
//是否来自启动页
companion
object
{
private
var
BIND_PHONE
=
"bind_phone"
//用于判断时候是绑定手机号
private
var
IS_FROM_GUIDE
=
"isFromGuide"
//是否来自启动页
var
REQUEST_CODE_COUNTRY
=
1024
fun
start
(
context
:
Context
)
{
start
(
context
,
false
)
}
/**
* 绑定手机号调用此方法启动
*/
fun
start
(
context
:
Context
,
isBindPhone
:
Boolean
)
{
startFromGuide
(
context
,
isBindPhone
,
false
)
}
/**
* 注意:此方法仅限于启动页调用,其他页面不要调用此方法
*/
fun
startFromGuide
(
context
:
Context
,
isBindPhone
:
Boolean
,
isFromGudile
:
Boolean
)
{
val
intent
=
Intent
(
context
,
testLoginActivity
::
class
.
java
)
intent
.
putExtra
(
BIND_PHONE
,
isBindPhone
)
intent
.
putExtra
(
IS_FROM_GUIDE
,
isFromGudile
)
context
.
startActivity
(
intent
)
}
fun
getIntent
(
context
:
Context
):
Intent
{
return
Intent
(
context
,
testLoginActivity
::
class
.
java
)
}
}
override
fun
createPresenter
():
ILoginContract
.
Presenter
{
return
LoginPresenterImpl
(
this
)
}
override
fun
layoutResId
():
Int
{
return
R
.
layout
.
user_activity_input_password_new
}
override
fun
initDataAndEvent
()
{
isUmengLoginState
=
intent
.
getBooleanExtra
(
BIND_PHONE
,
false
)
isFromGuide
=
intent
.
getBooleanExtra
(
IS_FROM_GUIDE
,
false
)
StatusUtils
.
isFromGuide
=
isFromGuide
setWindowStatusBarColor
()
initAuthHelper
()
setClickEvent
()
}
private
fun
setWindowStatusBarColor
()
{
StatusBarUtils
.
Companion
.
setWindowStatusBarColor
(
this
,
R
.
color
.
platform_color_075b66
)
}
@SuppressLint
(
"CheckResult"
)
private
fun
requestPermission
()
{
val
rxPermissions
=
RxPermissions
(
this
)
rxPermissions
.
requestEach
(
Manifest
.
permission
.
READ_PHONE_STATE
)
.
subscribe
{
permission
->
when
{
permission
.
granted
->
{
// 用户已经同意该权限
/*
* 5.sdk init
*/
mAutCheckResult
=
mAlicomAuthHelper
?.
checkAuthEnvEnable
()
}
permission
.
shouldShowRequestPermissionRationale
->
{
// 用户拒绝了该权限,没有选中『不再询问』(Never ask again),那么下次再次启动时。还会提示请求权限的对话框
}
else
->
{
// 用户拒绝了该权限,而且选中『不再询问』
ToastUtil
.
toastLong
(
this
,
getString
(
R
.
string
.
platform_need_storage_permission_hint
)
)
val
intent
=
Intent
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
)
val
uri
=
Uri
.
fromParts
(
"package"
,
packageName
,
null
)
intent
.
data
=
uri
startActivity
(
intent
)
finish
()
}
}
if
(
mAutCheckResult
!=
null
)
{
isCan4GAuth
=
mAutCheckResult
?.
isCan4GAuth
!!
if
(!
TextUtils
.
isEmpty
(
mAutCheckResult
!!
.
simPhoneNumber
)
&&
TextUtils
.
isEmpty
(
userPhoneNumber
)
)
{
runOnUiThread
{
// et_phone_number.setPhoneText(mAutCheckResult!!.simPhoneNumber)
// et_phone_number.setSelection(et_phone_number.text.length)
// iv_del.visibility = View.VISIBLE
}
}
}
}
}
/**
* 注册流程成功之后,进行百度埋点
*/
override
fun
baiduActionBury
(
uid
:
String
?,
positionClick
:
String
)
{
ActionCountUtils
.
baiduCount
(
uid
,
UserBIConstants
.
APP_REGISTER_PAGE
,
positionClick
,
""
,
""
,
25
)
}
private
fun
initAuthHelper
()
{
/*
* 1.init get token callback Listener
*/
mTokenListener
=
object
:
TokenResultListener
{
override
fun
onTokenSuccess
(
ret
:
String
)
{
this
@testLoginActivity
.
runOnUiThread
{
try
{
val
aliAuthBean
=
AliAuthBean
()
aliAuthBean
.
accessCode
=
ret
//
if
(
isUmengLoginState
)
{
//绑定手机号码
umengLoginBindPhone
(
aliAuthBean
.
accessCode
)
}
else
{
autoLogin
(
aliAuthBean
)
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
aliAuthFailed
()
}
/*
* setText just show the result for get token。
* use ret to verfiy number。
*/
mAlicomAuthHelper
?.
quitAuthActivity
()
}
}
override
fun
onTokenFailed
(
ret
:
String
)
{
this
@testLoginActivity
.
runOnUiThread
{
//验证失败跳转到验证码/密码界面
aliAuthFailed
()
/*
* setText just show the result for get token
* do something when getToken failed, such as use sms verify code.
*/
mAlicomAuthHelper
?.
quitAuthActivity
()
}
}
}
/*
* 2.init AlicomAuthHelper with tokenListener
*/
mAlicomAuthHelper
=
PhoneNumberAuthHelper
.
getInstance
(
this
,
mTokenListener
)
/*
* 3.set debugMode when app is in debug mode, sdk will print log in debug mode
*/
mAlicomAuthHelper
?.
setDebugMode
(
BaseApp
.
instance
.
getGlobalConfig
().
appDebug
)
requestPermission
()
/*
* 8.config authorization page ui to adapte app ui theme
*/
mAlicomAuthHelper
?.
setAuthUIConfig
(
AuthUIConfig
.
Builder
()
.
setAppPrivacyOne
(
"自定义协议"
,
"https://www.aliyun.com/product/dypns"
)
.
setLogoImgPath
(
"ic_launcher"
)
.
setPrivacyState
(
true
)
.
setCheckboxHidden
(
true
)
.
create
()
)
mAlicomAuthHelper
?.
preLogin
(
5
,
object
:
PreLoginResultListener
{
override
fun
onTokenSuccess
(
s
:
String
)
{
Log
.
e
(
"mTokenListener"
,
"preLogin Success:$s"
)
}
override
fun
onTokenFailed
(
s
:
String
,
s1
:
String
)
{
Log
.
e
(
"mTokenListener"
,
"preLogin Failed:$s"
)
}
})
}
private
fun
setHint
()
{
val
hintStr
=
SpannableString
(
resources
.
getString
(
R
.
string
.
user_edittext_hint
))
// 定义hint的值
val
ass
=
AbsoluteSizeSpan
(
16
,
true
)
// 设置字体大小 true表示单位是SP
hintStr
.
setSpan
(
ass
,
0
,
hintStr
.
length
,
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
)
et_phone_number
.
hint
=
SpannedString
(
hintStr
)
}
/**
* 设置点击事件
*/
private
var
mKeFuDialog
:
ZDialog
?
=
null
private
fun
setClickEvent
()
{
// tv_skip.setOnClickListener {
// ActionCountUtils.count(uid = "", partId = UserBIConstants.PART_ID_LOGIN_MAIN, position = UserBIConstants.POSITION_LOOK_AROUND_CLICK, url = "无url",api = "无api", sign1 = "")
// RxKeyboardTool.hideSoftInput(this)
// onBackPressed()
// }
img_reg_back
.
postDelayed
(
Runnable
{
// KeFuTipDialog(this).show()
if
(
mKeFuDialog
==
null
){
mKeFuDialog
=
ZDialog
.
Builder
(
this
)
.
setContentView
(
R
.
layout
.
user_kefu_tipdialog
)
.
setOnClickListener
(
R
.
id
.
cancel_dialog
)
{
mKeFuDialog
?.
dismiss
()
}
.
setAnimation
(
0
)
//取消动画
.
setOnClickListener
(
R
.
id
.
dial_right_now
)
{
val
dialIntent
=
Intent
(
Intent
.
ACTION_DIAL
,
Uri
.
parse
(
String
.
format
(
"tel:"
+
"400-765-1010"
))
)
startActivity
(
dialIntent
)
}
.
show
()
}
},
2000
)
img_reg_back
.
setOnClickListener
{
RxKeyboardTool
.
hideSoftInput
(
this
)
onBackPressed
()
}
var
isAgreeProtocol
=
false
//华为渠道不默认勾选隐私协议,必须全局上下文才可以获取到渠道号。其他渠道默认勾选隐私协议
//protocol_android 1是开启默认勾选,2是关闭默认勾选,方便应用市场审核
//新逻辑:华为一直不默认勾选(上线后华为也会抽查隐私协议勾选情况),vivo审核不默认勾选,通过后默认勾选
val
privacyOnOffType
=
PlatformRamImpl
.
getInstance
().
getGlobalInfo
()
?.
info
?.
protocol_android
?:
2
val
channel
=
WalleChannelReader
.
getChannel
(
applicationContext
)
/* if (channel=="huawei"){
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_unselected)
}else if (privacyOnOffType == 2 && (channel=="vivo")){
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_unselected)
}else{
isAgreeProtocol = true
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_selected)
}
view_click.setOnClickListener {
if (iv_select_protocol.visibility == View.VISIBLE) {
isAgreeProtocol = !isAgreeProtocol
if (isAgreeProtocol) {
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_selected)
} else {
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_unselected)
}
}
}*/
}
/**
* 检查手机号规范
*/
private
fun
checkPhone
():
Boolean
{
val
editPhone
=
et_phone_number
.
textContent
if
(
TextUtils
.
isEmpty
(
editPhone
))
{
ToastUtil
.
toastShort
(
"请输入手机号"
)
return
false
}
LogUtil
.
e
(
"本地userPhoneNumber赋值操作2:$editPhone"
)
userPhoneNumber
=
editPhone
//手机号码验证 国外手机号码不做限制
if
(!
TextUtils
.
equals
(
"0086"
,
countryCode
))
{
return
!
TextUtils
.
isEmpty
(
editPhone
)
}
return
if
(
editPhone
.
length
==
11
&&
editPhone
.
startsWith
(
"1"
))
{
view_lin
.
setBackgroundColor
(
Color
.
parseColor
(
"#E8E8E8"
))
true
}
else
{
view_lin
.
setBackgroundColor
(
Color
.
parseColor
(
"#FB6761"
))
ToastUtil
.
toastShort
(
"手机号格式错误"
)
startAnim
()
false
}
}
/**
* 三方登录成功后绑定手机号
*/
private
fun
umengLoginBindPhone
(
accessCode
:
String
?)
{
var
param
=
BindPhoneJavaParam
(
accessCode
!!
,
countryCode
!!
,
userPhoneNumber
!!
,
""
,
UserHelper
.
getUserInfo
()
!!
.
uid
!!
)
mPresenter
.
bindPhone
(
param
)
}
/**
* 动画
*/
private
fun
startAnim
()
{
val
shake
=
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
user_shake_input
)
//加载动画资源文件
et_phone_number
.
startAnimation
(
shake
)
}
/**
*三方登录成功
*/
override
fun
thirdLoginSuccess
(
userInfo
:
UserResponseBean
.
UserInfo
)
{
var
bindPhone
=
userInfo
.
bind_phone
if
(
bindPhone
!=
1
)
{
countryCode
=
userInfo
.
country_code
isUmengLoginState
=
true
// tv_skip.visibility = View.VISIBLE
// tv_des.text = "首次绑定即送大礼包"
tv_des
.
visibility
=
View
.
GONE
iv_select_protocol
.
visibility
=
View
.
GONE
tv_des_first
.
visibility
=
View
.
VISIBLE
iv_weixin
.
visibility
=
View
.
GONE
iv_qq
.
visibility
=
View
.
GONE
tv_reg_title
.
text
=
"手机号绑定"
tv_protocol
.
visibility
=
View
.
GONE
}
else
{
LoginUtils
.
LoginSuccessOperate
(
this
)
}
}
/**
* 校验手机号(是否是用户版号码、是否有设置密码、是否被绑定)成功
*/
override
fun
checkPhoneStatusSuccess
(
bean
:
ChcekPhoneResponeBean
?,
phone
:
String
)
{
//校验手机号的结果需要在本地保存,后续一键认证登录失败后跳转密码登录需要用到校验结果
if
(
bean
!=
null
)
{
chcekPhoneResponeBean
=
ChcekPhoneResponeBean
(
bean
.
hasPwd
,
bean
.
isDoctor
,
bean
.
isRegistered
)
}
if
(
isCan4GAuth
)
{
mAlicomAuthHelper
?.
getAuthToken
(
5000
)
// val authBean = CheckAliAuthParam(phone, mAlicomAuthHelper!!.version)
// mPresenter.checkAliAuth(authBean)
}
else
{
aliAuthFailed
()
}
}
/**
* 服务端校验阿里一键认证认证失败
*
* 成功的回调 :
* @see getAuthToken
*
* 失败的回调 :
* @see aliAuthFailed
*/
override
fun
aliAuthFailed
()
{
RxKeyboardTool
.
hideSoftInput
(
this
)
runOnUiThread
{
showLoading
(
false
)
}
if
(
chcekPhoneResponeBean
!=
null
&&
chcekPhoneResponeBean
?.
hasPwd
==
1
)
{
//用户码有设置密码:跳转到密登录
InputPassWordActivity
.
start
(
this
,
userPhoneNumber
!!
,
countryCode
!!
,
InputPassWordActivity
.
STATUS_INPUT_PWD
)
}
else
{
//否则跳转验证码页面
if
(!
TextUtils
.
isEmpty
(
userPhoneNumber
)
&&
!
TextUtils
.
isEmpty
(
countryCode
))
{
VerificationCodeActivity
.
start
(
this
,
userPhoneNumber
!!
,
countryCode
!!
,
VerificationCodeActivity
.
STATUS_LOGIN_BY_CODE
,
isUmengLoginState
,
false
)
}
}
}
/**
* 通过阿里sdk一键认证服务登陆
*/
private
fun
autoLogin
(
bean
:
AliAuthBean
)
{
var
param
=
PhoneLoginAutoParam
(
bean
.
accessCode
!!
,
userPhoneNumber
!!
)
mPresenter
.
autoLogin
(
param
)
}
/**
* 手机号绑定成功
*/
override
fun
bindSuccess
()
{
UserHelper
.
getUserInfo
()
!!
.
userInfo
!!
.
bind_phone
=
1
UserHelper
.
getUserInfo
()
!!
.
userInfo
!!
.
phone
=
userPhoneNumber
finishPrePage
()
}
/**
*菊花框
*/
override
fun
showLoading
(
state
:
Boolean
)
{
if
(
state
)
{
iv_next
.
visibility
=
View
.
GONE
iv_next
.
isEnabled
=
false
pb_Normal
.
visibility
=
View
.
VISIBLE
}
else
{
iv_next
.
visibility
=
View
.
VISIBLE
iv_next
.
isEnabled
=
true
pb_Normal
.
visibility
=
View
.
GONE
}
}
/**
* 自动登录成功
*/
override
fun
autoLoginSuccess
()
{
ll_success
.
visibility
=
View
.
VISIBLE
handler
!!
.
postDelayed
({
LoginUtils
.
LoginSuccessOperate
(
this
)
},
3000
)
}
private
fun
finishPrePage
()
{
ActivityManager
.
getInstance
().
finishActivity
(
VerificationCodeActivity
::
class
.
java
)
ActivityManager
.
getInstance
().
finishActivity
(
InputPassWordActivity
::
class
.
java
)
ActivityManager
.
getInstance
().
finishActivity
(
testLoginActivity
::
class
.
java
)
//关闭手势解锁页面与指纹解锁页面
ActivityManager
.
getInstance
().
finishActivity
(
FingerPrintCheckActivity
::
class
.
java
)
ActivityManager
.
getInstance
().
finishActivity
(
HandUnlockCheckActivity
::
class
.
java
)
FingerPrintUtil
.
instance
().
setCurrentUnLockTime
(
System
.
currentTimeMillis
())
}
override
fun
onBackPressed
()
{
//当前stack只有一个activity,说明被挤掉线的
if
(
ActivityManager
.
getActivitySize
()
==
1
)
{
ActivityManager
.
finishOtherActivity
(
this
)
UserIn
.
mainIntent
(
this
,
4
)
finish
()
}
else
{
super
.
onBackPressed
()
}
}
override
fun
showProgressView
()
{
showProgressDialog
()
}
override
fun
dismissProgressView
()
{
dismissProgressDialog
()
}
override
fun
showHasBindedDialog
()
{
CommonDialog
.
create
(
this
)
.
setMessage
(
"该手机号已被注册,无法绑定,\n您可以使用它直接登录。"
)
.
setRightClick
(
"确定"
)
{
}
.
show
()
}
override
fun
showNormalDialog
()
{
CommonDialog
.
create
(
this
)
.
setMessage
(
"专家账号,请下载壹点灵专家版app喔"
)
.
setRightClick
(
"确定"
)
{
}
.
show
()
}
public
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
UMShareAPI
.
get
(
this
).
onActivityResult
(
requestCode
,
resultCode
,
data
)
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
resultCode
==
45
&&
requestCode
==
REQUEST_CODE_COUNTRY
)
{
countryCode
=
data
!!
.
getStringExtra
(
"code"
)
setCountryIcon
(
countryCode
)
tv_country_code
.
text
=
"+"
+
countryCode
?.
replace
(
"00"
,
""
)
}
}
/**
* 根据国家个地区号设置国旗
*/
private
fun
setCountryIcon
(
code
:
String
?)
{
when
(
code
)
{
"0086"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_ic_china
)
"001"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_usa
)
"00886"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_ic_china
)
"0081"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_japan
)
"00852"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_hk
)
"0061"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_australia
)
"0064"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_nz
)
"0082"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_sk
)
"0060"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_malaysia
)
"0044"
->
iv_country_icon
.
setImageResource
(
R
.
drawable
.
user_country_uk
)
else
->
iv_country_icon
.
visibility
=
View
.
VISIBLE
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
if
(
handler
!=
null
)
{
handler
=
null
}
if
(
mAlicomAuthHelper
!=
null
)
{
mAlicomAuthHelper
!!
.
onDestroy
()
}
mAlicomAuthHelper
=
null
}
}
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/EncryptionParams.java
0 → 100644
View file @
a2965c7e
package
com
.
ydl
.
ydlcommon
.
base
.
config
;
import
android.os.Build
;
import
android.support.annotation.RequiresApi
;
import
android.util.Log
;
import
com.ydl.burypointlib.MD5Util
;
import
com.ydl.ydlcommon.base.BaseApp
;
import
com.yidianling.common.tools.RxAppTool
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* Created by Ykai on 2021/1/11.
*
* 获取加密参数类
*/
public
class
EncryptionParams
{
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
public
static
Map
<
String
,
String
>
getParams
(
String
path
){
String
timestamp
=
String
.
valueOf
(
System
.
currentTimeMillis
());
//值应该为毫秒数的字符串形式
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"timestamp"
,
timestamp
);
map
.
put
(
"path"
,
path
);
map
.
put
(
"version"
,
RxAppTool
.
getAppVersionName
(
BaseApp
.
Companion
.
getApp
()));
List
<
String
>
storedKeys
=
Arrays
.
stream
(
map
.
keySet
()
.
toArray
(
new
String
[]{}))
.
sorted
(
Comparator
.
naturalOrder
())
.
collect
(
Collectors
.
toList
());
String
sign
=
storedKeys
.
stream
()
.
map
(
key
->
String
.
join
(
""
,
key
,
map
.
get
(
key
)))
.
collect
(
Collectors
.
joining
()).
trim
()
.
concat
(
HttpConfig
.
Companion
.
getENCRYPTION_APP_SECRET
());
sign
=
MD5Util
.
md5
(
sign
).
toUpperCase
();
Log
.
e
(
"sign"
,
sign
);
Map
<
String
,
String
>
headersMap
=
new
HashMap
<>();
headersMap
.
put
(
"appKey"
,
HttpConfig
.
Companion
.
getENCRYPTION_APP_KEY
());
headersMap
.
put
(
"sign"
,
sign
);
headersMap
.
put
(
"timestamp"
,
timestamp
);
return
headersMap
;
}
}
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/GlobalConfig.kt
View file @
a2965c7e
...
...
@@ -111,6 +111,7 @@ class GlobalConfig private constructor(var builder: Builder) {
.
setBaseUrl
(
appBaseURL
?:
HttpConfig
.
PHP_BASE_URL
)
.
addUrl
(
YDL_DOMAIN_JAVA
,
HttpConfig
.
JAVA_BASE_URL
)
.
addUrl
(
YDL_DOMAIN_JAVA_URL
,
HttpConfig
.
JAVA_URL
)
.
addUrl
(
YDL_DOMAIN_LOGIN_BASE_URL
,
HttpConfig
.
JAVA_LOGIN_BASE_URL
)
.
setMultipleUrlMap
(
multipleUrl
)
if
(
okHttpClient
==
null
)
{
...
...
@@ -119,7 +120,7 @@ class GlobalConfig private constructor(var builder: Builder) {
apiFactory
.
setOkClient
(
okHttpClient
)
HttpConfig
.
getInstance
().
initAuth
()
HttpConfig
.
getInstance
().
initLoginBaseUrlConfig
()
HttpConfig
.
getInstance
().
initLoginBaseUrlConfig
(
multipleUrl
)
}
}
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
View file @
a2965c7e
...
...
@@ -7,6 +7,7 @@ import com.facebook.stetho.okhttp3.StethoInterceptor
import
com.ydl.pushserver.pushagent.YdlPushAgent
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.bean.AuthBean
import
com.ydl.ydlcommon.bean.GatewayRequestDTO
import
com.ydl.ydlcommon.data.PlatformDataManager
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.ydl.ydlcommon.data.http.EncryptUtils
...
...
@@ -16,6 +17,7 @@ import com.ydl.ydlcommon.data.http.api.ApiRequestUtil
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.utils.YDLCacheUtils
import
com.ydl.ydlnet.builder.config.OkHttpConfig
import
com.ydl.ydlnet.builder.factory.ApiFactory
import
com.ydl.ydlnet.builder.interceptor.log.RequestHandler
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxAppTool
...
...
@@ -27,6 +29,7 @@ import okio.Buffer
import
okio.BufferedSink
import
java.util.*
import
kotlin.collections.ArrayList
import
kotlin.collections.HashMap
/**
...
...
@@ -99,7 +102,11 @@ class HttpConfig {
*/
var
ACTION_URL
=
""
var
JAVA_LOGIN_BASE_URL
=
""
// 登录注册动态配置网关地址
var
JAVA_LOGIN_BASE_URL
=
""
// 登录注册动态配置的网关地址
var
ENCRYPTION_APP_KEY
=
""
// 接口加密appKey
var
ENCRYPTION_APP_SECRET
=
""
// 接口加密appSecret
var
isEncryption
=
false
fun
getInstance
():
HttpConfig
{
return
Holder
.
INSTANCE
...
...
@@ -132,6 +139,15 @@ class HttpConfig {
.
build
()
}
/**
* 开启动态网关,请求头某些参数加密
*/
// private fun addEncryptionHeaderParams():Interceptor{
// return Interceptor {
// var request = it.request()
// }
// }
private
fun
getRequestHandler
():
RequestHandler
{
return
object
:
RequestHandler
{
override
fun
onHttpResultResponse
(
...
...
@@ -364,6 +380,8 @@ class HttpConfig {
PHP_BASE_URL
=
properties
.
getProperty
(
"serverurl.$appEnv"
)
JAVA_BASE_URL
=
properties
.
getProperty
(
"javaapi.$appEnv"
)
JAVA_LOGIN_BASE_URL
=
JAVA_BASE_URL
ENCRYPTION_APP_KEY
=
properties
.
getProperty
(
"appKey.$appEnv"
)
ENCRYPTION_APP_SECRET
=
properties
.
getProperty
(
"appSecret.$appEnv"
)
ACTION_URL
=
properties
.
getProperty
(
"actionurl.$appEnv"
)
H5_URL
=
properties
.
getProperty
(
"h5url.$appEnv"
)
...
...
@@ -409,14 +427,22 @@ class HttpConfig {
*
*/
@SuppressLint
(
"CheckResult"
)
fun
initLoginBaseUrlConfig
(){
ApiRequestUtil
.
getBaseUrl
()
fun
initLoginBaseUrlConfig
(
urlMap
:
HashMap
<
String
,
String
>){
val
map
=
HashMap
<
String
,
Any
>()
val
list
=
ArrayList
<
GatewayRequestDTO
>()
val
gatewayRequestDTO
=
GatewayRequestDTO
(
"login"
)
list
.
add
(
gatewayRequestDTO
)
map
[
"gatewayRequestDTOList"
]
=
list
ApiRequestUtil
.
getBaseUrl
(
map
)
.
compose
(
RxUtils
.
applySchedulers
())
.
compose
(
RxUtils
.
resultJavaData
())
.
subscribe
({
if
(
it
.
baseUrlGatewayDTOList
.
isNotEmpty
()){
if
(
it
.
baseUrlGatewayDTOList
[
0
].
goGateway
){
JAVA_LOGIN_BASE_URL
=
it
.
baseUrlGatewayDTOList
[
0
].
baseUrl
isEncryption
=
it
.
baseUrlGatewayDTOList
[
0
].
goGateway
if
(
isEncryption
){
JAVA_LOGIN_BASE_URL
=
it
.
baseUrlGatewayDTOList
[
0
].
baseUrl
+
"/"
urlMap
[
YDL_DOMAIN_LOGIN_BASE_URL
]
=
JAVA_LOGIN_BASE_URL
ApiFactory
.
getInstance
().
setMultipleUrlMap
(
urlMap
)
}
}
})
{
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/bean/GatewayRequestDTO.kt
0 → 100644
View file @
a2965c7e
package
com.ydl.ydlcommon.bean
/**
* Created by Ykai on 2021/1/9.
*/
data class
GatewayRequestDTO
(
var
bizType
:
String
)
\ No newline at end of file
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/ApiRequestUtil.java
View file @
a2965c7e
...
...
@@ -13,10 +13,12 @@ import com.ydl.ydlcommon.utils.NetworkParamsUtils;
import
com.ydl.ydlnet.YDLHttpUtils
;
import
java.util.List
;
import
java.util.Map
;
import
io.reactivex.Observable
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
import
retrofit2.http.Body
;
/**
* 模块请求工具类
...
...
@@ -63,7 +65,7 @@ public class ApiRequestUtil {
/**
* 获取登录注册模块网关
*/
public
static
Observable
<
BaseAPIResponse
<
BaseUrlBean
>>
getBaseUrl
(){
return
YDLHttpUtils
.
Companion
.
obtainApi
(
NetApiStore
.
class
).
getBaseUrl
();
public
static
Observable
<
BaseAPIResponse
<
BaseUrlBean
>>
getBaseUrl
(
Map
<
String
,
Object
>
map
){
return
YDLHttpUtils
.
Companion
.
obtainApi
(
NetApiStore
.
class
).
getBaseUrl
(
map
);
}
}
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/NetApiStore.java
View file @
a2965c7e
...
...
@@ -51,7 +51,7 @@ interface NetApiStore {
@GET
(
"config/socket-config"
)
Observable
<
BaseAPIResponse
<
JavaGlobalInfo
>>
getJavaGlobalInfo
();
@Headers
({
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
,
"userPort:1"
})
@Headers
({
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
,
"userPort:1"
,
"Content-type:application/json;charset=UTF-8"
})
@POST
(
"systemconfig/get_gateway_base_url"
)
Observable
<
BaseAPIResponse
<
BaseUrlBean
>>
getBaseUrl
();
Observable
<
BaseAPIResponse
<
BaseUrlBean
>>
getBaseUrl
(
@Body
Map
<
String
,
Object
>
map
);
}
ydl-platform/src/main/res/raw/api.properties
View file @
a2965c7e
...
...
@@ -51,3 +51,9 @@ javatempurl.prod = https://dc.ydl.com/api/
javaapi.test
=
https://testapi.ydl.com/api/
javaapi.auto_test
=
https://auto_testapi.ydl.com/api/
javaapi.prod
=
https://api.ydl.com/api/
# 开启网关加密appKey和appSecret
appKey.test
=
20BB42485BD448DE888DD745899C457D
appSecret.test
=
ABA88F2FF7E64A688D2213B20A9B3A3E
appKey.prod
=
appSecret.prod
=
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment