8c51f3f1c81f4198edcf434b4d8710b9e2d1c1de.svn-base 3.0 KB

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