|
|
@@ -1,11 +1,7 @@
|
|
|
package com.adealink.weparty.account.login.phone
|
|
|
|
|
|
import androidx.activity.viewModels
|
|
|
-import androidx.lifecycle.lifecycleScope
|
|
|
import com.adealink.frame.base.Rlt
|
|
|
-import com.adealink.weparty.commonui.toast.util.showFailedToast
|
|
|
-import com.adealink.frame.ext.clicks
|
|
|
-import com.adealink.frame.ext.throttleFirst
|
|
|
import com.adealink.frame.log.Log
|
|
|
import com.adealink.frame.mvvm.view.viewBinding
|
|
|
import com.adealink.frame.router.Router
|
|
|
@@ -14,7 +10,7 @@ import com.adealink.frame.router.annotation.RouterUri
|
|
|
import com.adealink.frame.statistics.CommonEventValue
|
|
|
import com.adealink.frame.util.formatAppPhone
|
|
|
import com.adealink.frame.util.formatPhonePretty
|
|
|
-import com.adealink.weparty.module.account.Account
|
|
|
+import com.adealink.frame.util.onClick
|
|
|
import com.adealink.weparty.account.constant.TAG_ACCOUNT_LOGIN_PHONE
|
|
|
import com.adealink.weparty.account.databinding.ActivityPhoneLoginBinding
|
|
|
import com.adealink.weparty.account.login.BaseLoginActivity
|
|
|
@@ -25,8 +21,9 @@ import com.adealink.weparty.account.login.data.ThirdType
|
|
|
import com.adealink.weparty.account.login.viewmodel.LoginViewModel
|
|
|
import com.adealink.weparty.account.stat.AccountLoginStatEvent
|
|
|
import com.adealink.weparty.account.viewModel.AccountViewModelFactory
|
|
|
+import com.adealink.weparty.commonui.toast.util.showFailedToast
|
|
|
+import com.adealink.weparty.module.account.Account
|
|
|
import com.qmuiteam.qmui.widget.util.QMUIStatusBarHelper
|
|
|
-import kotlinx.coroutines.launch
|
|
|
|
|
|
/**
|
|
|
* Created by sunxiaodong on 2021/10/6.
|
|
|
@@ -52,19 +49,19 @@ class PhoneLoginActivity : BaseLoginActivity() {
|
|
|
override fun initViews() {
|
|
|
QMUIStatusBarHelper.setStatusBarLightMode(this)
|
|
|
setContentView(binding.root)
|
|
|
- lifecycleScope.launch {
|
|
|
- binding.loginButton.clicks().throttleFirst(1000).collect {
|
|
|
- login()
|
|
|
- AccountLoginStatEvent(CommonEventValue.Action.BTN_CLICK).apply {
|
|
|
- type to AccountLoginStatEvent.Type.PHONE
|
|
|
- btn to AccountLoginStatEvent.Btn.LOG_IN
|
|
|
- phone to this@PhoneLoginActivity.phone
|
|
|
- this.countryCode to this@PhoneLoginActivity.countryCode
|
|
|
- source to getLoginStatSource()
|
|
|
- }.send()
|
|
|
- }
|
|
|
+
|
|
|
+ binding.loginButton.onClick(wait = 1000) {
|
|
|
+ login()
|
|
|
+ AccountLoginStatEvent(CommonEventValue.Action.BTN_CLICK).apply {
|
|
|
+ type to AccountLoginStatEvent.Type.PHONE
|
|
|
+ btn to AccountLoginStatEvent.Btn.LOG_IN
|
|
|
+ phone to this@PhoneLoginActivity.phone
|
|
|
+ this.countryCode to this@PhoneLoginActivity.countryCode
|
|
|
+ source to getLoginStatSource()
|
|
|
+ }.send()
|
|
|
}
|
|
|
- binding.forgetPassword.setOnClickListener {
|
|
|
+
|
|
|
+ binding.forgetPassword.onClick {
|
|
|
goResetPassword()
|
|
|
AccountLoginStatEvent(CommonEventValue.Action.BTN_CLICK).apply {
|
|
|
type to AccountLoginStatEvent.Type.PHONE
|
|
|
@@ -74,6 +71,7 @@ class PhoneLoginActivity : BaseLoginActivity() {
|
|
|
source to getLoginStatSource()
|
|
|
}.send()
|
|
|
}
|
|
|
+
|
|
|
showPhone()
|
|
|
}
|
|
|
|
|
|
@@ -90,19 +88,22 @@ class PhoneLoginActivity : BaseLoginActivity() {
|
|
|
|
|
|
val formatPhone = formatPhonePretty(phone!!, countryCode!!)
|
|
|
if (formatPhone.isNullOrEmpty()) {
|
|
|
- Log.e(TAG_ACCOUNT_LOGIN_PHONE,
|
|
|
- "phone login, show phone, format phone is null, phone:$phone, countryCode:$countryCode")
|
|
|
+ Log.e(
|
|
|
+ TAG_ACCOUNT_LOGIN_PHONE,
|
|
|
+ "phone login, show phone, format phone is null, phone:$phone, countryCode:$countryCode"
|
|
|
+ )
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- binding.phone.text = formatPhone
|
|
|
}
|
|
|
|
|
|
override fun initComponents() {
|
|
|
LoginTitleComp(this, binding.loginTitle).attach()
|
|
|
- passwordInputComp = PasswordInputComp(this,
|
|
|
+ passwordInputComp = PasswordInputComp(
|
|
|
+ this,
|
|
|
binding.layoutPasswordInput,
|
|
|
- binding.loginButton).apply { attach() }
|
|
|
+ binding.loginButton
|
|
|
+ ).apply { attach() }
|
|
|
}
|
|
|
|
|
|
override fun observeViewModel() {
|
|
|
@@ -112,6 +113,7 @@ class PhoneLoginActivity : BaseLoginActivity() {
|
|
|
is Rlt.Success -> {
|
|
|
handleLoginSuccess(it.data, ThirdType.PHONE, AccountLoginStatEvent.Source.LOGIN)
|
|
|
}
|
|
|
+
|
|
|
is Rlt.Failed -> {
|
|
|
showFailedToast(it)
|
|
|
}
|
|
|
@@ -139,14 +141,19 @@ class PhoneLoginActivity : BaseLoginActivity() {
|
|
|
|
|
|
val password = passwordInputComp.getPassword()
|
|
|
if (!passwordInputComp.isPasswordValid(password)) {
|
|
|
- Log.e(TAG_ACCOUNT_LOGIN_PHONE, "phone login, login, password invalid, password:$password")
|
|
|
+ Log.e(
|
|
|
+ TAG_ACCOUNT_LOGIN_PHONE,
|
|
|
+ "phone login, login, password invalid, password:$password"
|
|
|
+ )
|
|
|
return
|
|
|
}
|
|
|
|
|
|
showLoading()
|
|
|
- loginViewModel.phonePasswordLogin(formatAppPhone(phone!!, countryCode!!),
|
|
|
+ loginViewModel.phonePasswordLogin(
|
|
|
+ formatAppPhone(phone!!, countryCode!!),
|
|
|
password,
|
|
|
- countryCode!!)
|
|
|
+ countryCode!!
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
private fun goResetPassword() {
|
|
|
@@ -155,7 +162,8 @@ class PhoneLoginActivity : BaseLoginActivity() {
|
|
|
.putExtra(Account.Phone.EXTRA_PHONE, phone)
|
|
|
.putExtra(
|
|
|
Account.Phone.EXTRA_GET_VERIFY_CODE_REASON,
|
|
|
- GetVerifyCodeReason.RESET_PASSWORD)
|
|
|
+ GetVerifyCodeReason.RESET_PASSWORD
|
|
|
+ )
|
|
|
.start()
|
|
|
}
|
|
|
|