|
|
|
@ -5,11 +5,10 @@ import androidx.lifecycle.MutableLiveData |
|
|
|
|
import blankj.utilcode.util.ActivityUtils |
|
|
|
|
import com.project.survey.constants.EventConstants |
|
|
|
|
import com.project.survey.constants.SPConstants |
|
|
|
|
import com.project.survey.extend.toast |
|
|
|
|
import com.project.survey.model.LoginBean |
|
|
|
|
import com.project.survey.logic.event.Message |
|
|
|
|
import com.project.survey.logic.repository.GlobalRepository |
|
|
|
|
import com.project.survey.network.RetrofitClient |
|
|
|
|
import com.project.survey.ui.MainActivity |
|
|
|
|
import com.project.survey.ui.login.LoginActivity |
|
|
|
|
import com.project.survey.ui.login.LoginInputCodeActivity |
|
|
|
|
import com.project.survey.ui.project.ProjectListActivity |
|
|
|
@ -25,15 +24,18 @@ class LoginViewModel : BaseViewModel() { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 外部用户获取验证码 |
|
|
|
|
* @param isOutLogin: false内部用户,true外部用户 |
|
|
|
|
*/ |
|
|
|
|
fun fetchExternalPersonSMSCode(account: String, password: String) { |
|
|
|
|
fun fetchLoginSMSCode(isOutLogin: Boolean, account: String, password: String) { |
|
|
|
|
launch { |
|
|
|
|
val res = api.fetchExternalPersonSMSCode(account, password) |
|
|
|
|
val res = if (isOutLogin) |
|
|
|
|
api.fetchExternalPersonSMSCode(account, password) |
|
|
|
|
else |
|
|
|
|
api.fetchInternalPersonSMSCode(account, password) |
|
|
|
|
if (res.success) { |
|
|
|
|
// _externalPersonSMSCodeResponse.postValue(res.data) |
|
|
|
|
LoginInputCodeActivity.start(account, password, res.data ?: "") |
|
|
|
|
LoginInputCodeActivity.start(isOutLogin, account, password, res.data ?: "") |
|
|
|
|
} else { |
|
|
|
|
errorResponse.postValue(res.data) |
|
|
|
|
errorResponse.postValue(res.message) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -43,11 +45,14 @@ class LoginViewModel : BaseViewModel() { |
|
|
|
|
private val _loginResponse = MutableLiveData<LoginBean>() |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 外部用户登录 |
|
|
|
|
* 用户登录 |
|
|
|
|
*/ |
|
|
|
|
fun externalPersonLogin(account: String, password: String, code: String) { |
|
|
|
|
fun externalPersonLogin(isOutLogin: Boolean, account: String, password: String, code: String) { |
|
|
|
|
launch { |
|
|
|
|
val res = api.externalPersonLogin(account, password, code) |
|
|
|
|
val res = if (isOutLogin) |
|
|
|
|
api.externalPersonLogin(account, password, code) |
|
|
|
|
else |
|
|
|
|
api.internalPersonLogin(account, password, code) |
|
|
|
|
if (res.success) { |
|
|
|
|
// _externalPersonSMSCodeResponse.postValue(res.data) |
|
|
|
|
|
|
|
|
@ -64,6 +69,8 @@ class LoginViewModel : BaseViewModel() { |
|
|
|
|
|
|
|
|
|
ActivityUtils.finishActivity(LoginActivity::class.java) |
|
|
|
|
ActivityUtils.finishActivity(LoginInputCodeActivity::class.java) |
|
|
|
|
} else { |
|
|
|
|
toast(res.message) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|