@uxda/appkit 4.1.16 → 4.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/appkit.css CHANGED
@@ -440,7 +440,7 @@ page {
440
440
  --text-color-dark-mode: #eee;
441
441
  }
442
442
  .number {
443
- font-family: 'DIN alternate', 'Barlow Condensed', 'Roboto Condensed', sans-serif-condensed-light;
443
+ font-family: 'DIN alternate', 'Roboto', sans-serif-condensed-light;
444
444
  }
445
445
  .account-card .card {
446
446
  background: #2f2f2f;
package/dist/index.js CHANGED
@@ -951,7 +951,7 @@ var script$C = /* @__PURE__ */ defineComponent({
951
951
  onClick: onIconClick
952
952
  },
953
953
  [
954
- createVNode(unref(NsIcon), { name: "https://simple.shensi.tech/icons/ocr.svg" })
954
+ createVNode(unref(NsIcon), { name: "https://cdn.ddjf.com/static/images/beidouxing/ocr-icon.png" })
955
955
  ],
956
956
  2
957
957
  /* CLASS */
@@ -1061,7 +1061,7 @@ var script$B = /* @__PURE__ */ defineComponent({
1061
1061
  onClick: onIconClick
1062
1062
  },
1063
1063
  [
1064
- createVNode(unref(NsIcon), { name: "https://simple.shensi.tech/icons/ocr.svg" })
1064
+ createVNode(unref(NsIcon), { name: "https://cdn.ddjf.com/static/images/beidouxing/ocr-icon.png" })
1065
1065
  ],
1066
1066
  2
1067
1067
  /* CLASS */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "4.1.16",
3
+ "version": "4.1.20",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -1,30 +1,33 @@
1
1
  <template>
2
- <div :class="['ocr-business-license', disabled ? 'disabled' : '']" class="ocr-icon" @click="onIconClick">
3
- <ns-icon name="https://simple.shensi.tech/icons/ocr.svg" />
2
+ <div
3
+ :class="['ocr-business-license', disabled ? 'disabled' : '']"
4
+ class="ocr-icon"
5
+ @click="onIconClick"
6
+ >
7
+ <ns-icon name="https://cdn.ddjf.com/static/images/beidouxing/ocr-icon.png" />
4
8
  </div>
5
9
  </template>
6
10
 
7
11
  <script lang="ts" setup>
8
- import Taro from '@tarojs/taro'
9
- import { NsIcon } from '@uxda/nutshell/taro'
10
- import { useAppKitOptions } from '../../Appkit'
12
+ import Taro from '@tarojs/taro';
13
+ import { NsIcon } from '@uxda/nutshell/taro';
14
+ import { useAppKitOptions } from '../../Appkit';
11
15
 
12
- const appKitOptions = useAppKitOptions()
13
-
14
- const emits = defineEmits(['complete'])
16
+ const appKitOptions = useAppKitOptions();
15
17
 
18
+ const emits = defineEmits(['complete']);
16
19
 
17
20
  type OcrBusinessLicenseProps = {
18
- disabled: boolean
19
- }
21
+ disabled: boolean;
22
+ };
20
23
 
21
- const props = defineProps<OcrBusinessLicenseProps>()
24
+ const props = defineProps<OcrBusinessLicenseProps>();
22
25
 
23
26
  export type OcrResult = {
24
- companyName: string
25
- idCardNo: string
26
- legalPersonName: string
27
- }
27
+ companyName: string;
28
+ idCardNo: string;
29
+ legalPersonName: string;
30
+ };
28
31
 
29
32
  async function taroImgCompress(src: string, quality = 80) {
30
33
  return new Promise((resolve, reject) => {
@@ -32,45 +35,45 @@ async function taroImgCompress(src: string, quality = 80) {
32
35
  src: src,
33
36
  quality: quality,
34
37
  success: (res) => {
35
- resolve(res)
38
+ resolve(res);
36
39
  },
37
40
  fail: (res) => {
38
- reject(res)
41
+ reject(res);
39
42
  },
40
- })
41
- })
43
+ });
44
+ });
42
45
  }
43
46
 
44
47
  function getCompressQuality(size: number) {
45
- let quality = 100
46
- const curSize = size / (1024 * 1024)
48
+ let quality = 100;
49
+ const curSize = size / (1024 * 1024);
47
50
  if (curSize > 6) {
48
- quality = quality - ((curSize - 6) / curSize) * 100
51
+ quality = quality - ((curSize - 6) / curSize) * 100;
49
52
  }
50
- return quality
53
+ return quality;
51
54
  }
52
55
 
53
56
  function allTrim(str: string) {
54
- return str.replace(/\s+/g, '')
57
+ return str.replace(/\s+/g, '');
55
58
  }
