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
b5884938
Commit
b5884938
authored
Mar 30, 2021
by
YKai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:强绑手机号优化
parent
8c2975f7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
54 deletions
+124
-54
config.gradle
config.gradle
+2
-2
BindPhoneActivity.kt
m-user/src/main/java/com/yidianling/user/ui/login/BindPhoneActivity.kt
+81
-33
RegisterAndLoginActivity.kt
m-user/src/main/java/com/yidianling/user/ui/login/RegisterAndLoginActivity.kt
+41
-19
No files found.
config.gradle
View file @
b5884938
...
@@ -8,7 +8,7 @@ ext {
...
@@ -8,7 +8,7 @@ ext {
"m-confide"
:
"0.0.49.02"
,
"m-confide"
:
"0.0.49.02"
,
"m-consultant"
:
"0.0.59.66"
,
"m-consultant"
:
"0.0.59.66"
,
"m-fm"
:
"0.0.30.01"
,
"m-fm"
:
"0.0.30.01"
,
"m-user"
:
"0.0.61.
18
"
,
"m-user"
:
"0.0.61.
22
"
,
"m-home"
:
"0.0.22.59"
,
"m-home"
:
"0.0.22.59"
,
"m-im"
:
"0.0.18.41"
,
"m-im"
:
"0.0.18.41"
,
"m-dynamic"
:
"0.0.7.19"
,
"m-dynamic"
:
"0.0.7.19"
,
...
@@ -91,7 +91,7 @@ ext {
...
@@ -91,7 +91,7 @@ ext {
"m-confide"
:
"0.0.49.02"
,
"m-confide"
:
"0.0.49.02"
,
"m-consultant"
:
"0.0.59.66"
,
"m-consultant"
:
"0.0.59.66"
,
"m-fm"
:
"0.0.30.01"
,
"m-fm"
:
"0.0.30.01"
,
"m-user"
:
"0.0.61.
18
"
,
"m-user"
:
"0.0.61.
22
"
,
"m-home"
:
"0.0.22.59"
,
"m-home"
:
"0.0.22.59"
,
"m-im"
:
"0.0.18.40"
,
"m-im"
:
"0.0.18.40"
,
"m-dynamic"
:
"0.0.7.19"
,
"m-dynamic"
:
"0.0.7.19"
,
...
...
m-user/src/main/java/com/yidianling/user/ui/login/BindPhoneActivity.kt
View file @
b5884938
...
@@ -12,6 +12,7 @@ import android.view.View
...
@@ -12,6 +12,7 @@ import android.view.View
import
com.ydl.ydlcommon.base.BaseActivity
import
com.ydl.ydlcommon.base.BaseActivity
import
com.ydl.ydlcommon.router.YdlCommonOut
import
com.ydl.ydlcommon.router.YdlCommonOut
import
com.ydl.ydlcommon.utils.StatusBarUtils
import
com.ydl.ydlcommon.utils.StatusBarUtils
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxKeyboardTool
import
com.yidianling.common.tools.RxKeyboardTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.user.LoginUtils
import
com.yidianling.user.LoginUtils
...
@@ -31,6 +32,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers
...
@@ -31,6 +32,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.Disposable
import
io.reactivex.disposables.Disposable
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
kotlinx.android.synthetic.main.activity_bind_phone.*
import
kotlinx.android.synthetic.main.activity_bind_phone.*
import
kotlinx.android.synthetic.main.activity_bind_phone.et_phone_number
import
kotlinx.android.synthetic.main.activity_bind_phone.iv_del
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
class
BindPhoneActivity
:
BaseActivity
()
{
class
BindPhoneActivity
:
BaseActivity
()
{
...
@@ -39,16 +42,17 @@ class BindPhoneActivity : BaseActivity() {
...
@@ -39,16 +42,17 @@ class BindPhoneActivity : BaseActivity() {
private
var
countryName
:
String
=
"中国"
private
var
countryName
:
String
=
"中国"
private
var
msgCodeDispoable
:
Disposable
?
=
null
private
var
msgCodeDispoable
:
Disposable
?
=
null
private
var
mKeFuDialog
:
ZDialog
?
=
null
private
var
mKeFuDialog
:
ZDialog
?
=
null
private
var
i
sForceBindPhone
:
Boolean
=
false
// 是否强绑手机号
private
var
mI
sForceBindPhone
:
Boolean
=
false
// 是否强绑手机号
private
lateinit
var
loginType
:
String
// 第三方登录方式 qq/微信
private
var
mIsFromGuide
:
Boolean
=
false
// 是否来自启动页
companion
object
{
companion
object
{
/**
/**
* 启动BindPhoneActivity
* 启动BindPhoneActivity
*/
*/
fun
startActivity
(
context
:
Context
,
loginType
:
String
)
{
fun
startActivity
(
context
:
Context
,
isForceBindPhone
:
Boolean
,
isFromGuide
:
Boolean
)
{
val
intent
=
Intent
(
context
,
BindPhoneActivity
::
class
.
java
)
val
intent
=
Intent
(
context
,
BindPhoneActivity
::
class
.
java
)
intent
.
putExtra
(
"login_type"
,
loginType
)
intent
.
putExtra
(
"is_force_bind_phone"
,
isForceBindPhone
)
intent
.
putExtra
(
"is_from_guide"
,
isFromGuide
)
context
.
startActivity
(
intent
)
context
.
startActivity
(
intent
)
}
}
}
}
...
@@ -60,10 +64,10 @@ class BindPhoneActivity : BaseActivity() {
...
@@ -60,10 +64,10 @@ class BindPhoneActivity : BaseActivity() {
override
fun
initDataAndEvent
()
{
override
fun
initDataAndEvent
()
{
setWindowStatusBarColor
()
setWindowStatusBarColor
()
loginType
=
intent
.
getStringExtra
(
"login_type"
)
mIsForceBindPhone
=
intent
.
getBooleanExtra
(
"is_force_bind_phone"
,
false
)
mIsFromGuide
=
intent
.
getBooleanExtra
(
"is_from_guide"
,
false
)
iv_back
.
setOnClickListener
{
iv_back
.
setOnClickListener
{
if
(
i
sForceBindPhone
)
{
if
(
mI
sForceBindPhone
)
{
//清除UserInfo
//清除UserInfo
setUserinfo
(
null
)
setUserinfo
(
null
)
clearImData
()
clearImData
()
...
@@ -86,7 +90,9 @@ class BindPhoneActivity : BaseActivity() {
...
@@ -86,7 +90,9 @@ class BindPhoneActivity : BaseActivity() {
}
}
// 获取验证码按钮
// 获取验证码按钮
tv_get_code
.
setOnClickListener
{
tv_get_code
.
setOnClickListener
{
checkPhoneStatus
()
if
(
checkPhone
())
{
checkPhoneStatus
()
}
}
}
// 收不到验证码
// 收不到验证码
tv_no_get_code
.
setOnClickListener
{
tv_no_get_code
.
setOnClickListener
{
...
@@ -144,31 +150,31 @@ class BindPhoneActivity : BaseActivity() {
...
@@ -144,31 +150,31 @@ class BindPhoneActivity : BaseActivity() {
override
fun
onTextChanged
(
p0
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
override
fun
onTextChanged
(
p0
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
}
}
})
})
getIsNeedForceBindPhone
()
//
getIsNeedForceBindPhone()
setTvGetCodeStatus
()
setTvGetCodeStatus
()
}
}
/**
//
/**
* 获取用户是否需要强绑定手机号
//
* 获取用户是否需要强绑定手机号
*/
//
*/
@SuppressLint
(
"CheckResult"
)
//
@SuppressLint("CheckResult")
private
fun
getIsNeedForceBindPhone
()
{
//
private fun getIsNeedForceBindPhone() {
val
userInfo
=
UserHelper
.
getUserInfo
()
?.
userInfo
//
val userInfo = UserHelper.getUserInfo()?.userInfo
val
map
=
HashMap
<
String
,
String
>()
//
val map = HashMap<String, String>()
map
[
"login_type"
]
=
loginType
//
map["login_type"] = loginType
map
[
"openid"
]
=
userInfo
?.
open_id_qqapp
?:
""
//
map["openid"] = userInfo?.open_id_qqapp ?: ""
map
[
"unionid"
]
=
userInfo
?.
union_id
?:
""
//
map["unionid"] = userInfo?.union_id ?: ""
LoginApiRequestUtil
.
isNeedForceBindPhone
(
map
)
//
LoginApiRequestUtil.isNeedForceBindPhone(map)
.
subscribeOn
(
Schedulers
.
io
())
//
.subscribeOn(Schedulers.io())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
//
.observeOn(AndroidSchedulers.mainThread())
.
subscribe
({
//
.subscribe({
if
(
it
.
code
==
"200"
)
{
//
if (it.code == "200") {
isForceBindPhone
=
it
.
data
//
isForceBindPhone = it.data
}
//
}
},
{
//
}, {
ToastUtil
.
toastShort
(
it
.
message
)
//
ToastUtil.toastShort(it.message)
})
//
})
}
//
}
/**
/**
* 检查手机号是否是用户版号码、是否有设置密码、是否被绑定
* 检查手机号是否是用户版号码、是否有设置密码、是否被绑定
...
@@ -230,12 +236,24 @@ class BindPhoneActivity : BaseActivity() {
...
@@ -230,12 +236,24 @@ class BindPhoneActivity : BaseActivity() {
.
doOnSubscribe
{
showProgressDialog
()
}
.
doOnSubscribe
{
showProgressDialog
()
}
.
doAfterTerminate
{
dismissProgressDialog
()
}
.
doAfterTerminate
{
dismissProgressDialog
()
}
.
subscribe
({
.
subscribe
({
if
(
it
.
data
!=
null
&&
it
.
code
==
200
)
{
if
(
it
.
code
==
200
)
{
ToastUtil
.
toastShort
(
"
手机号
绑定成功"
)
ToastUtil
.
toastShort
(
"绑定成功"
)
UserHelper
.
getUserInfo
()
!!
.
userInfo
!!
.
bind_phone
=
1
UserHelper
.
getUserInfo
()
!!
.
userInfo
!!
.
bind_phone
=
1
UserHelper
.
getUserInfo
()
!!
.
userInfo
!!
.
phone
=
phone
UserHelper
.
getUserInfo
()
!!
.
userInfo
!!
.
phone
=
phone
RxKeyboardTool
.
hideSoftInput
(
this
)
RxKeyboardTool
.
hideSoftInput
(
this
)
LoginUtils
.
loginSuccessOperate
(
this
)
if
(
mIsFromGuide
)
{
LoginUtils
.
loginSuccessOperate
(
this
)
}
else
{
finish
()
}
}
else
if
(
it
.
code
==
1300000004
)
{
// 如果不是10分钟内注册,提示“绑定失败,此手机号已注册”,并标记此账号为无需强绑
ToastUtil
.
toastShort
(
it
.
msg
)
RxKeyboardTool
.
hideSoftInput
(
this
)
if
(
mIsFromGuide
)
{
LoginUtils
.
loginSuccessOperate
(
this
)
}
else
{
finish
()
}
}
else
{
}
else
{
ToastUtil
.
toastShort
(
it
.
msg
)
//服务端返回{验证码错误&异常}信息
ToastUtil
.
toastShort
(
it
.
msg
)
//服务端返回{验证码错误&异常}信息
}
}
...
@@ -334,6 +352,36 @@ class BindPhoneActivity : BaseActivity() {
...
@@ -334,6 +352,36 @@ class BindPhoneActivity : BaseActivity() {
}
}
}
}
/**
* 检查手机号规范
*/
private
fun
checkPhone
():
Boolean
{
val
editPhone
=
et_phone_number
.
textContent
if
(
TextUtils
.
isEmpty
(
editPhone
))
{
ToastUtil
.
toastShort
(
"请输入手机号"
)
return
false
}
LogUtil
.
e
(
"本地userPhoneNumber赋值操作2:$editPhone"
)
//手机号码验证 国外手机号码不做限制
if
(!
TextUtils
.
equals
(
"0086"
,
countryCode
))
{
return
!
TextUtils
.
isEmpty
(
editPhone
)
}
return
if
(
editPhone
.
length
==
11
&&
editPhone
.
startsWith
(
"1"
)
&&
checkRegex
(
editPhone
.
toString
().
trim
()
)
)
{
true
}
else
{
ToastUtil
.
toastShort
(
"不是正确的手机号"
)
false
}
}
private
fun
checkRegex
(
phone
:
String
):
Boolean
{
val
regex
=
"^1+[23456789]+\\d{9}"
return
phone
.
matches
(
regex
.
toRegex
())
}
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
if
(
msgCodeDispoable
!=
null
)
{
if
(
msgCodeDispoable
!=
null
)
{
...
...
m-user/src/main/java/com/yidianling/user/ui/login/RegisterAndLoginActivity.kt
View file @
b5884938
...
@@ -44,6 +44,7 @@ import com.yidianling.user.UserHelper
...
@@ -44,6 +44,7 @@ import com.yidianling.user.UserHelper
import
com.yidianling.user.UserHelper.isLogin
import
com.yidianling.user.UserHelper.isLogin
import
com.yidianling.user.api.bean.UserResponseBean
import
com.yidianling.user.api.bean.UserResponseBean
import
com.yidianling.user.constants.UserBIConstants
import
com.yidianling.user.constants.UserBIConstants
import
com.yidianling.user.http.LoginApiRequestUtil
import
com.yidianling.user.http.request.BindPhoneJavaParam
import
com.yidianling.user.http.request.BindPhoneJavaParam
import
com.yidianling.user.http.request.PhoneLoginAutoParam
import
com.yidianling.user.http.request.PhoneLoginAutoParam
import
com.yidianling.user.http.response.ChcekPhoneResponeBean
import
com.yidianling.user.http.response.ChcekPhoneResponeBean
...
@@ -54,6 +55,8 @@ import com.yidianling.user.safePrivate.HandUnlockCheckActivity
...
@@ -54,6 +55,8 @@ import com.yidianling.user.safePrivate.HandUnlockCheckActivity
import
com.yidianling.user.ui.CountryListActivity
import
com.yidianling.user.ui.CountryListActivity
import
com.yidianling.user.ui.login.contract.ILoginContract
import
com.yidianling.user.ui.login.contract.ILoginContract
import
com.yidianling.user.ui.login.presenter.LoginPresenterImpl
import
com.yidianling.user.ui.login.presenter.LoginPresenterImpl
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
kotlinx.android.synthetic.main.user_activity_register_and_login_bottom.*
import
kotlinx.android.synthetic.main.user_activity_register_and_login_bottom.*
import
kotlinx.android.synthetic.main.user_activity_register_and_login_new.*
import
kotlinx.android.synthetic.main.user_activity_register_and_login_new.*
...
@@ -531,28 +534,47 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
...
@@ -531,28 +534,47 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
/**
/**
*三方登录成功
*三方登录成功
*/
*/
override
fun
thirdLoginSuccess
(
userInfo
:
UserResponseBean
.
UserInfo
,
thirdLoginPlatform
:
String
)
{
@SuppressLint
(
"CheckResult"
)
if
(
userInfo
.
bind_phone
!=
1
)
{
override
fun
thirdLoginSuccess
(
BindPhoneActivity
.
startActivity
(
this
,
thirdLoginPlatform
)
userInfo
:
UserResponseBean
.
UserInfo
,
finish
()
thirdLoginPlatform
:
String
}
else
{
)
{
when
{
isFromGuide
->
{
val
userInfo
=
UserHelper
.
getUserInfo
()
?.
userInfo
LoginUtils
.
loginSuccessOperate
(
this
)
val
map
=
HashMap
<
String
,
String
>()
}
map
[
"login_type"
]
=
thirdLoginPlatform
isFromOneKeyLogin
->
{
map
[
"openid"
]
=
userInfo
?.
open_id_qqapp
?:
""
if
(
OneKeyLoginHelp
.
mIsFromGuide
)
{
map
[
"unionid"
]
=
userInfo
?.
union_id
?:
""
LoginUtils
.
loginSuccessOperate
(
this
)
LoginApiRequestUtil
.
isNeedForceBindPhone
(
map
)
}
else
{
.
subscribeOn
(
Schedulers
.
io
())
OneKeyLoginHelp
.
quitLoginPage
()
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
if
(
it
.
code
==
"200"
)
{
if
(
it
.
data
)
{
BindPhoneActivity
.
startActivity
(
this
,
it
.
data
,
isFromGuide
)
finish
()
finish
()
}
else
{
when
{
isFromGuide
->
{
LoginUtils
.
loginSuccessOperate
(
this
)
}
isFromOneKeyLogin
->
{
if
(
OneKeyLoginHelp
.
mIsFromGuide
)
{
LoginUtils
.
loginSuccessOperate
(
this
)
}
else
{
OneKeyLoginHelp
.
quitLoginPage
()
finish
()
}
}
else
->
{
finish
()
}
}
}
}
}
}
else
->
{
},
{
finish
()
ToastUtil
.
toastShort
(
it
.
message
)
}
})
}
}
}
}
/**
/**
...
...
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