zhengyiming
4 天以前 4c6f6d453785f4dba80e874a1b6172b3207b434f
packages/hooks/identify.ts
@@ -1,26 +1,20 @@
import { EnumOcrAccess } from '@12333/constants';
import * as accountServices from '@12333/services/api/Account';
import * as ocrUtilsServices from '@12333/services/apiV2/ocrUtils';
import { FileItem } from '@nutui/nutui-taro/dist/types/__VUE/uploader/type';
import _ from 'lodash';
type VatLicenseOptions = {
  onSuccess?: (res: API.LicenseOcrModel) => any;
  onSuccess?: (res: API.BaiduOcrBusinessLicenseResultModel) => any;
};
export async function vatLicense(response: FileItem, options: VatLicenseOptions = {}) {
  try {
    if (response?.url) {
      const { onSuccess } = options;
      let res = await accountServices.vatLicense({
      let res = await ocrUtilsServices.getLicenseOcr({
        url: response.url,
      });
      onSuccess?.(
        _.mapValues(res, (x) => {
          if (x === '无') return '';
          return x;
        })
      );
      onSuccess?.(res.model);
    }
  } catch (error) {}
}
@@ -29,7 +23,7 @@
  access?: EnumOcrAccess;
  scene?: string;
  isOssUrl?: boolean;
  response?: FileItem;
  url?: string;
  onSuccess?: (res: API.GetIdentityFrontOcrCommandResult) => any;
};
@@ -37,11 +31,11 @@
  options: UserCredentialVerifyOcrIDCardOptions = {}
) {
  try {
    const { onSuccess, access, isOssUrl, response, scene } = options;
    if (response?.path) {
    const { onSuccess, access, isOssUrl, url, scene } = options;
    if (url) {
      let res = await ocrUtilsServices.getIdentityFrontOcr({
        access: access,
        url: response.path,
        url: url,
        isOssUrl: isOssUrl,
      });
      onSuccess?.(res);