ae260bfa13e665389e493280c973ef3620438a20.svn-base 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package eVVM.apk.ui.login.authentication;
  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.Gson;
  6. import java.io.IOException;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import eVVM.apk.api.ApiUrl;
  11. import eVVM.apk.mvp.MvpModel;
  12. import eVVM.apk.ui.bean.VerificationCodeBean;
  13. import okhttp3.MultipartBody;
  14. import okhttp3.ResponseBody;
  15. /**
  16. * Created by Android Studio.
  17. * User: zbb
  18. * Date: 2019/6/3
  19. * Describe: AttctModel
  20. */
  21. public class AttctModel extends MvpModel<AttctOnListener> {
  22. public AttctModel() {
  23. }
  24. /***
  25. *
  26. * @param userId 用户id 注册成功后返回
  27. * @param companyName 公司名称
  28. * @param userName 用户姓名
  29. * @param idCard 身份证号
  30. * @param email 邮箱
  31. * @param roleId 职务
  32. * @param phoneType 手机类型 0安卓 1ios
  33. * @param phoneModel 手机型号
  34. * @param uploadimgpaths 上传图片的路径
  35. */
  36. public void attct(int userId, String companyName, String userName, String idCard,
  37. String email, String roleId, int phoneType, String phoneModel, List<String> uploadimgpaths) {
  38. Map<String ,Object> map = new HashMap<>();
  39. map.put("userId",userId+"");
  40. map.put("companyId",companyName+"");
  41. map.put("userName",userName+"");
  42. map.put("idCard",idCard+"");
  43. map.put("email",email+"");
  44. map.put("roleId",roleId+"");
  45. map.put("phoneType",phoneType+"");
  46. map.put("phoneModel",phoneModel+"");
  47. RxHttpUtils.uploadImagesWithParams(ApiUrl.BASE_URL+ApiUrl.ARTICLE_LIST+"perfectInfo","files",map,uploadimgpaths)
  48. .compose(Transformer.<ResponseBody>switchSchedulers())
  49. .subscribe(new CommonObserver<ResponseBody>() {
  50. @Override
  51. protected void onError(String errorMsg) {
  52. getListener().onFail(errorMsg);
  53. }
  54. @Override
  55. protected void onSuccess(ResponseBody data) {
  56. try {
  57. String json = data.string();
  58. Gson gson = new Gson();
  59. VerificationCodeBean verificationCodeBean = gson.fromJson(json, VerificationCodeBean.class);
  60. if (verificationCodeBean.getCode() == 200){
  61. getListener().onSucceed(verificationCodeBean);
  62. }else{
  63. getListener().onFail(verificationCodeBean.getMsg());
  64. }
  65. } catch (IOException e) {
  66. e.printStackTrace();
  67. }
  68. }
  69. });
  70. }
  71. }