e3dd3522c108c90f43ec1ba33554e07b7bd01ece.svn-base 3.1 KB

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