cbd2fe00322ed0f4449604a83d905004245acd44.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. package eVVM.apk.ui.login;
  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.os.Environment;
  6. import android.support.annotation.Nullable;
  7. import android.text.TextUtils;
  8. import android.util.Log;
  9. import android.view.View;
  10. import android.widget.Button;
  11. import android.widget.EditText;
  12. import android.widget.ImageView;
  13. import android.widget.TextView;
  14. import java.io.File;
  15. import java.util.ArrayList;
  16. import java.util.Arrays;
  17. import java.util.List;
  18. import butterknife.BindView;
  19. import butterknife.ButterKnife;
  20. import butterknife.OnClick;
  21. import cn.bingoogolapple.photopicker.activity.BGAPhotoPickerActivity;
  22. import cn.bingoogolapple.photopicker.imageloader.BGAImage;
  23. import eVVM.apk.R;
  24. import eVVM.apk.helper.InputTextHelper;
  25. import eVVM.apk.helper.SPUtils;
  26. import eVVM.apk.helper.SystemUtil;
  27. import eVVM.apk.helper.basepicker.DataPickerDialog;
  28. import eVVM.apk.mvp.MvpActivity;
  29. import eVVM.apk.ui.bean.VerificationCodeBean;
  30. import eVVM.apk.ui.launcher.LikeActivity;
  31. import eVVM.apk.ui.login.authentication.AttctContract;
  32. import eVVM.apk.ui.login.authentication.AttctPresenter;
  33. import me.jessyan.autosize.utils.AutoSizeUtils;
  34. /**
  35. * 实名认证页
  36. */
  37. public class AuthenticationActivity extends MvpActivity<AttctPresenter> implements AttctContract.View {
  38. @BindView(R.id.attc_et_phone)
  39. EditText attcEtPhone;
  40. @BindView(R.id.attc_et_name)
  41. EditText attcEtName;
  42. @BindView(R.id.attc_et_code)
  43. EditText attcEtCode;
  44. @BindView(R.id.attc_et_email)
  45. EditText attcEtEmail;
  46. @BindView(R.id.attc_et_license)
  47. ImageView attcEtLicense;
  48. @BindView(R.id.attc_et_prove)
  49. ImageView attcEtProve;
  50. @BindView(R.id.attc_btn_register)
  51. Button attcBtnRegister;
  52. @BindView(R.id.tv_information_hospital)
  53. TextView tvInformationHospital;
  54. @BindView(R.id.tv_information_factory)
  55. TextView tvInformationFactory;
  56. private File takePhotoDir = new File(Environment.getExternalStorageDirectory(), "eVVM");
  57. private static final int REQUEST_LICENSE_CHOOSE_FROM_GALLERY = 1325;
  58. private static final int REQUEST_PROVE_CHOOSE_FROM_GALLERY = 1326;
  59. private String registerUserId;
  60. @Override
  61. protected int getLayoutId() {
  62. return R.layout.activity_authentication;
  63. }
  64. @Override
  65. protected int getTitleId() {
  66. return R.id.attc_title;
  67. }
  68. @Override
  69. protected void initView() {
  70. new InputTextHelper.Builder(this)
  71. .setMain(attcBtnRegister)
  72. .addView(attcEtPhone)
  73. .addView(attcEtName)
  74. .addView(attcEtCode)
  75. .addView(attcEtEmail)
  76. .addView(tvInformationHospital)
  77. .addView(tvInformationFactory)
  78. .build();
  79. Intent in = getIntent();
  80. registerUserId = in.getStringExtra("registerUserId");
  81. }
  82. @Override
  83. protected void initData() {
  84. }
  85. @OnClick({R.id.attc_et_license, R.id.attc_et_prove, R.id.attc_btn_register, R.id.tv_information_hospital, R.id.tv_information_factory})
  86. public void onViewClicked(View view) {
  87. switch (view.getId()) {
  88. case R.id.attc_et_license:
  89. //上传营业执照
  90. /*
  91. 从相册选取二维码图片,这里为了方便演示,使用的是
  92. https://github.com/bingoogolapple/BGAPhotoPicker-Android
  93. 这个库来从图库中选择二维码图片,这个库不是必须的,你也可以通过自己的方式从图库中选择图片
  94. */
  95. Intent licensePhotoPickerIntent = new BGAPhotoPickerActivity.IntentBuilder(this)
  96. .cameraFileDir(takePhotoDir)
  97. .maxChooseCount(1)
  98. .selectedPhotos(null)
  99. .pauseOnScroll(false)
  100. .build();
  101. startActivityForResult(licensePhotoPickerIntent, REQUEST_LICENSE_CHOOSE_FROM_GALLERY);
  102. break;
  103. case R.id.attc_et_prove:
  104. //上传授权证明
  105. if (uploadimgpaths.size() == 0) {
  106. toast("请先上传营业执照");
  107. } else {
  108. Intent provePhotoPickerIntent = new BGAPhotoPickerActivity.IntentBuilder(this)
  109. .cameraFileDir(takePhotoDir)
  110. .maxChooseCount(1)
  111. .selectedPhotos(null)
  112. .pauseOnScroll(false)
  113. .build();
  114. startActivityForResult(provePhotoPickerIntent, REQUEST_PROVE_CHOOSE_FROM_GALLERY);
  115. }
  116. break;
  117. case R.id.attc_btn_register:
  118. //进行实名认证
  119. if (uploadimgpaths.size() < 2) {
  120. toast("请上传营业执照及授权证明");
  121. } else {
  122. //String user_id = (String) SPUtils.get("USER_ID", "");
  123. if (TextUtils.isEmpty(registerUserId)) {
  124. } else {
  125. getPresenter().attct(Integer.parseInt(registerUserId), attcEtPhone.getText().toString()
  126. , attcEtName.getText().toString(), attcEtCode.getText().toString(),
  127. attcEtEmail.getText().toString(), getRoleId(tvInformationFactory.getText().toString()) + "",
  128. 0, SystemUtil.getSystemModel(), uploadimgpaths);
  129. }
  130. }
  131. break;
  132. case R.id.tv_information_hospital:
  133. DataPickerDialog.Builder builder = new DataPickerDialog.Builder(this);
  134. List<String> data = Arrays.asList(new String[]{"医药企业", "预防接种机构", "预防接受种者", "物流公司"});
  135. /*List<RoleTypeBean.RoleParen> parentlist = new ArrayList<>();
  136. parentlist.add(new RoleTypeBean.RoleParen(6,"","医药企业"));
  137. parentlist.add(new RoleTypeBean.RoleParen(7,"","预防接种机构"));
  138. parentlist.add(new RoleTypeBean.RoleParen(8,"","预防接受种者"));
  139. parentlist.add(new RoleTypeBean.RoleParen(9,"","物流公司"));*/
  140. DataPickerDialog dialog = builder.setData(data).setSelection(0).setTitle("标题")
  141. .setOnDataSelectedListener(new DataPickerDialog.OnDataSelectedListener() {
  142. @Override
  143. public void onDataSelected(String itemValue) {
  144. if (!TextUtils.isEmpty(tvInformationHospital.getText().toString())) {
  145. tvInformationFactory.setText("");
  146. }
  147. tvInformationHospital.setText(itemValue + "");
  148. }
  149. }).create();
  150. dialog.show();
  151. break;
  152. case R.id.tv_information_factory:
  153. if (TextUtils.isEmpty(tvInformationHospital.getText().toString())) {
  154. toast("请先选择所属类型");
  155. return;
  156. } else {
  157. int roleParentId = getRoleParentId(tvInformationHospital.getText().toString());
  158. List<String> roleType = getRoleType(roleParentId);
  159. DataPickerDialog.Builder builder2 = new DataPickerDialog.Builder(this);
  160. /*List<String> data2 = Arrays.asList(new String[]{"品控人员", "生产人员", "物流人员", "管理人员", "护士", "受种者家属",
  161. "管理人员", "操作人员","后台管理者"});*/
  162. DataPickerDialog dialog2 = builder2.setData(roleType).setSelection(0).setTitle("职务")
  163. .setOnDataSelectedListener(new DataPickerDialog.OnDataSelectedListener() {
  164. @Override
  165. public void onDataSelected(String itemValue) {
  166. tvInformationFactory.setText(itemValue + "");
  167. //Toast.makeText(getApplicationContext(), itemValue, Toast.LENGTH_SHORT).show();
  168. }
  169. }).create();
  170. dialog2.show();
  171. }
  172. break;
  173. }
  174. }
  175. //根据parent名字返回id
  176. private int getRoleParentId(String name) {
  177. if ("医药企业".equals(name))
  178. return 6;
  179. if ("预防接种机构".equals(name))
  180. return 7;
  181. if ("预防接受种者".equals(name))
  182. return 8;
  183. if ("物流公司".equals(name))
  184. return 9;
  185. return 0;
  186. }
  187. //根据id返回字列表
  188. private List<String> getRoleType(int parentId) {
  189. List<String> list = new ArrayList<>();
  190. switch (parentId) {
  191. case 6:
  192. list.clear();
  193. list.add("管理员");
  194. list.add("操作员");
  195. list.add("品控人员");
  196. list.add("生产人员");
  197. list.add("物流人员");
  198. list.add("后台管理员");
  199. return list;
  200. case 7:
  201. list.clear();
  202. list.add("医生");
  203. list.add("管理人员");
  204. list.add("护士");
  205. return list;
  206. case 8:
  207. list.clear();
  208. list.add("受种者本人");
  209. list.add("受种者家属");
  210. return list;
  211. case 9:
  212. list.clear();
  213. list.add("管理人员");
  214. list.add("操作人员");
  215. return list;
  216. default:
  217. return null;
  218. }
  219. }
  220. //根据名字返回id
  221. private int getRoleId(String name) {
  222. if ("超级管理员".equals(name))
  223. return 1;
  224. if ("医生".equals(name))
  225. return 2;
  226. if ("管理员".equals(name))
  227. return 3;
  228. if ("操作员".equals(name))
  229. return 4;
  230. if ("受种着本人".equals(name))
  231. return 5;
  232. if ("医药企业".equals(name))
  233. return 6;
  234. if ("预防接种机构".equals(name))
  235. return 7;
  236. if ("预防接种者".equals(name))
  237. return 8;
  238. if ("物流公司".equals(name))
  239. return 9;
  240. if ("其他".equals(name))
  241. return 10;
  242. if ("品控人员".equals(name))
  243. return 11;
  244. if ("生产人员".equals(name))
  245. return 12;
  246. if ("物流人员".equals(name))
  247. return 13;
  248. if ("管理人员".equals(name) && "预防接种机构".equals(tvInformationHospital.getText().toString()))
  249. return 14;
  250. if ("护士".equals(name))
  251. return 15;
  252. if ("受种者家属".equals(name))
  253. return 16;
  254. if ("管理人员".equals(name) && "物流公司".equals(tvInformationHospital.getText().toString()))
  255. return 17;
  256. if ("操作人员".equals(name))
  257. return 18;
  258. if ("后台管理者".equals(name))
  259. return 19;
  260. return 0;
  261. }
  262. @Override
  263. protected AttctPresenter createPresenter() {
  264. return new AttctPresenter();
  265. }
  266. @Override
  267. public void attctError(String msg) {
  268. toast(msg);
  269. }
  270. @Override
  271. public void attctSuccess(VerificationCodeBean data) {
  272. toast("注册成功");
  273. startActivityFinish(LikeActivity.class);
  274. }
  275. private List<String> uploadimgpaths = new ArrayList<>();
  276. @Override
  277. protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
  278. super.onActivityResult(requestCode, resultCode, data);
  279. if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_LICENSE_CHOOSE_FROM_GALLERY) {
  280. //营业执照回调
  281. String picturePath = BGAPhotoPickerActivity.getSelectedPhotos(data).get(0);
  282. if (uploadimgpaths.size() == 0) { //这里主要是为了让第一张图片必须是营业执照 第二张是授权证明
  283. uploadimgpaths.add(picturePath);
  284. } else if (uploadimgpaths.size() > 0) {
  285. uploadimgpaths.remove(0);
  286. uploadimgpaths.add(0, picturePath);
  287. }
  288. BGAImage.display(attcEtLicense, R.mipmap.iv_upload_icon, picturePath, AutoSizeUtils.dp2px(this, 77), AutoSizeUtils.dp2px(this, 43));
  289. Log.e("uploadimgpaths1", "" + uploadimgpaths.toString());
  290. } else if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_PROVE_CHOOSE_FROM_GALLERY) {
  291. //授权证明回调
  292. String picturePath = BGAPhotoPickerActivity.getSelectedPhotos(data).get(0);
  293. if (uploadimgpaths.size() == 2) {
  294. uploadimgpaths.remove(1);
  295. uploadimgpaths.add(picturePath);
  296. } else {
  297. uploadimgpaths.add(picturePath);
  298. }
  299. BGAImage.display(attcEtProve, R.mipmap.iv_upload_icon, picturePath, AutoSizeUtils.dp2px(this, 77), AutoSizeUtils.dp2px(this, 43));
  300. Log.e("uploadimgpaths2", "" + uploadimgpaths.toString());
  301. }
  302. }
  303. }