Commit 096d19bc by YKai

fix:一键登录逻辑修复

parent c8b1f32b
......@@ -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.74",
"m-user" : "0.0.60.76",
"m-home" : "0.0.22.51",
"m-im" : "0.0.18.30",
"m-dynamic" : "0.0.7.13",
......
......@@ -119,9 +119,9 @@ object OneKeyLoginHelp {
*/
fun toLoginActivity() {
if (mOpenPageIsSuccess){
RegisterAndLoginActivity.start(mActivity)
RegisterAndLoginActivity.start(mActivity, isFromOneKey = true, isFromGuide = false)
}else{
RegisterAndLoginActivity.startFromGuide(mActivity, isBindPhone = false, isFromGudile = true)
RegisterAndLoginActivity.start(mActivity, isFromOneKey = false, isFromGuide = true)
}
}
......@@ -133,10 +133,11 @@ object OneKeyLoginHelp {
if (mIsOpenOneKeyLogin){
getLoginToken(isOpenDialog)
}else{
// 一键登录页面打开成功
if (mOpenPageIsSuccess){
RegisterAndLoginActivity.start(mActivity)
}else{
RegisterAndLoginActivity.startFromGuide(mActivity, isBindPhone = false, isFromGudile = true)
RegisterAndLoginActivity.start(mActivity, isFromOneKey = false, isFromGuide = true)
}
}
}
......
......@@ -41,6 +41,7 @@ import com.yidianling.user.LoginUtils
import com.yidianling.user.R
import com.yidianling.user.StatusUtils
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.request.BindPhoneJavaParam
......@@ -78,10 +79,12 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
private var countryCode: String? = "0086"//国家或地区手机区号
private var handler: Handler? = null
private var isFromGuide = false//是否来自启动页
private var isFromOneKeyLogin = false // 是否来自一键登录界面
companion object {
private var BIND_PHONE = "bind_phone"//用于判断时候是绑定手机号
private var IS_FROM_GUIDE = "isFromGuide"//是否来自启动页
private var IS_FROM_ONE_KEY_LOGIN = "isFromOneKeyLogin"//是否来自启动页
var REQUEST_CODE_COUNTRY = 1024
fun start(context: Context) {
start(context, false)
......@@ -95,12 +98,25 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
}
/**
* 打开登录注册页面
*
* @param isFromOneKey 是否来自一键登录界面
* @param isFromGuide 是否来自启动页面
*/
fun start(context: Context, isFromOneKey: Boolean, isFromGuide: Boolean) {
val intent = Intent(context, RegisterAndLoginActivity::class.java)
intent.putExtra(IS_FROM_ONE_KEY_LOGIN, isFromOneKey)
intent.putExtra(IS_FROM_GUIDE, isFromGuide)
context.startActivity(intent)
}
/**
* 注意:此方法仅限于启动页调用,其他页面不要调用此方法
*/
fun startFromGuide(context: Context, isBindPhone: Boolean, isFromGudile: Boolean) {
fun startFromGuide(context: Context, isBindPhone: Boolean, isFromGuide: Boolean) {
val intent = Intent(context, RegisterAndLoginActivity::class.java)
intent.putExtra(BIND_PHONE, isBindPhone)
intent.putExtra(IS_FROM_GUIDE, isFromGudile)
intent.putExtra(IS_FROM_GUIDE, isFromGuide)
context.startActivity(intent)
}
......@@ -120,6 +136,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
override fun initDataAndEvent() {
isBindPhone = intent.getBooleanExtra(BIND_PHONE, false)
isFromGuide = intent.getBooleanExtra(IS_FROM_GUIDE, false)
isFromOneKeyLogin = intent.getBooleanExtra(IS_FROM_ONE_KEY_LOGIN, false)
StatusUtils.isFromGuide = isFromGuide
setWindowStatusBarColor()
......@@ -423,20 +440,21 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
ll_next.background =
ContextCompat.getDrawable(this, R.drawable.login_password_unable_bg_24dp)
}*/
if (country_code.text.equals("+86")!!&&it.toString().length == 13){
if (country_code.text.equals("+86")!! && it.toString().length == 13) {
ll_next.isEnabled = true
ll_next.background = ContextCompat.getDrawable(this, R.drawable.bg_one_click_login)
}else{
if (country_code.text.equals("+86")!!){
} else {
if (country_code.text.equals("+86")!!) {
ll_next.isEnabled = false
ll_next.background =
ContextCompat.getDrawable(this, R.drawable.login_password_unable_bg_24dp)
return@setListener
}
if (!country_code.text?.equals("+86")!!&&it.toString().length > 0){
if (!country_code.text?.equals("+86")!! && it.toString().length > 0) {
ll_next.isEnabled = true
ll_next.background = ContextCompat.getDrawable(this, R.drawable.bg_one_click_login)
}else{
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)
......@@ -661,13 +679,20 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
// } else {
// super.onBackPressed()
// }
// 如果从引导页面过来,点击返回键直接返回到主页
if (isFromGuide){
if (isFromGuide) {
ActivityManager.finishOtherActivity(this)
UserIn.mainIntent(this, 4)
finish()
}else{
super.onBackPressed()
} else if (isFromOneKeyLogin) { // 来自一键登录界面
// 如果已经登录
if (isLogin()) {
OneKeyLoginHelp.quitLoginPage()
ActivityManager.finishOtherActivity(this)
UserIn.mainIntent(this, 4)
finish()
} else {
super.onBackPressed()
}
}
}
......@@ -713,7 +738,7 @@ class RegisterAndLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginCont
*/
private fun setCountryIcon(code: String?) {
country_code.text = "+" + countryCode?.replace("00", "")
val splitCode= countryCode?.replace("00", "")
val splitCode = 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)
......
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