package eVVM.apk.ui.My.information; 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.helper.SPUtils; import eVVM.apk.mvp.MvpModel; import eVVM.apk.ui.bean.VerificationCodeBean; /** * Created by Android Studio. * User: zbb * Date: 2019/6/3 * Describe: InformationModel */ public class InformationModel extends MvpModel { public InformationModel() { } public void information(String telephone, String userName, String code ,String password, String email) { // String user_token = (String) SPUtils.get("USER_TOKEN", ""); Map map = new HashMap<>(); map.put("telephone", Encrypt.encrypt(telephone)); map.put("userName",userName); map.put("code",code); map.put("password", MD5.GetMD5Code(password)); map.put("email",email); //map.put("token",user_token); RxHttpUtils.createApi(ApiService.class) .informationdoc(map) .compose(Transformer.switchSchedulers()) .subscribe(new CommonObserver() { @Override protected void onError(String errorMsg) { getListener().onFail(errorMsg); } @Override protected void onSuccess(VerificationCodeBean verificationCodeBean) { if (verificationCodeBean.getCode() == 200){ getListener().onSucceed(verificationCodeBean); }else { getListener().onFail(verificationCodeBean.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()); } } }); } }