tj
2025-03-20 90b7acecef96a7b4927301847efbe11a1f0336c2
app/src/main/java/com/example/firstapp/ui/login/LoginViewModel.kt
@@ -6,6 +6,7 @@
import kotlinx.coroutines.launch
import androidx.lifecycle.ViewModel
import com.example.firstapp.database.service.RetrofitClient
import com.example.firstapp.utils.Log
class LoginViewModel : ViewModel() {
@@ -29,6 +30,7 @@
                    _loginMessage.value = response.msg.ifEmpty { "发送验证码失败" }
                }
            } catch (e: Exception) {
                Log.e("LoginError", "Login failed: ${e.message}", e)
                _loginMessage.value = "网络错误,请稍后重试"
            } finally {
                _isLoading.value = false
@@ -47,6 +49,7 @@
                    _loginMessage.value = response.msg.ifEmpty { "登录失败" }
                }
            } catch (e: Exception) {
                Log.e("LoginError", "Login failed: ${e.message}", e)
                _loginMessage.value = "网络错误,请稍后重试"
            } finally {
                _isLoading.value = false