|
|
@@ -24,6 +24,7 @@ import com.adealink.weparty.account.constant.TAG_ACCOUNT_LOGIN_PHONE
|
|
|
import com.adealink.weparty.account.constant.getLoginErrorByServerCode
|
|
|
import com.adealink.weparty.account.login.auth.AuthManager
|
|
|
import com.adealink.weparty.account.login.auth.IAuthCallback
|
|
|
+import com.adealink.weparty.account.login.data.AccountInfo
|
|
|
import com.adealink.weparty.account.login.data.GetVerifyCodeReason
|
|
|
import com.adealink.weparty.account.login.data.LoginResult
|
|
|
import com.adealink.weparty.account.login.data.ThirdType
|
|
|
@@ -31,6 +32,7 @@ import com.adealink.weparty.account.login.data.VerifyCodeType
|
|
|
import com.adealink.weparty.account.login.manager.loginManager
|
|
|
import com.adealink.weparty.account.stat.AccountLoginStatEvent
|
|
|
import com.adealink.weparty.account.stat.getReportLoginType
|
|
|
+import com.adealink.weparty.commonui.ext.onSuccess
|
|
|
import com.adealink.weparty.module.account.ILoginListener
|
|
|
import com.adealink.weparty.storage.AppPref
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
@@ -93,8 +95,8 @@ class LoginViewModel : BaseViewModel(), ILoginViewModel, ILoginListener {
|
|
|
authType,
|
|
|
Rlt.Failed(AccountLoginAuthCancelError()),
|
|
|
getLoginStatSource()
|
|
|
- )
|
|
|
- , false)
|
|
|
+ ), false
|
|
|
+ )
|
|
|
AccountLoginStatEvent(CommonEventValue.Action.AUTH).apply {
|
|
|
type to getReportLoginType(authType)
|
|
|
this.result to CommonEventValue.Result.CANCEL
|
|
|
@@ -169,6 +171,7 @@ class LoginViewModel : BaseViewModel(), ILoginViewModel, ILoginListener {
|
|
|
this.source to AccountLoginStatEvent.Source.LOGIN
|
|
|
}.send()
|
|
|
}
|
|
|
+
|
|
|
is Rlt.Failed -> {
|
|
|
phoneLoginRltLD.send(Rlt.Failed(getLoginErrorByServerCode(result.error)))
|
|
|
AccountLoginStatEvent(AccountLoginStatEvent.Action.SERVER_LOGIN).apply {
|
|
|
@@ -210,6 +213,7 @@ class LoginViewModel : BaseViewModel(), ILoginViewModel, ILoginListener {
|
|
|
this.source to source
|
|
|
}.send()
|
|
|
}
|
|
|
+
|
|
|
is Rlt.Failed -> {
|
|
|
phoneRegisterRltLD.send(Rlt.Failed(getLoginErrorByServerCode(result.error)))
|
|
|
AccountLoginStatEvent(AccountLoginStatEvent.Action.SERVER_LOGIN).apply {
|
|
|
@@ -227,7 +231,11 @@ class LoginViewModel : BaseViewModel(), ILoginViewModel, ILoginListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- override fun setPhonePassword(phone: String, oldPassword: String, newPassword:String): LiveData<Rlt<Res<Any>>> {
|
|
|
+ override fun setPhonePassword(
|
|
|
+ phone: String,
|
|
|
+ oldPassword: String,
|
|
|
+ newPassword: String
|
|
|
+ ): LiveData<Rlt<Res<Any>>> {
|
|
|
val liveData: LiveData<Rlt<Res<Any>>> = OnceMutableLiveData()
|
|
|
viewModelScope.launch {
|
|
|
liveData.send(
|
|
|
@@ -278,7 +286,7 @@ class LoginViewModel : BaseViewModel(), ILoginViewModel, ILoginListener {
|
|
|
authManager.handleOnActivityResult(requestCode, resultCode, intent)
|
|
|
}
|
|
|
|
|
|
- fun onNewIntent(intent: Intent?){
|
|
|
+ fun onNewIntent(intent: Intent?) {
|
|
|
authManager.onNewIntent(intent)
|
|
|
}
|
|
|
|
|
|
@@ -312,8 +320,7 @@ class LoginViewModel : BaseViewModel(), ILoginViewModel, ILoginListener {
|
|
|
Triple(
|
|
|
authType,
|
|
|
Rlt.Failed(getLoginErrorByServerCode(result.error)), source
|
|
|
- )
|
|
|
- , false
|
|
|
+ ), false
|
|
|
)
|
|
|
AccountLoginStatEvent(AccountLoginStatEvent.Action.SERVER_LOGIN).apply {
|
|
|
type to getReportLoginType(authType)
|
|
|
@@ -356,8 +363,29 @@ class LoginViewModel : BaseViewModel(), ILoginViewModel, ILoginListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- override fun getAccountBindInfo(): LiveData<Rlt<Res<Any>>> {
|
|
|
- val onceMutableLiveData = OnceMutableLiveData<Rlt<Res<Any>>>()
|
|
|
+ override fun getAccountBindInfo(): LiveData<AccountInfo> {
|
|
|
+ val onceMutableLiveData = OnceMutableLiveData<AccountInfo>()
|
|
|
+ viewModelScope.launch {
|
|
|
+ loginManager.fetchAccountInfo().onSuccess { data ->
|
|
|
+ onceMutableLiveData.send(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return onceMutableLiveData
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ override fun bindAccountWithPhone(
|
|
|
+ phoneWithRegion: String,
|
|
|
+ verifyCode: String
|
|
|
+ ): LiveData<Rlt<Any>> {
|
|
|
+ val onceMutableLiveData = OnceMutableLiveData<Rlt<Any>>()
|
|
|
+ viewModelScope.launch {
|
|
|
+ val rlt = loginManager.bindAccountWithPhone(phoneWithRegion, verifyCode)
|
|
|
+ onceMutableLiveData.send(rlt)
|
|
|
+ }
|
|
|
+
|
|
|
+ return onceMutableLiveData
|
|
|
+ }
|
|
|
+
|
|
|
}
|