package eVVM.apk.ui.login.findpwd; import com.allen.library.RxHttpUtils; import com.allen.library.interceptor.Transformer; import com.allen.library.observer.CommonObserver; import java.util.HashMap; import java.util.Map; import eVVM.apk.api.ApiService; import eVVM.apk.helper.Encrypt; import eVVM.apk.helper.MD5; import eVVM.apk.mvp.MvpModel; import eVVM.apk.ui.bean.VerificationCodeBean; /** * Created by Android Studio. * User: zbb * Date: 2019/6/1 * Describe: FindpwdModel */ public class FindpwdModel extends MvpModel { public FindpwdModel() { } public void findpwd(String telephone, String password,String rePassword, String code) { Map map = new HashMap<>(); map.put("telephone", "" + Encrypt.encrypt(telephone)); map.put("password", "" + MD5.GetMD5Code(password)); map.put("rePassword", "" + MD5.GetMD5Code(rePassword)); map.put("code", "" + code); RxHttpUtils.createApi(ApiService.class) .findpwd(map) .compose(Transformer.switchSchedulers()) .subscribe(new CommonObserver() { @Override protected void onError(String errorMsg) { getListener().onFail(errorMsg); } @Override protected void onSuccess(VerificationCodeBean findpwdData) { if (findpwdData.getCode() == 200) { getListener().onSucceed(findpwdData); } else { getListener().onFail(findpwdData.getMsg()); } } }); } public void getCode(String telephone, int type) { Map map = new HashMap<>(); map.put("telephone", "" + Encrypt.encrypt(telephone)); map.put("type", "" + type); RxHttpUtils.createApi(ApiService.class) .getCode(map) .compose(Transformer.switchSchedulers()) .subscribe(new CommonObserver() { @Override protected void onError(String errorMsg) { getListener().onCodeFail(errorMsg); } @Override protected void onSuccess(VerificationCodeBean codeData) { if (codeData.getCode() == 200) { getListener().onCodeSucceed(codeData); } else { getListener().onCodeFail(codeData.getMsg()); } } }); } }