56
59
 
57
60
  async function onIconClick() {
58
61
  if (props.disabled) {
59
- return
62
+ return;
60
63
  }
61
- console.log('===onIconClick')
62
- let result: OcrResult | null = null
64
+ console.log('===onIconClick');
65
+ let result: OcrResult | null = null;
63
66
  try {
64
67
  const csRes = await Taro.chooseImage({
65
68
  count: 1,
66
- })
67
- let { path, size } = csRes.tempFiles[0]
69
+ });
70
+ let { path, size } = csRes.tempFiles[0];
68
71
  const compressImg: any =
69
- (await taroImgCompress(path, getCompressQuality(size))) || {}
70
- const filePath = compressImg.tempFilePath || path
71
- Taro.showLoading({ title: '营业执照识别中..' })
72
- const session = appKitOptions.token()
73
- const baseUrl = appKitOptions.baseUrl()
72
+ (await taroImgCompress(path, getCompressQuality(size))) || {};
73
+ const filePath = compressImg.tempFilePath || path;
74
+ Taro.showLoading({ title: '营业执照识别中..' });
75
+ const session = appKitOptions.token();
76
+ const baseUrl = appKitOptions.baseUrl();
74
77
  const upRes: any = await Taro.uploadFile({
75
78
  url: baseUrl + '/promoact/common/parseBusinessLicense',
76
79
  filePath,
@@ -82,11 +85,11 @@ async function onIconClick() {
82
85
  sessionKey: session || '',
83
86
  token: session || '',
84
87
  },
85
- })
86
- Taro.hideLoading()
87
- const res = JSON.parse(upRes.data)
88
+ });
89
+ Taro.hideLoading();
90
+ const res = JSON.parse(upRes.data);
88
91
  if (res.code === '200') {
89
- const faceInfo = res.result || {}
92
+ const faceInfo = res.result || {};
90
93
  result = {
91
94
  companyName: allTrim(faceInfo.companyName || ''),
92
95
  idCardNo: allTrim(faceInfo.idCardNo || ''),
@@ -94,22 +97,22 @@ async function onIconClick() {
94
97
  fileId: faceInfo.fileId,
95
98
  originalUrl: faceInfo.originalUrl,
96
99
  downloadUrl: faceInfo.downloadUrl,
97
- }
98
- console.log('===识别', result)
100
+ };
101
+ console.log('===识别', result);
99
102
  if (!result.companyName && !result.idCardNo) {
100
- Taro.showToast({ title: '识别失败,请重试', icon: 'none' })
103
+ Taro.showToast({ title: '识别失败,请重试', icon: 'none' });
101
104
  }
102
105
  } else {
103
106
  Taro.showToast({
104
107
  title: res.msg,
105
108
  icon: 'error',
106
- })
109
+ });
107
110
  }
108
111
  } catch (err) {
109
- Taro.hideLoading()
110
- console.log(err)
112
+ Taro.hideLoading();
113
+ console.log(err);
111
114
  }
112
- emits('complete', result)
115
+ emits('complete', result);
113
116
  }
114
117
  </script>
115
118
 
@@ -1,29 +1,29 @@
1
1
  <template>
2
2
  <div :class="['ocr-icon', disabled ? 'disabled' : '']" @click="onIconClick">
3
- <ns-icon name="https://simple.shensi.tech/icons/ocr.svg" />
3
+ <ns-icon name="https://cdn.ddjf.com/static/images/beidouxing/ocr-icon.png" />
4
4
  </div>
5
5
  </template>
6
6
 
7
7
  <script lang="ts" setup>
8
- import Taro from '@tarojs/taro'
9
- import { NsIcon } from '@uxda/nutshell/taro'
10
- import { useAppKitOptions } from '../../Appkit'
8
+ import Taro from '@tarojs/taro';
9
+ import { NsIcon } from '@uxda/nutshell/taro';
10
+ import { useAppKitOptions } from '../../Appkit';
11
11
 
12
- const appKitOptions = useAppKitOptions()
12
+ const appKitOptions = useAppKitOptions();
13
13
 
14
- const emits = defineEmits(['complete'])
14
+ const emits = defineEmits(['complete']);
15
15
 
16
16
  type OcrIconProps = {
17
- disabled: boolean
18
- }
17
+ disabled: boolean;
18
+ };
19
19
 
20
- const props = defineProps<OcrIconProps>()
20
+ const props = defineProps<OcrIconProps>();
21
21
 
22
22
  export type OcrResult = {
23
- name: string
24
- number: string
25
- address: string
26
- }
23
+ name: string;
24
+ number: string;
25
+ address: string;
26
+ };
27
27
 
