Commit e93f02a7 by YKai

fix:修复绑定号验证失败问题

parent e298457c
......@@ -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.58",
"m-user" : "0.0.60.60",
"m-home" : "0.0.22.51",
"m-im" : "0.0.18.30",
"m-dynamic" : "0.0.7.13",
......
......@@ -394,54 +394,6 @@ public class AccountSettingActivity extends BaseActivity implements View.OnClick
dismissProgressDialog();
}
});
/* UMShareAPI.get(this).doOauthVerify(this, SHARE_MEDIA.WEIXIN, new UMAuthListener() {
@Override
public void onStart(SHARE_MEDIA share_media) {
}
@SuppressLint("CheckResult")
@Override
public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {
if (map == null||map.size()==0) {
return;
}
String openid = map.get("openid");
String unionid = map.get("unionid");
LogUtil.e("aaaaa"+openid+"bbbb"+unionid);
userHttp.bindWX(new BindWX(openid, unionid))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(o -> {
dismissProgressDialog();
if(o.code == 0 ) {
UserHelper.INSTANCE.getUserInfo().getUserInfo().setBind_weixin(1);
jtv_wechat.setRightText("已绑定");
ToastUtil.toastShort("绑定成功");
}else{
ToastHelper.Companion.show(o.msg);
}
}, new ThrowableConsumer() {
@Override
public void accept(@NotNull String msg) {
dismissProgressDialog();
}
});
UMShareAPI.get(AccountSettingActivity.this).deleteOauth(AccountSettingActivity.this, SHARE_MEDIA.WEIXIN, this);
}
@Override
public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {
dismissProgressDialog();
ToastUtil.toastShort(throwable.getMessage());
}
@Override
public void onCancel(SHARE_MEDIA share_media, int i) {
dismissProgressDialog();
}
});*/
}
/**
......@@ -559,7 +511,7 @@ public class AccountSettingActivity extends BaseActivity implements View.OnClick
* 绑定手机
*/
private void bindPhone() {
RegisterAndLoginActivity.Companion.start(this, true);
RegisterAndLoginActivity.Companion.start(this,true);
}
private String isNullString(String str) {
......
......@@ -42,7 +42,6 @@ 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
......@@ -70,11 +69,12 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
ILoginContract.View {
private var userPhoneNumber: String? = null
// 是否支持号码认证
private var isCanAuth: Boolean = false
private var chcekPhoneResponeBean: ChcekPhoneResponeBean? = null // 手机号校验结果
private var isUmengLoginState: Boolean = false //true 通过第三方登录后绑定手机号码
private var isBindPhone: Boolean = false // 是否绑定手机号
private var countryCode: String? = "0086"//国家或地区手机区号
private var handler: Handler? = null
private var isFromGuide = false//是否来自启动页
......@@ -82,13 +82,14 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
companion object {
private var BIND_PHONE = "bind_phone"//用于判断时候是绑定手机号
private var IS_FROM_GUIDE = "isFromGuide"//是否来自启动页
private var IS_FROM_ACCOUNT_SET = "isFromAccountSet"// 是否来自设置页
var REQUEST_CODE_COUNTRY = 1024
fun start(context: Context) {
start(context, false)
}
/**
* 绑定手机号调用此方法启动
* 第三方登录,绑定手机号调用此方法启动
*/
fun start(context: Context, isBindPhone: Boolean) {
startFromGuide(context, isBindPhone, false)
......@@ -118,7 +119,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
}
override fun initDataAndEvent() {
isUmengLoginState = intent.getBooleanExtra(BIND_PHONE, false)
isBindPhone = intent.getBooleanExtra(BIND_PHONE, false)
isFromGuide = intent.getBooleanExtra(IS_FROM_GUIDE, false)
StatusUtils.isFromGuide = isFromGuide
......@@ -130,7 +131,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
private fun setWindowStatusBarColor() {
StatusBarUtils.Companion.setWindowStatusBarColor(this, R.color.white)
StatusBarUtils.Companion.setStatusBarLightMode(this,true)
StatusBarUtils.Companion.setStatusBarLightMode(this, true)
}
@SuppressLint("CheckResult")
......@@ -176,22 +177,16 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
requestPermission()
OneKeyLoginHelp.checkEnvAvailable(PhoneNumberAuthHelper.SERVICE_TYPE_AUTH)
OneKeyLoginHelp.setVerifyTokenResultListener(object :OneKeyLoginHelp.VerifyTokenResultListener{
OneKeyLoginHelp.setVerifyTokenResultListener(object :
OneKeyLoginHelp.VerifyTokenResultListener {
override fun onTokenSuccess(result: String) {
val tokenRet = TokenRet.fromJson(result)
when (tokenRet.code) {
ResultCode.CODE_ERROR_ENV_CHECK_SUCCESS->{ // 终端环境支持认证
isCanAuth =true
ResultCode.CODE_ERROR_ENV_CHECK_SUCCESS -> { // 终端环境支持认证
isCanAuth = true
}
ResultCode.CODE_SUCCESS -> { // 获取token成功
val aliAuthBean = AliAuthBean()
aliAuthBean.accessCode = tokenRet.token
if (isUmengLoginState) {
//绑定手机号码
umengLoginBindPhone(aliAuthBean.accessCode)
} else {
autoLogin(tokenRet.token)
}
autoLogin(tokenRet.token)
OneKeyLoginHelp.mPhoneNumberAuthHelper?.setAuthListener(null)
OneKeyLoginHelp.mIsGetTokenSuccess = false
}
......@@ -214,12 +209,13 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
spannableString.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.color = ContextCompat.getColor(this@RegisterAndLoginActivity,R.color.user_1da1f2trans)
ds.color =
ContextCompat.getColor(this@RegisterAndLoginActivity, R.color.user_1da1f2trans)
ds.isUnderlineText = true //设置下划线
}
override fun onClick(widget: View) {
if (!isUmengLoginState) {
if (!isBindPhone) {
H5Activity.start(this@RegisterAndLoginActivity, false)
overridePendingTransition(
R.anim.platform_slide_in_from_bottom,
......@@ -231,12 +227,13 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
spannableString.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.color = ContextCompat.getColor(this@RegisterAndLoginActivity,R.color.user_1da1f2trans)
ds.color =
ContextCompat.getColor(this@RegisterAndLoginActivity, R.color.user_1da1f2trans)
ds.isUnderlineText = true //设置下划线
}
override fun onClick(widget: View) {
if (!isUmengLoginState) {
if (!isBindPhone) {
H5Activity.start(this@RegisterAndLoginActivity, true)
overridePendingTransition(
R.anim.platform_slide_in_from_bottom,
......@@ -255,7 +252,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
setHint()
requestFocus()
if (isUmengLoginState) {
if (isBindPhone) {
skip_bind.visibility = View.VISIBLE
// tv_des.text = "首次绑定即送大礼包"
// tv_des.visibility = View.GONE//"同意"
......@@ -264,9 +261,9 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
login_wechat.visibility = View.GONE
login_qq.visibility = View.GONE
tv_login_title.text = "手机号绑定"
ll_next.text="发送验证码"
ll_next.text = "发送验证码"
tv_protocol.visibility = View.GONE
other_login_style.visibility=View.GONE
other_login_style.visibility = View.GONE
}
......@@ -284,9 +281,9 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
}
setCountryIcon(countryCode)
if (et_phone_number.text.length>0){
ll_next.isEnabled=true
ll_next.background=ContextCompat.getDrawable(this,R.drawable.bg_one_click_login)
if (et_phone_number.text.length > 0) {
ll_next.isEnabled = true
ll_next.background = ContextCompat.getDrawable(this, R.drawable.bg_one_click_login)
}
if (isFromGuide) {
......@@ -337,7 +334,14 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
*/
private fun setClickEvent() {
skip_bind.setOnClickListener {
ActionCountUtils.count(uid = "", partId = UserBIConstants.PART_ID_LOGIN_MAIN, position = UserBIConstants.POSITION_LOOK_AROUND_CLICK, url = "无url",api = "无api", sign1 = "")
ActionCountUtils.count(
uid = "",
partId = UserBIConstants.PART_ID_LOGIN_MAIN,
position = UserBIConstants.POSITION_LOOK_AROUND_CLICK,
url = "无url",
api = "无api",
sign1 = ""
)
RxKeyboardTool.hideSoftInput(this)
onBackPressed()
}
......@@ -350,13 +354,14 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
//protocol_android 1是开启默认勾选,2是关闭默认勾选,方便应用市场审核
//新逻辑:华为一直不默认勾选(上线后华为也会抽查隐私协议勾选情况),vivo审核不默认勾选,通过后默认勾选
val privacyOnOffType = PlatformRamImpl.getInstance().getGlobalInfo()?.info?.protocol_android ?: 2
val privacyOnOffType =
PlatformRamImpl.getInstance().getGlobalInfo()?.info?.protocol_android ?: 2
val channel = WalleChannelReader.getChannel(applicationContext)
if (channel=="huawei"){
if (channel == "huawei") {
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_unselected_new)
}else if (privacyOnOffType == 2 && (channel=="vivo")){
} else if (privacyOnOffType == 2 && (channel == "vivo")) {
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_unselected_new)
}else{
} else {
isAgreeProtocol = true
iv_select_protocol.setImageResource(R.drawable.user_login_protocol_selected_new)
}
......@@ -396,7 +401,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
return@setOnClickListener
}
if (checkPhone()) {
mPresenter.checkPhoneStatus(userPhoneNumber!!, countryCode!!, isUmengLoginState)
mPresenter.checkPhoneStatus(userPhoneNumber!!, countryCode!!, isBindPhone)
}
}
......@@ -410,12 +415,13 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
iv_del.visibility = View.VISIBLE
iv_del.isEnabled = true
}
if (it.toString().length==13||(!countryCode?.contains("86")!! &&et_phone_number.text.toString().length>0)){
ll_next.isEnabled=true
ll_next.background=ContextCompat.getDrawable(this,R.drawable.bg_one_click_login)
}else{
ll_next.isEnabled=false
ll_next.background=ContextCompat.getDrawable(this,R.drawable.login_password_unable_bg_24dp)
if (it.toString().length == 13 || (!countryCode?.contains("86")!! && et_phone_number.text.toString().length > 0)) {
ll_next.isEnabled = true
ll_next.background = ContextCompat.getDrawable(this, R.drawable.bg_one_click_login)
} else {
ll_next.isEnabled = false
ll_next.background =
ContextCompat.getDrawable(this, R.drawable.login_password_unable_bg_24dp)
}
}
//删除按钮
......@@ -439,7 +445,10 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
if (!TextUtils.equals("0086", countryCode)) {
return !TextUtils.isEmpty(editPhone)
}
return if (editPhone.length == 11 && editPhone.startsWith("1")&&checkRegex(editPhone.toString().trim())) {
return if (editPhone.length == 11 && editPhone.startsWith("1") && checkRegex(
editPhone.toString().trim()
)
) {
view_lin.setBackgroundColor(Color.parseColor("#E8E8E8"))
true
} else {
......@@ -449,15 +458,17 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
false
}
}
private fun checkRegex( phone:String):Boolean{
val regex="^1+[23456789]+\\d{9}"
private fun checkRegex(phone: String): Boolean {
val regex = "^1+[23456789]+\\d{9}"
return phone.matches(regex.toRegex())
}
/**
* 三方登录成功后绑定手机号
*/
private fun umengLoginBindPhone(accessCode: String?) {
var param = BindPhoneJavaParam(
val param = BindPhoneJavaParam(
accessCode!!,
countryCode!!,
userPhoneNumber!!,
......@@ -483,22 +494,22 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
var bindPhone = userInfo.bind_phone
if (bindPhone != 1) {
countryCode = userInfo.country_code
isUmengLoginState = true
isBindPhone = true
skip_bind.visibility = View.VISIBLE
// tv_des.text = "首次绑定即送大礼包"
// tv_des.visibility = View.GONE
iv_select_protocol.visibility = View.GONE
// tv_des_first.visibility = View.VISIBLE
bind_phone_hint.visibility=View.VISIBLE
bind_phone_hint.visibility = View.VISIBLE
login_wechat.visibility = View.GONE
login_qq.visibility = View.GONE
tv_login_title.text = "绑定手机号"
tv_protocol.visibility = View.GONE
other_login_style.visibility=View.GONE
other_login_style.visibility = View.GONE
} else {
if (isFromGuide) {
LoginUtils.LoginSuccessOperate(this)
}else{
} else {
finish()
}
}
......@@ -510,12 +521,17 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
override fun checkPhoneStatusSuccess(bean: ChcekPhoneResponeBean?, phone: String) {
//校验手机号的结果需要在本地保存,后续一键认证登录失败后跳转密码登录需要用到校验结果
if (bean != null) {
chcekPhoneResponeBean = ChcekPhoneResponeBean(bean.hasPwd, bean.isDoctor, bean.isRegistered)
chcekPhoneResponeBean =
ChcekPhoneResponeBean(bean.hasPwd, bean.isDoctor, bean.isRegistered)
}
if (isCanAuth) {
OneKeyLoginHelp.getVerifyToken()
} else {
if (isBindPhone) {
aliAuthFailed()
} else {
if (isCanAuth) {
OneKeyLoginHelp.getVerifyToken()
} else {
aliAuthFailed()
}
}
}
......@@ -548,7 +564,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
userPhoneNumber!!,
countryCode!!,
VerificationCodeActivity.STATUS_LOGIN_BY_CODE,
isUmengLoginState,
isBindPhone,
false
)
}
......@@ -558,9 +574,11 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
/**
* 通过阿里sdk一键认证服务登陆
*/
private fun autoLogin(token:String) {
val param = PhoneLoginAutoParam(token, JPushUtils.getRegistrationID(),2,1,userPhoneNumber!!,
RxAppTool.getAppVersionName(BaseApp.Companion.getApp()))
private fun autoLogin(token: String) {
val param = PhoneLoginAutoParam(
token, JPushUtils.getRegistrationID(), 2, 1, userPhoneNumber!!,
RxAppTool.getAppVersionName(BaseApp.Companion.getApp())
)
mPresenter.autoLogin(param)
}
......@@ -574,13 +592,14 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
finishPrePage()
}
/**
*菊花框
*/
override fun showLoading(state: Boolean) {
if (state){
if (state) {
showProgressDialog()
}else{
} else {
dismissProgressDialog()
}
}
......@@ -595,7 +614,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
handler!!.postDelayed({
if (isFromGuide) {
LoginUtils.LoginSuccessOperate(this)
}else{
} else {
finish()
}
}, 1000)
......@@ -665,20 +684,20 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
* 根据国家个地区号设置国旗
*/
private fun setCountryIcon(code: String?) {
country_code.text= "+"+countryCode?.replace("00", "")
/* 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
}*/
country_code.text = "+" + countryCode?.replace("00", "")
/* 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() {
......
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