Linjiajia
2023-09-12 efafbbf142c81c233c71de636a2d3ce9dc2124f0
app/src/main/java/com/application/zhangshi_app_android/ui/login/LoginActivityViewModel.java
@@ -38,6 +38,7 @@
    private MutableLiveData<String> againPassword = new MutableLiveData<>();
    private MutableLiveData<Boolean> passwordVisibility = new MutableLiveData<>();
    private MutableLiveData<Boolean> againPasswordVisibility = new MutableLiveData<>();
    private MutableLiveData<String> selectLoginBackgroundLiveData = new MutableLiveData<>();//背景图
    private MutableLiveData<String> value = new MutableLiveData<>();
    public LoginActivityViewModel(@NonNull Application application) {
@@ -92,7 +93,7 @@
            return;
        }
        if (captchaImageLiveData.getValue() != null){
            model.login(new LoginRequestBean(username.getValue(),password.getValue(),captchaImageLiveData.getValue().getValue(),captchaImageLiveData.getValue().getUuid()))
            model.login(new LoginRequestBean(username.getValue(),password.getValue(),value.getValue(),captchaImageLiveData.getValue().getUuid()))
                    .compose(RxUtils.schedulersTransformer())
                    .subscribe(new Observer<ResultData<LoginResponseBean>>() {
                        @Override
@@ -105,8 +106,9 @@
                            if (loginResponseBeanResultData.getCode() == CODE_SUCCESS){
                                String token = loginResponseBeanResultData.getData().getToken();
                                UserManager.getInstance().setToken(token);
                                ToastUtils.showShort("登陆成功");
                                AppManager.getAppManager().startActivity(MainActivity.class);
                                AppManager.getAppManager().finishCurrentActivity();
                                ToastUtils.showShort("登陆成功");
                            }else {
                                changeStateView(StateViewEnum.DATA_ERROR);
                                messageLiveData.postValue(loginResponseBeanResultData.getMsg());
@@ -226,4 +228,12 @@
    public void setValue(MutableLiveData<String> value) {
        this.value = value;
    }
    public MutableLiveData<String> getSelectLoginBackgroundLiveData() {
        return selectLoginBackgroundLiveData;
    }
    public void setSelectLoginBackgroundLiveData(MutableLiveData<String> selectLoginBackgroundLiveData) {
        this.selectLoginBackgroundLiveData = selectLoginBackgroundLiveData;
    }
}