43fffac5b9ca372939f4c78363cf53e6a1a4d3d8.svn-base 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package eVVM.apk.ui.My.information;
  2. import com.allen.library.RxHttpUtils;
  3. import com.allen.library.interceptor.Transformer;
  4. import com.allen.library.observer.CommonObserver;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import eVVM.apk.api.ApiService;
  8. import eVVM.apk.helper.Encrypt;
  9. import eVVM.apk.helper.MD5;
  10. import eVVM.apk.helper.SPUtils;
  11. import eVVM.apk.mvp.MvpModel;
  12. import eVVM.apk.ui.bean.VerificationCodeBean;
  13. /**
  14. * Created by Android Studio.
  15. * User: zbb
  16. * Date: 2019/6/3
  17. * Describe: InformationModel
  18. */
  19. public class InformationModel extends MvpModel<InformationOnListener> {
  20. public InformationModel() {
  21. }
  22. public void information(String telephone, String userName, String code ,String password, String email) {
  23. // String user_token = (String) SPUtils.get("USER_TOKEN", "");
  24. Map<String,String> map = new HashMap<>();
  25. map.put("telephone", Encrypt.encrypt(telephone));
  26. map.put("userName",userName);
  27. map.put("code",code);
  28. map.put("password", MD5.GetMD5Code(password));
  29. map.put("email",email);
  30. //map.put("token",user_token);
  31. RxHttpUtils.createApi(ApiService.class)
  32. .informationdoc(map)
  33. .compose(Transformer.<VerificationCodeBean>switchSchedulers())
  34. .subscribe(new CommonObserver<VerificationCodeBean>() {
  35. @Override
  36. protected void onError(String errorMsg) {
  37. getListener().onFail(errorMsg);
  38. }
  39. @Override
  40. protected void onSuccess(VerificationCodeBean verificationCodeBean) {
  41. if (verificationCodeBean.getCode() == 200){
  42. getListener().onSucceed(verificationCodeBean);
  43. }else {
  44. getListener().onFail(verificationCodeBean.getMsg());
  45. }
  46. }
  47. });
  48. }
  49. public void getCode(String telephone, int type) {
  50. Map<String, String> map = new HashMap<>();
  51. map.put("telephone", "" + Encrypt.encrypt(telephone));
  52. map.put("type", "" + type);
  53. RxHttpUtils.createApi(ApiService.class)
  54. .getCode(map)
  55. .compose(Transformer.<VerificationCodeBean>switchSchedulers())
  56. .subscribe(new CommonObserver<VerificationCodeBean>() {
  57. @Override
  58. protected void onError(String errorMsg) {
  59. getListener().onCodeFail(errorMsg);
  60. }
  61. @Override
  62. protected void onSuccess(VerificationCodeBean codeData) {
  63. if (codeData.getCode() == 200){
  64. getListener().onCodeSucceed(codeData);
  65. }else {
  66. getListener().onCodeFail(codeData.getMsg());
  67. }
  68. }
  69. });
  70. }
  71. }