36bad85f75b1c86e25431d0460903c3d8095c233.svn-base 16 KB

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