28
28
  async function taroImgCompress(src: string, quality = 80) {
29
29
  return new Promise((resolve, reject) => {
@@ -31,43 +31,44 @@ async function taroImgCompress(src: string, quality = 80) {
31
31
  src: src,
32
32
  quality: quality,
33
33
  success: (res) => {
34
- resolve(res)
34
+ resolve(res);
35
35
  },
36
36
  fail: (res) => {
37
- reject(res)
37
+ reject(res);
38
38
  },
39
- })
40
- })
39
+ });
40
+ });
41
41
  }
42
42
 
43
43
  function getCompressQuality(size: number) {
44
- let quality = 100
45
- const curSize = size / (1024 * 1024)
44
+ let quality = 100;
45
+ const curSize = size / (1024 * 1024);
46
46
  if (curSize > 6) {
47
- quality = quality - ((curSize - 6) / curSize) * 100
47
+ quality = quality - ((curSize - 6) / curSize) * 100;
48
48
  }
49
- return quality
49
+ return quality;
50
50
  }
51
51
 
52
52
  function allTrim(str: string) {
53
- return str.replace(/\s+/g, '')
53
+ return str.replace(/\s+/g, '');
54
54
  }
55
55
 
56
56
  async function onIconClick() {
57
57
  if (props.disabled) {
58
- return
58
+ return;
59
59
  }
60
- let result: OcrResult | null = null
60
+ let result: OcrResult | null = null;
61
61
  try {
62
62
  const csRes = await Taro.chooseImage({
63
63
  count: 1,
64
- })
65
- let { path, size } = csRes.tempFiles[0]
66
- const compressImg: any = (await taroImgCompress(path, getCompressQuality(size))) || {}
67
- const filePath = compressImg.tempFilePath || path
68
- Taro.showLoading({ title: '身份证识别中..' })
69
- const session = appKitOptions.token()
70
- const baseUrl = appKitOptions.baseUrl()
64
+ });
65
+ let { path, size } = csRes.tempFiles[0];
66
+ const compressImg: any =
67
+ (await taroImgCompress(path, getCompressQuality(size))) || {};
68
+ const filePath = compressImg.tempFilePath || path;
69
+ Taro.showLoading({ title: '身份证识别中..' });
70
+ const session = appKitOptions.token();
71
+ const baseUrl = appKitOptions.baseUrl();
71
72
  const upRes: any = await Taro.uploadFile({
72
73
  url: baseUrl + '/hkapprove/ocr/idcard',
73
74
  filePath,
@@ -80,12 +81,12 @@ async function onIconClick() {
80
81
  sessionKey: session || '',
81
82
  token: session || '',
82
83
  },
83
- })
84
- Taro.hideLoading()
85
- const res = JSON.parse(upRes.data)
84
+ });
85
+ Taro.hideLoading();
86
+ const res = JSON.parse(upRes.data);
86
87
  if (res.code === '200') {
87
88
  const faceInfo = res.result.faceInfo || {},
88
- file = res.result.fileUploadVO
89
+ file = res.result.fileUploadVO;
89
90
  result = {
90
91
  name: allTrim(faceInfo.name || ''),
91
92
  number: allTrim(faceInfo.num || ''),
@@ -96,22 +97,22 @@ async function onIconClick() {
96
97
  // object: file.objectNo,
97
98
  // thumb: file.thumbnailUrl
98
99
  // }
99
- }
100
- console.log('===识别', result)
100
+ };
101
+ console.log('===识别', result);
101
102
  if (!result.name && !result.number) {
102
- Taro.showToast({ title: '识别失败,请重试', icon: 'none' })
103
+ Taro.showToast({ title: '识别失败,请重试', icon: 'none' });
103
104
  }
104
105
  } else {
105
106
  Taro.showToast({
106
107
  title: res.msg,
107
108
  icon: 'error',
108
- })
109
+ });
109
110
  }
110
111
  } catch (err) {
111
- Taro.hideLoading()
112
- console.log(err)
112
+ Taro.hideLoading();
113
+ console.log(err);
113
114
  }
114
- emits('complete', result)
115
+ emits('complete', result);
115
116
  }
116
117
  </script>
117
118
 
@@ -129,4 +130,4 @@ async function onIconClick() {
129
130
  }
130
131
  }
131
132
  }
132
- </style>
133
+ </style>
@@ -1,3 +1,3 @@
1
1
  .number {
2
- font-family: 'DIN alternate', 'Barlow Condensed', 'Roboto Condensed', sans-serif-condensed-light;
2
+ font-family: 'DIN alternate', 'Roboto', sans-serif-condensed-light;
3
3
  }