wupengfei
16 小时以前 6283110f6c1b7e7307c36f27e88e36c860bab96f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;
};
 
export async function vatLicense(response: FileItem, options: VatLicenseOptions = {}) {
  try {
    if (response?.url) {
      const { onSuccess } = options;
      let res = await accountServices.vatLicense({
        url: response.url,
      });
      onSuccess?.(
        _.mapValues(res, (x) => {
          if (x === '无') return '';
          return x;
        })
      );
    }
  } catch (error) {}
}
 
type UserCredentialVerifyOcrIDCardOptions = {
  access?: EnumOcrAccess;
  scene?: string;
  isOssUrl?: boolean;
  response?: FileItem;
  onSuccess?: (res: API.GetIdentityFrontOcrCommandResult) => any;
};
 
export async function userCredentialVerifyOcrIDCard(
  options: UserCredentialVerifyOcrIDCardOptions = {}
) {
  try {
    const { onSuccess, access, isOssUrl, response, scene } = options;
    if (response?.path) {
      let res = await ocrUtilsServices.getIdentityFrontOcr({
        access: access,
        url: response.path,
        isOssUrl: isOssUrl,
      });
      onSuccess?.(res);
    }
  } catch (error) {}
}