Commit b5884938 by YKai

feat:强绑手机号优化

parent 8c2975f7
......@@ -8,7 +8,7 @@ ext {
"m-confide" : "0.0.49.02",
"m-consultant" : "0.0.59.66",
"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-im" : "0.0.18.41",
"m-dynamic" : "0.0.7.19",
......@@ -91,7 +91,7 @@ ext {
"m-confide" : "0.0.49.02",
"m-consultant" : "0.0.59.66",
"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-im" : "0.0.18.40",
"m-dynamic" : "0.0.7.19",
......
......@@ -12,6 +12,7 @@ import android.view.View
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxKeyboardTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.user.LoginUtils
......@@ -31,6 +32,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
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
class BindPhoneActivity : BaseActivity() {
......@@ -39,16 +42,17 @@ class BindPhoneActivity : BaseActivity() {
private var countryName: String = "中国"
private var msgCodeDispoable: Disposable? = null
private var mKeFuDialog: ZDialog? = null
private var isForceBindPhone: Boolean = false // 是否强绑手机号
private lateinit var loginType: String // 第三方登录方式 qq/微信
private var mIsForceBindPhone: Boolean = false // 是否强绑手机号
private var mIsFromGuide: Boolean = false // 是否来自启动页
companion object {
/**
* 启动BindPhoneActivity
*/
fun startActivity(context: Context, loginType: String) {
fun startActivity(context: Context, isForceBindPhone: Boolean, isFromGuide: Boolean) {
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)
}
}
......@@ -60,10 +64,10 @@ class BindPhoneActivity : BaseActivity() {
override fun initDataAndEvent() {
setWindowStatusBarColor()
loginType = intent.getStringExtra("login_type")
mIsForceBindPhone = intent.getBooleanExtra("is_force_bind_phone",false)
mIsFromGuide = intent.getBooleanExtra("is_from_guide", false)
iv_back.setOnClickListener {
if (isForceBindPhone) {
if (mIsForceBindPhone) {
//清除UserInfo
setUserinfo(null)
clearImData()
......@@ -86,7 +90,9 @@ class BindPhoneActivity : BaseActivity() {
}
// 获取验证码按钮
tv_get_code.setOnClickListener {
checkPhoneStatus()
if (checkPhone()) {
checkPhoneStatus()
}
}
// 收不到验证码
tv_no_get_code.setOnClickListener {
......@@ -144,31 +150,31 @@ class BindPhoneActivity : BaseActivity() {
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
})
getIsNeedForceBindPhone()
// getIsNeedForceBindPhone()
setTvGetCodeStatus()
}
/**
* 获取用户是否需要强绑定手机号
*/
@SuppressLint("CheckResult")
private fun getIsNeedForceBindPhone() {
val userInfo = UserHelper.getUserInfo()?.userInfo
val map = HashMap<String, String>()
map["login_type"] = loginType
map["openid"] = userInfo?.open_id_qqapp ?: ""
map["unionid"] = userInfo?.union_id ?: ""
LoginApiRequestUtil.isNeedForceBindPhone(map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.code == "200") {
isForceBindPhone = it.data
}
}, {
ToastUtil.toastShort(it.message)
})
}
// /**
// * 获取用户是否需要强绑定手机号
// */
// @SuppressLint("CheckResult")
// private fun getIsNeedForceBindPhone() {
// val userInfo = UserHelper.getUserInfo()?.userInfo
// val map = HashMap<String, String>()
// map["login_type"] = loginType
// map["openid"] = userInfo?.open_id_qqapp ?: ""
// map["unionid"] = userInfo?.union_id ?: ""
// LoginApiRequestUtil.isNeedForceBindPhone(map)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe({
// if (it.code == "200") {
// isForceBindPhone = it.data
// }
// }, {
// ToastUtil.toastShort(it.message)
// })
// }
/**
* 检查手机号是否是用户版号码、是否有设置密码、是否被绑定
......@@ -230,12 +236,24 @@ class BindPhoneActivity : BaseActivity() {
.doOnSubscribe { showProgressDialog() }
.doAfterTerminate { dismissProgressDialog() }
.subscribe({
if (it.data != null && it.code == 200) {
ToastUtil.toastShort("手机号绑定成功")
if (it.code == 200) {
ToastUtil.toastShort("绑定成功")
UserHelper.getUserInfo()!!.userInfo!!.bind_phone = 1
UserHelper.getUserInfo()!!.userInfo!!.phone = phone
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 {
ToastUtil.toastShort(it.msg)//服务端返回{验证码错误&异常}信息
}
......@@ -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() {
super.onDestroy()
if (msgCodeDispoable != null) {
......
......@@ -44,6 +44,7 @@ import com.yidianling.user.UserHelper
import com.yidianling.user.UserHelper.isLogin
import com.yidianling.user.api.bean.UserResponseBean
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.PhoneLoginAutoParam
import com.yidianling.user.http.response.ChcekPhoneResponeBean
......@@ -54,6 +55,8 @@ import com.yidianling.user.safePrivate.HandUnlockCheckActivity
import com.yidianling.user.ui.CountryListActivity
import com.yidianling.user.ui.login.contract.ILoginContract
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_new.*
......@@ -531,28 +534,47 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
/**
*三方登录成功
*/
override fun thirdLoginSuccess(userInfo: UserResponseBean.UserInfo,thirdLoginPlatform:String) {
if (userInfo.bind_phone != 1) {
BindPhoneActivity.startActivity(this,thirdLoginPlatform)
finish()
} else {
when {
isFromGuide -> {
LoginUtils.loginSuccessOperate(this)
}
isFromOneKeyLogin -> {
if (OneKeyLoginHelp.mIsFromGuide) {
LoginUtils.loginSuccessOperate(this)
} else {
OneKeyLoginHelp.quitLoginPage()
@SuppressLint("CheckResult")
override fun thirdLoginSuccess(
userInfo: UserResponseBean.UserInfo,
thirdLoginPlatform: String
) {
val userInfo = UserHelper.getUserInfo()?.userInfo
val map = HashMap<String, String>()
map["login_type"] = thirdLoginPlatform
map["openid"] = userInfo?.open_id_qqapp ?: ""
map["unionid"] = userInfo?.union_id ?: ""
LoginApiRequestUtil.isNeedForceBindPhone(map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.code == "200") {
if (it.data) {
BindPhoneActivity.startActivity(this, it.data, isFromGuide)
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)
})
}
/**
......
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