| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- package eVVM.apk.ui.login;
- import android.app.Activity;
- import android.app.Dialog;
- import android.content.Intent;
- import android.os.Build;
- import android.os.Bundle;
- import android.os.Environment;
- import android.support.annotation.Nullable;
- import android.text.TextUtils;
- import android.util.Log;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.TextView;
- import com.hjq.dialog.MessageDialog;
- import java.io.File;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import butterknife.BindView;
- import butterknife.ButterKnife;
- import butterknife.OnClick;
- import cn.bingoogolapple.photopicker.activity.BGAPhotoPickerActivity;
- import cn.bingoogolapple.photopicker.imageloader.BGAImage;
- import eVVM.apk.R;
- import eVVM.apk.helper.InputTextHelper;
- import eVVM.apk.helper.basepicker.DataPickerDialog;
- import eVVM.apk.mvp.MvpActivity;
- import eVVM.apk.ui.bean.VerificationCodeBean;
- import eVVM.apk.ui.launcher.LikeActivity;
- import eVVM.apk.ui.login.authentication.AttctContract;
- import eVVM.apk.ui.login.authentication.AttctPresenter;
- import me.jessyan.autosize.utils.AutoSizeUtils;
- /**
- * 实名认证页
- */
- public class AuthenticationActivity extends MvpActivity<AttctPresenter> implements AttctContract.View {
- @BindView(R.id.attc_et_phone)
- EditText attcEtPhone;
- @BindView(R.id.attc_et_name)
- EditText attcEtName;
- @BindView(R.id.attc_et_code)
- EditText attcEtCode;
- @BindView(R.id.attc_et_email)
- EditText attcEtEmail;
- @BindView(R.id.attc_et_license)
- ImageView attcEtLicense;
- @BindView(R.id.attc_et_prove)
- ImageView attcEtProve;
- @BindView(R.id.attc_btn_register)
- Button attcBtnRegister;
- @BindView(R.id.tv_information_hospital)
- TextView tvInformationHospital;
- @BindView(R.id.tv_information_factory)
- TextView tvInformationFactory;
- @BindView(R.id.attc_ll_license)
- LinearLayout attcLlLicense;
- @BindView(R.id.attc_ll_prove)
- LinearLayout attcLlProve;
- @BindView(R.id.attc_et_imgcount)
- TextView attcEtImgcount;
- private File takePhotoDir = new File(Environment.getExternalStorageDirectory(), "eVVM");
- private static final int REQUEST_LICENSE_CHOOSE_FROM_GALLERY = 1325;
- private static final int REQUEST_PROVE_CHOOSE_FROM_GALLERY = 1326;
- private String registerUserId;
- @Override
- protected int getLayoutId() {
- return R.layout.activity_authentication;
- }
- @Override
- protected int getTitleId() {
- return R.id.attc_title;
- }
- @Override
- public void onLeftClick(View v) {
- new MessageDialog.Builder(this)
- .setTitle("") // 标题可以不用填写
- .setMessage("您未完成实名认证,是否退出")
- .setConfirm("确定")
- .setCancel("取消") // 设置 null 表示不显示取消按钮
- //.setAutoDismiss(false) // 设置点击按钮后不关闭对话框
- .setListener(new MessageDialog.OnListener() {
- @Override
- public void onConfirm(Dialog dialog) {
- finish();
- }
- @Override
- public void onCancel(Dialog dialog) {
- //toast("取消了");
- }
- })
- .show();
- }
- @Override
- protected void initView() {
- new InputTextHelper.Builder(this)
- .setMain(attcBtnRegister)
- .addView(attcEtPhone)
- .addView(attcEtName)
- .addView(attcEtCode)
- .addView(attcEtEmail)
- .addView(tvInformationHospital)
- .addView(tvInformationFactory)
- .build();
- Intent in = getIntent();
- registerUserId = in.getStringExtra("registerUserId");
- }
- @Override
- protected void initData() {
- }
- @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})
- public void onViewClicked(View view) {
- switch (view.getId()) {
- case R.id.attc_et_license:
- //上传营业执照
- /*
- 从相册选取二维码图片,这里为了方便演示,使用的是
- https://github.com/bingoogolapple/BGAPhotoPicker-Android
- 这个库来从图库中选择二维码图片,这个库不是必须的,你也可以通过自己的方式从图库中选择图片
- */
- Intent licensePhotoPickerIntent = new BGAPhotoPickerActivity.IntentBuilder(this)
- .cameraFileDir(takePhotoDir)
- .maxChooseCount(3)
- .selectedPhotos(null)
- .pauseOnScroll(false)
- .build();
- startActivityForResult(licensePhotoPickerIntent, REQUEST_LICENSE_CHOOSE_FROM_GALLERY);
- break;
- case R.id.attc_et_prove:
- //上传授权证明
- if (uploadimgpaths1.size() == 0) {
- toast("请先选择营业执照");
- } else {
- Intent provePhotoPickerIntent = new BGAPhotoPickerActivity.IntentBuilder(this)
- .cameraFileDir(takePhotoDir)
- .maxChooseCount(1)
- .selectedPhotos(null)
- .pauseOnScroll(false)
- .build();
- startActivityForResult(provePhotoPickerIntent, REQUEST_PROVE_CHOOSE_FROM_GALLERY);
- }
- break;
- case R.id.attc_btn_register:
- //进行实名认证
- List<String> uploadimgpaths3 = new ArrayList<>();
- if ("预防接种机构".equals(tvInformationHospital.getText().toString())) {
- if (uploadimgpaths1.size() == 0 || uploadimgpaths2.size() == 0) {
- toast("请选择营业执照及授权证明");
- } else {
- uploadimgpaths3.clear();
- uploadimgpaths3.addAll(uploadimgpaths1);
- uploadimgpaths3.addAll(uploadimgpaths2);
- //String user_id = (String) SPUtils.get("USER_ID", "");
- if (TextUtils.isEmpty(registerUserId)) {
- Log.e("getPresenterattct", "" + uploadimgpaths3.toString());
- } else {
- getPresenter().attct(Integer.parseInt(registerUserId), attcEtPhone.getText().toString()
- , attcEtName.getText().toString(), attcEtCode.getText().toString(),
- attcEtEmail.getText().toString(), getRoleId(tvInformationFactory.getText().toString()) + "",
- 0, Build.BRAND + " " + Build.MODEL, uploadimgpaths3);
- }
- }
- } else {
- if (TextUtils.isEmpty(registerUserId)) {
- } else {
- getPresenter().attct(Integer.parseInt(registerUserId), attcEtPhone.getText().toString()
- , attcEtName.getText().toString(), attcEtCode.getText().toString(),
- attcEtEmail.getText().toString(), getRoleId(tvInformationFactory.getText().toString()) + "",
- 0, Build.BRAND + " " + Build.MODEL, uploadimgpaths3);
- }
- }
- break;
- case R.id.tv_information_hospital:
- DataPickerDialog.Builder builder = new DataPickerDialog.Builder(this);
- List<String> data = Arrays.asList(new String[]{"医药企业", "预防接种机构", "预防接受种者", "物流公司"});
- /*List<RoleTypeBean.RoleParen> parentlist = new ArrayList<>();
- parentlist.add(new RoleTypeBean.RoleParen(6,"","医药企业"));
- parentlist.add(new RoleTypeBean.RoleParen(7,"","预防接种机构"));
- parentlist.add(new RoleTypeBean.RoleParen(8,"","预防接受种者"));
- parentlist.add(new RoleTypeBean.RoleParen(9,"","物流公司"));*/
- DataPickerDialog dialog = builder.setData(data).setSelection(0).setTitle("标题")
- .setOnDataSelectedListener(new DataPickerDialog.OnDataSelectedListener() {
- @Override
- public void onDataSelected(String itemValue) {
- if (!TextUtils.isEmpty(tvInformationHospital.getText().toString())) {
- tvInformationFactory.setText("");
- }
- tvInformationHospital.setText(itemValue + "");
- if ("预防接种机构".equals(itemValue)) {
- attcLlLicense.setVisibility(View.VISIBLE);
- attcLlProve.setVisibility(View.VISIBLE);
- } else {
- attcLlLicense.setVisibility(View.GONE);
- attcLlProve.setVisibility(View.GONE);
- }
- }
- }).create();
- dialog.show();
- break;
- case R.id.tv_information_factory:
- if (TextUtils.isEmpty(tvInformationHospital.getText().toString())) {
- toast("请先选择所属类型");
- return;
- } else {
- int roleParentId = getRoleParentId(tvInformationHospital.getText().toString());
- List<String> roleType = getRoleType(roleParentId);
- DataPickerDialog.Builder builder2 = new DataPickerDialog.Builder(this);
- /*List<String> data2 = Arrays.asList(new String[]{"品控人员", "生产人员", "物流人员", "管理人员", "护士", "受种者家属",
- "管理人员", "操作人员","后台管理者"});*/
- DataPickerDialog dialog2 = builder2.setData(roleType).setSelection(0).setTitle("职务")
- .setOnDataSelectedListener(new DataPickerDialog.OnDataSelectedListener() {
- @Override
- public void onDataSelected(String itemValue) {
- tvInformationFactory.setText(itemValue + "");
- //Toast.makeText(getApplicationContext(), itemValue, Toast.LENGTH_SHORT).show();
- }
- }).create();
- dialog2.show();
- }
- break;
- }
- }
- //根据parent名字返回id
- private int getRoleParentId(String name) {
- if ("医药企业".equals(name))
- return 6;
- if ("预防接种机构".equals(name))
- return 7;
- if ("预防接受种者".equals(name))
- return 8;
- if ("物流公司".equals(name))
- return 9;
- return 0;
- }
- //根据id返回字列表
- private List<String> getRoleType(int parentId) {
- List<String> list = new ArrayList<>();
- switch (parentId) {
- case 6:
- list.clear();
- list.add("管理员");
- list.add("操作员");
- list.add("品控人员");
- list.add("生产人员");
- list.add("物流人员");
- list.add("后台管理员");
- return list;
- case 7:
- list.clear();
- list.add("医生");
- list.add("管理人员");
- list.add("护士");
- return list;
- case 8:
- list.clear();
- list.add("受种者本人");
- list.add("受种者家属");
- return list;
- case 9:
- list.clear();
- list.add("管理人员");
- list.add("操作人员");
- return list;
- default:
- return null;
- }
- }
- //根据名字返回id
- private int getRoleId(String name) {
- if ("超级管理员".equals(name))
- return 1;
- if ("医生".equals(name))
- return 2;
- if ("管理员".equals(name))
- return 3;
- if ("操作员".equals(name))
- return 4;
- if ("受种着本人".equals(name))
- return 5;
- if ("医药企业".equals(name))
- return 6;
- if ("预防接种机构".equals(name))
- return 7;
- if ("预防接种者".equals(name))
- return 8;
- if ("物流公司".equals(name))
- return 9;
- if ("其他".equals(name))
- return 10;
- if ("品控人员".equals(name))
- return 11;
- if ("生产人员".equals(name))
- return 12;
- if ("物流人员".equals(name))
- return 13;
- if ("管理人员".equals(name) && "预防接种机构".equals(tvInformationHospital.getText().toString()))
- return 14;
- if ("护士".equals(name))
- return 15;
- if ("受种者家属".equals(name))
- return 16;
- if ("管理人员".equals(name) && "物流公司".equals(tvInformationHospital.getText().toString()))
- return 17;
- if ("操作人员".equals(name))
- return 18;
- if ("后台管理者".equals(name))
- return 19;
- return 0;
- }
- @Override
- protected AttctPresenter createPresenter() {
- return new AttctPresenter();
- }
- @Override
- public void attctError(String msg) {
- toast(msg);
- }
- @Override
- public void attctSuccess(VerificationCodeBean data) {
- // Log.e("attctSuccessVN",data.getData().toString()+data.getMsg());
- toast("注册成功");
- Intent in = new Intent(this, LikeActivity.class);
- in.putExtra("LikeUserId", "" + Double.valueOf(String.valueOf(data.getData())).intValue());
- in.putExtra("LikeRoleId", getRoleId(tvInformationFactory.getText().toString()) + "");
- startActivityFinish(in);
- }
- private List<String> uploadimgpaths1 = new ArrayList<>();
- private List<String> uploadimgpaths2 = new ArrayList<>();
- @Override
- protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_LICENSE_CHOOSE_FROM_GALLERY) {
- //营业执照回调
- List<String> selectedPhotos = BGAPhotoPickerActivity.getSelectedPhotos(data);
- uploadimgpaths1.clear();
- uploadimgpaths1.addAll(selectedPhotos);
- attcEtImgcount.setText("照片数量:" + uploadimgpaths1.size() + "张");
- BGAImage.display(attcEtLicense, R.mipmap.iv_upload_icon, selectedPhotos.get(0), AutoSizeUtils.dp2px(this, 77), AutoSizeUtils.dp2px(this, 43));
- Log.e("uploadimgpaths1", "" + uploadimgpaths1.toString());
- } else if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_PROVE_CHOOSE_FROM_GALLERY) {
- //授权证明回调
- String picturePath = BGAPhotoPickerActivity.getSelectedPhotos(data).get(0);
- uploadimgpaths2.clear();
- uploadimgpaths2.add(picturePath);
- BGAImage.display(attcEtProve, R.mipmap.iv_upload_icon, picturePath, AutoSizeUtils.dp2px(this, 77), AutoSizeUtils.dp2px(this, 43));
- Log.e("uploadimgpaths2", "" + uploadimgpaths2.toString());
- }
- }
- }
|