| | |
| | | import kotlinx.coroutines.launch |
| | | import androidx.lifecycle.ViewModel |
| | | import com.example.firstapp.database.service.RetrofitClient |
| | | import com.example.firstapp.utils.Log |
| | | |
| | | |
| | | class LoginViewModel : ViewModel() { |
| | |
| | | _loginMessage.value = response.msg.ifEmpty { "发送验证码失败" } |
| | | } |
| | | } catch (e: Exception) { |
| | | Log.e("LoginError", "Login failed: ${e.message}", e) |
| | | _loginMessage.value = "网络错误,请稍后重试" |
| | | } finally { |
| | | _isLoading.value = false |
| | |
| | | _loginMessage.value = response.msg.ifEmpty { "登录失败" } |
| | | } |
| | | } catch (e: Exception) { |
| | | Log.e("LoginError", "Login failed: ${e.message}", e) |
| | | _loginMessage.value = "网络错误,请稍后重试" |
| | | } finally { |
| | | _isLoading.value = false |