|
|
@@ -6,6 +6,7 @@ import android.content.Intent;
|
|
|
import android.text.TextUtils;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
+import com.tencent.ocr.sdk.entity.IdCardOcrResult;
|
|
|
import com.tongyu.luck.happywork.AppCacheManager;
|
|
|
import com.tongyu.luck.happywork.R;
|
|
|
import com.tongyu.luck.happywork.baselibrary.EventConstant;
|
|
|
@@ -38,6 +39,7 @@ import okhttp3.RequestBody;
|
|
|
public class RealNameAuthenticationModel extends BaseModel implements RealNameAuthenticationContacts.IRealNameAuthenticationModel {
|
|
|
private String imagePathPositive, imagePathReverse;
|
|
|
private ApiORCBean apiORCBean;
|
|
|
+ private IdCardOcrResult result;
|
|
|
private int clickPosition;
|
|
|
|
|
|
public RealNameAuthenticationModel(Context mContext) {
|
|
|
@@ -131,12 +133,10 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
|
|
|
/**
|
|
|
* 实名认证
|
|
|
*
|
|
|
- * @param name
|
|
|
- * @param idCode
|
|
|
* @param callBack
|
|
|
*/
|
|
|
@Override
|
|
|
- public void httpRealAuthentication(String name, String idCode, final MvpDataCallBack<Boolean> callBack) {
|
|
|
+ public void httpRealAuthentication(final MvpDataCallBack<Boolean> callBack) {
|
|
|
MultipartBody.Builder builder = new RetrofitHttpParams(mContext).getRequestMultipartBody();
|
|
|
if (FileUtils.isFileExit(imagePathPositive)) {
|
|
|
File file = new File(imagePathPositive.replace("file://", ""));
|
|
|
@@ -150,8 +150,9 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
|
|
|
MediaType.parse("multipart/form-data;charset=UTF-8"), file);
|
|
|
builder.addFormDataPart("idCardBack", file.getName(), requestBody);
|
|
|
}
|
|
|
- builder.addFormDataPart("realName", name);
|
|
|
- builder.addFormDataPart("idCardNumber", idCode);
|
|
|
+ builder.addFormDataPart("realName", result.getName());
|
|
|
+ builder.addFormDataPart("idCardNumber", result.getIdNum());
|
|
|
+ builder.addFormDataPart("nation", result.getNation());
|
|
|
new UserSubscribe(mContext).requestRealApprove(builder.build(), new ApiObserver<ApiApproveBean>(mContext, true, false) {
|
|
|
@Override
|
|
|
public void onSuccess(ApiApproveBean data) {
|
|
|
@@ -172,6 +173,16 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 识别结果
|
|
|
+ *
|
|
|
+ * @param result
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void setResult(IdCardOcrResult result) {
|
|
|
+ this.result = result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* orc是否获得数据
|
|
|
*
|
|
|
* @return
|
|
|
@@ -184,34 +195,16 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
|
|
|
/**
|
|
|
* 检查提交数据合法性
|
|
|
*
|
|
|
- * @param name
|
|
|
- * @param idCode
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean isValid(String name, String idCode) {
|
|
|
- if (TextUtils.isEmpty(name)) {
|
|
|
+ public boolean isValid() {
|
|
|
+ if (result == null || !FileUtils.isFileExit(imagePathPositive)) {
|
|
|
ToastUtils.show(mContext, R.string.toast_input_real_name);
|
|
|
return false;
|
|
|
}
|
|
|
- if (CommonUtils.isHaveSpecialText(name)) {
|
|
|
- ToastUtils.show(mContext, R.string.toast_input_real_name2);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(idCode)) {
|
|
|
- ToastUtils.show(mContext, R.string.toast_input_id_code);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!CommonUtils.is18ByteIdCard(idCode)) {
|
|
|
- ToastUtils.show(mContext, R.string.toast_input_id_code2);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!FileUtils.isFileExit(imagePathPositive)) {
|
|
|
- ToastUtils.show(mContext, R.string.toast_input_choose_image1);
|
|
|
- return false;
|
|
|
- }
|
|
|
if (!FileUtils.isFileExit(imagePathReverse)) {
|
|
|
- ToastUtils.show(mContext, R.string.toast_input_choose_image2);
|
|
|
+ ToastUtils.show(mContext, R.string.toast_input_receive);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|