Commit c329aeb3 authored by david's avatar david Committed by 杨秀秀

完成注销功能

parent 05387797
......@@ -374,5 +374,11 @@ interface ApiService {
@Headers("Content-type:application/json")
@POST("app/activity/queryAppActivityList")
fun getActivityList(@Body requestBody: RequestBody): Observable<BaseResponse<List<ActivityCenterBean>>>
/**
* 查询活动列表信息
*/
@Headers("Content-type:application/json")
@POST("app/user/closure-with-reason")
fun logoff(@Body requestBody: RequestBody): Observable<BaseResponse<Boolean>>
}
\ No newline at end of file
package com.xx.hbhconsumer.data.http.requst
import com.xx.hbhconsumer.data.http.BaseRespons
import io.reactivex.rxjava3.core.Observable
import me.goldze.mvvmhabit.http.ApiParams
import me.goldze.mvvmhabit.http.BaseResponse
class LogoffRequest : BaseRespons() {
/**
* 获取验证码
*/
fun logoff(accountClosureMark: String, accountClosureReason: String): Observable<BaseResponse<Boolean>> {
return apiService.logoff(ApiParams<LogoffRequestBody>().setParams(
LogoffRequestBody(
accountClosureMark,
accountClosureReason
)
));
}
/**
* 忘记密码入参
*
*/
class LogoffRequestBody(
var accountClosureMark: String,
var accountClosureReason: String
)
}
\ No newline at end of file
......@@ -25,12 +25,12 @@ public class LogoffFirstStepActivity extends BaseActivity<ActivityLogoffFirstSte
public void initData() {
super.initData();
viewModel.logoffType.observe(this, logoffType -> {
if (logoffType == 0) {
if (logoffType == 1) {
binding.rgSecurityReason.clearCheck();
binding.rgOther.clearCheck();
binding.rbUnbindPhone.setChecked(true);
binding.etOtherReason.setEnabled(false);
} else if (logoffType == 1) {
} else if (logoffType == 2) {
binding.rgUnbindPhone.clearCheck();
binding.rgOther.clearCheck();
binding.rbSecurityReason.setChecked(true);
......
......@@ -15,7 +15,7 @@ import me.goldze.mvvmhabit.binding.command.BindingCommand;
public class LogoffFirstStepViewModel extends BaseViewModel<ForgetPwdRequest> {
public ObservableField<String> otherReason = new ObservableField<>("");
public MutableLiveData<Integer> logoffType = new MutableLiveData<>(0);
public MutableLiveData<Integer> logoffType = new MutableLiveData<>(1);
public LogoffFirstStepViewModel(@NonNull Application application) {
super(application);
}
......@@ -29,7 +29,8 @@ public class LogoffFirstStepViewModel extends BaseViewModel<ForgetPwdRequest> {
@Override
public void call() {
Bundle bundle=new Bundle();
bundle.putString("pageStep", "");
bundle.putString("accountClosureReason",logoffType.toString());
bundle.putString("accountClosureMark", otherReason.get());
startActivity(LogoffSecondStepActivity.class, bundle);
}
......@@ -40,7 +41,7 @@ public class LogoffFirstStepViewModel extends BaseViewModel<ForgetPwdRequest> {
public BindingCommand selectUnbindPhone = new BindingCommand(new BindingAction() {
@Override
public void call() {
logoffType.postValue(0);
logoffType.postValue(1);
}
});
......@@ -48,7 +49,7 @@ public class LogoffFirstStepViewModel extends BaseViewModel<ForgetPwdRequest> {
public BindingCommand selectSecurityReason = new BindingCommand(new BindingAction() {
@Override
public void call() {
logoffType.postValue(1);
logoffType.postValue(2);
}
});
......@@ -56,7 +57,7 @@ public class LogoffFirstStepViewModel extends BaseViewModel<ForgetPwdRequest> {
public BindingCommand selectOther = new BindingCommand(new BindingAction() {
@Override
public void call() {
logoffType.postValue(2);
logoffType.postValue(3);
}
});
......
......@@ -4,7 +4,7 @@ import android.os.Bundle;
import com.xx.hbhconsumer.BR;
import com.xx.hbhconsumer.R;
import com.xx.hbhconsumer.data.http.requst.ForgetPwdRequest;
import com.xx.hbhconsumer.data.http.requst.LogoffRequest;
import com.xx.hbhconsumer.databinding.ActivityLogoffSecondStepBinding;
import me.goldze.mvvmhabit.base.BaseActivity;
......@@ -32,7 +32,9 @@ public class LogoffSecondStepActivity extends BaseActivity<ActivityLogoffSecondS
@Override
public LogoffSecondStepViewModel initViewModel() {
ForgetPwdRequest lm = new ForgetPwdRequest();
return new LogoffSecondStepViewModel(getApplication(), lm);
LogoffRequest lm = new LogoffRequest();
String accountClosureMark = getIntent().getStringExtra("accountClosureMark");
String accountClosureReason = getIntent().getStringExtra("accountClosureReason");
return new LogoffSecondStepViewModel(getApplication(), lm, accountClosureReason, accountClosureMark);
}
}
package com.xx.hbhconsumer.ui.logoff;
import static me.goldze.mvvmhabit.utils.Utils.Interceptor_TOKEN;
import android.app.Application;
import androidx.annotation.NonNull;
import com.xx.hbhconsumer.data.http.requst.ForgetPwdRequest;
import com.xx.hbhconsumer.data.http.requst.LogoffRequest;
import com.xx.hbhconsumer.ui.login.LoginActivity;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.http.ApiDisposableObserver;
import me.goldze.mvvmhabit.utils.RxUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;
public class LogoffSecondStepViewModel extends BaseViewModel<ForgetPwdRequest> {
public class LogoffSecondStepViewModel extends BaseViewModel<LogoffRequest> {
String accountClosureMark;
String accountClosureReason;
public LogoffSecondStepViewModel(@NonNull Application application) {
super(application);
}
public LogoffSecondStepViewModel(@NonNull Application application, ForgetPwdRequest model) {
public LogoffSecondStepViewModel(@NonNull Application application, LogoffRequest model, String accountClosureReason, String accountClosureMark) {
super(application, model);
this.accountClosureReason = accountClosureReason;
this.accountClosureMark = accountClosureMark;
}
// 触发确认按钮
......@@ -25,29 +36,29 @@ public class LogoffSecondStepViewModel extends BaseViewModel<ForgetPwdRequest> {
@Override
public void call() {
// model.ForegetPwd(phone.get().toString(), password.get().toString(),code.get().toString())
// .compose(RxUtils.schedulersTransformer()) //线程调度
//// .compose(RxUtils.exceptionTransformer()) // 网络错误的异常转换, 这里可以换成自己的ExceptionHandle
// .doOnSubscribe(LogoffSecondStepViewModel.this)
// .doOnSubscribe(new Consumer<Disposable>() {
// @Override
// public void accept(Disposable disposable) throws Exception {
// showDialog("正在请求...");
// }
// }).subscribe(new ApiDisposableObserver<String>() {
// @Override
// public void onSuccess(String resultBean) {
// //是指token
// Interceptor_TOKEN = "Bearer " + resultBean;
// startActivity(LoginActivity.class);
// }
//
// @Override
// public void onError(String Error) {
// dismissDialog();
// }
//
// });
model.logoff(accountClosureReason, accountClosureReason)
.compose(RxUtils.schedulersTransformer()) //线程调度
// .compose(RxUtils.exceptionTransformer()) // 网络错误的异常转换, 这里可以换成自己的ExceptionHandle
.doOnSubscribe(LogoffSecondStepViewModel.this)
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
}
}).subscribe(new ApiDisposableObserver<Boolean>() {
@Override
public void onSuccess(Boolean resultBean) {
ToastUtils.showShort("注销成功");
startActivity(LoginActivity.class);
finish();
}
@Override
public void onError(String Error) {
dismissDialog();
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment