zhengyiming
13 小时以前 19fd07d35d59b54ad9154eab18d253fac1fa49f0
packages/hooks/identify.ts
@@ -1,5 +1,6 @@
import { EnumOcrAccess } from '@12333/constants';
import * as accountServices from '@12333/services/api/Account';
import * as commonServices from '@12333/services/api/Common';
import * as ocrUtilsServices from '@12333/services/apiV2/ocrUtils';
import { FileItem } from '@nutui/nutui-taro/dist/types/__VUE/uploader/type';
import _ from 'lodash';
@@ -25,18 +26,23 @@
}
type UserCredentialVerifyOcrIDCardOptions = {
  onSuccess?: (res: API.UserCredentialVerifyOcrIDCardResponse) => any;
  access?: EnumOcrAccess;
  scene?: string;
  isOssUrl?: boolean;
  response?: FileItem;
  onSuccess?: (res: API.GetIdentityFrontOcrCommandResult) => any;
};
export async function userCredentialVerifyOcrIDCard(
  response: FileItem,
  options: UserCredentialVerifyOcrIDCardOptions = {}
) {
  try {
    if (response?.url) {
      const { onSuccess } = options;
      let res = await commonServices.userCredentialVerifyOcrIDCard({
        identityImageUrl: response.url,
    const { onSuccess, access, isOssUrl, response, scene } = options;
    if (response?.path) {
      let res = await ocrUtilsServices.getIdentityFrontOcr({
        access: access,
        url: response.path,
        isOssUrl: isOssUrl,
      });
      onSuccess?.(res);
    }