@uxda/appkit 4.1.12 → 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 +2 -1
- package/dist/index.js +24 -36
- package/package.json +1 -1
- package/src/notice/components/NoticePopup.vue +1 -0
- package/src/payment/components/RechargeView.vue +7 -9
- package/src/payment/components/TradeView.vue +8 -12
- package/src/shared/components/OcrBusinessLicense.vue +48 -45
- package/src/shared/components/OcrIcon.vue +44 -43
- package/src/styles/fonts.scss +1 -1
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', '
|
|
443
|
+
font-family: 'DIN alternate', 'Roboto', sans-serif-condensed-light;
|
|
444
444
|
}
|
|
445
445
|
.account-card .card {
|
|
446
446
|
background: #2f2f2f;
|
|
@@ -1406,6 +1406,7 @@ page {
|
|
|
1406
1406
|
align-items: center;
|
|
1407
1407
|
justify-content: center;
|
|
1408
1408
|
border-radius: 15px;
|
|
1409
|
+
z-index: 10;
|
|
1409
1410
|
}
|
|
1410
1411
|
.notice-banner {
|
|
1411
1412
|
background: #e6f2ff;
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import '@nutui/nutui-taro/dist/packages/checkbox/style/css';
|
|
|
4
4
|
import { defineComponent, reactive, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, toDisplayString, createTextVNode, ref, computed, onUnmounted, createCommentVNode, renderSlot, createVNode, unref, isRef, normalizeStyle, onMounted, createStaticVNode, watch, resolveComponent, withDirectives, vShow, useModel, mergeModels, vModelText, watchPostEffect, withModifiers } from 'vue';
|
|
5
5
|
import '@nutui/nutui-taro/dist/packages/grid/style/css';
|
|
6
6
|
import '@nutui/nutui-taro/dist/packages/griditem/style/css';
|
|
7
|
-
import '@nutui/nutui-taro/dist/packages/popup/style/css';
|
|
8
7
|
import Taro, { useDidShow, useRouter } from '@tarojs/taro';
|
|
8
|
+
import '@nutui/nutui-taro/dist/packages/popup/style/css';
|
|
9
9
|
import { isIdentityCard, isMobilePhone } from 'validator';
|
|
10
10
|
import { NsForm, NsInput, NsButton, NsIcon, useNutshell } from '@uxda/nutshell/taro';
|
|
11
11
|
import debounce from 'lodash/debounce';
|
|
@@ -951,7 +951,7 @@ var script$C = /* @__PURE__ */ defineComponent({
|
|
|
951
951
|
onClick: onIconClick
|
|
952
952
|
},
|
|
953
953
|
[
|
|
954
|
-
createVNode(unref(NsIcon), { name: "https://
|
|
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://
|
|
1064
|
+
createVNode(unref(NsIcon), { name: "https://cdn.ddjf.com/static/images/beidouxing/ocr-icon.png" })
|
|
1065
1065
|
],
|
|
1066
1066
|
2
|
|
1067
1067
|
/* CLASS */
|
|
@@ -1380,7 +1380,7 @@ var script$A = /* @__PURE__ */ defineComponent({
|
|
|
1380
1380
|
app: { type: String, required: true },
|
|
1381
1381
|
tenant: { type: String, required: true }
|
|
1382
1382
|
},
|
|
1383
|
-
emits: ["complete"],
|
|
1383
|
+
emits: ["complete", "agree"],
|
|
1384
1384
|
setup(__props, { emit: __emit }) {
|
|
1385
1385
|
const props = __props;
|
|
1386
1386
|
const emit = __emit;
|
|
@@ -1391,8 +1391,10 @@ var script$A = /* @__PURE__ */ defineComponent({
|
|
|
1391
1391
|
buttonLoading: false
|
|
1392
1392
|
});
|
|
1393
1393
|
const amounts = ref([]);
|
|
1394
|
-
const onAgreementLinkClick = (
|
|
1395
|
-
|
|
1394
|
+
const onAgreementLinkClick = (e) => {
|
|
1395
|
+
e.preventDefault();
|
|
1396
|
+
e.stopImmediatePropagation();
|
|
1397
|
+
emit("agree");
|
|
1396
1398
|
};
|
|
1397
1399
|
const onAmountSelect = (selected) => {
|
|
1398
1400
|
state.selected = selected;
|
|
@@ -1452,7 +1454,7 @@ var script$A = /* @__PURE__ */ defineComponent({
|
|
|
1452
1454
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.agreed = $event)
|
|
1453
1455
|
}, {
|
|
1454
1456
|
default: withCtx(() => [
|
|
1455
|
-
_cache[
|
|
1457
|
+
_cache[1] || (_cache[1] = createTextVNode("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F")),
|
|
1456
1458
|
createElementVNode("a", {
|
|
1457
1459
|
class: "link inline",
|
|
1458
1460
|
onClick: onAgreementLinkClick
|
|
@@ -1469,18 +1471,13 @@ var script$A = /* @__PURE__ */ defineComponent({
|
|
|
1469
1471
|
onClick: onPayClick,
|
|
1470
1472
|
class: "recharge-button"
|
|
1471
1473
|
}, {
|
|
1472
|
-
default: withCtx(() => _cache[
|
|
1474
|
+
default: withCtx(() => _cache[2] || (_cache[2] = [
|
|
1473
1475
|
createTextVNode("\u7ACB\u5373\u5145\u503C")
|
|
1474
1476
|
])),
|
|
1475
1477
|
_: 1
|
|
1476
1478
|
/* STABLE */
|
|
1477
1479
|
}, 8, ["loading"])
|
|
1478
|
-
])
|
|
1479
|
-
createVNode(unref(script$G), {
|
|
1480
|
-
modelValue: state.agreementOpen,
|
|
1481
|
-
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => state.agreementOpen = $event),
|
|
1482
|
-
title: "\u5145\u503C\u534F\u8BAE"
|
|
1483
|
-
}, null, 8, ["modelValue"])
|
|
1480
|
+
])
|
|
1484
1481
|
]);
|
|
1485
1482
|
};
|
|
1486
1483
|
}
|
|
@@ -1685,21 +1682,23 @@ var script$w = /* @__PURE__ */ defineComponent({
|
|
|
1685
1682
|
app: { type: String, required: true },
|
|
1686
1683
|
tenant: { type: String, required: true }
|
|
1687
1684
|
},
|
|
1688
|
-
emits: ["complete"],
|
|
1685
|
+
emits: ["complete", "agree"],
|
|
1689
1686
|
setup(__props, { emit: __emit }) {
|
|
1690
1687
|
const props = __props;
|
|
1691
1688
|
const emit = __emit;
|
|
1692
1689
|
const state = reactive({
|
|
1693
1690
|
agreed: false,
|
|
1694
1691
|
selected: 0,
|
|
1695
|
-
agreementOpen: false,
|
|
1692
|
+
// agreementOpen: false,
|
|
1696
1693
|
buttonLoading: false
|
|
1697
1694
|
});
|
|
1698
1695
|
const balance = ref(0);
|
|
1699
1696
|
const amounts = ref([]);
|
|
1700
1697
|
const selectBean = ref(false);
|
|
1701
|
-
const onAgreementLinkClick = (
|
|
1702
|
-
|
|
1698
|
+
const onAgreementLinkClick = (e) => {
|
|
1699
|
+
e.preventDefault();
|
|
1700
|
+
e.stopImmediatePropagation();
|
|
1701
|
+
emit("agree");
|
|
1703
1702
|
};
|
|
1704
1703
|
const onAmountSelect = (selected) => {
|
|
1705
1704
|
state.selected = selected;
|
|
@@ -1775,7 +1774,7 @@ var script$w = /* @__PURE__ */ defineComponent({
|
|
|
1775
1774
|
}, null, 8, ["items", "selected"]),
|
|
1776
1775
|
amounts.value[state.selected] ? (openBlock(), createElementBlock("div", _hoisted_3$e, [
|
|
1777
1776
|
createElementVNode("div", _hoisted_4$b, [
|
|
1778
|
-
_cache[
|
|
1777
|
+
_cache[4] || (_cache[4] = createElementVNode(
|
|
1779
1778
|
"div",
|
|
1780
1779
|
{ class: "title" },
|
|
1781
1780
|
"\u4F7F\u7528\u4E91\u8C46\u652F\u4ED8",
|
|
@@ -1822,7 +1821,7 @@ var script$w = /* @__PURE__ */ defineComponent({
|
|
|
1822
1821
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => state.agreed = $event)
|
|
1823
1822
|
}, {
|
|
1824
1823
|
default: withCtx(() => [
|
|
1825
|
-
_cache[
|
|
1824
|
+
_cache[5] || (_cache[5] = createTextVNode("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F")),
|
|
1826
1825
|
createElementVNode("a", {
|
|
1827
1826
|
class: "link inline",
|
|
1828
1827
|
onClick: onAgreementLinkClick
|
|
@@ -1834,9 +1833,9 @@ var script$w = /* @__PURE__ */ defineComponent({
|
|
|
1834
1833
|
])) : createCommentVNode("v-if", true),
|
|
1835
1834
|
createElementVNode("div", _hoisted_11$2, [
|
|
1836
1835
|
createElementVNode("div", _hoisted_12$2, [
|
|
1837
|
-
_cache[
|
|
1836
|
+
_cache[7] || (_cache[7] = createTextVNode(" \u5F85\u652F\u4ED8\uFF1A ")),
|
|
1838
1837
|
createElementVNode("span", _hoisted_13$2, [
|
|
1839
|
-
_cache[
|
|
1838
|
+
_cache[6] || (_cache[6] = createElementVNode(
|
|
1840
1839
|
"i",
|
|
1841
1840
|
null,
|
|
1842
1841
|
"\uFFE5",
|
|
@@ -1857,7 +1856,7 @@ var script$w = /* @__PURE__ */ defineComponent({
|
|
|
1857
1856
|
onClick: onPayClick,
|
|
1858
1857
|
class: "recharge-button"
|
|
1859
1858
|
}, {
|
|
1860
|
-
default: withCtx(() => _cache[
|
|
1859
|
+
default: withCtx(() => _cache[8] || (_cache[8] = [
|
|
1861
1860
|
createTextVNode("\u8D2D\u4E70")
|
|
1862
1861
|
])),
|
|
1863
1862
|
_: 1
|
|
@@ -1865,23 +1864,12 @@ var script$w = /* @__PURE__ */ defineComponent({
|
|
|
1865
1864
|
}, 8, ["loading"])
|
|
1866
1865
|
])
|
|
1867
1866
|
]),
|
|
1868
|
-
createVNode(unref(script$G), {
|
|
1869
|
-
modelValue: state.agreementOpen,
|
|
1870
|
-
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => state.agreementOpen = $event),
|
|
1871
|
-
title: "\u5145\u503C\u534F\u8BAE"
|
|
1872
|
-
}, {
|
|
1873
|
-
default: withCtx(() => [
|
|
1874
|
-
createVNode(script$z)
|
|
1875
|
-
]),
|
|
1876
|
-
_: 1
|
|
1877
|
-
/* STABLE */
|
|
1878
|
-
}, 8, ["modelValue"]),
|
|
1879
1867
|
createVNode(_component_nut_dialog, {
|
|
1880
1868
|
title: "\u786E\u8BA4\u8D2D\u4E70",
|
|
1881
1869
|
"custom-class": "trade-dialog",
|
|
1882
1870
|
visible: showDialog.value,
|
|
1883
|
-
"onUpdate:visible": _cache[
|
|
1884
|
-
onCancel: _cache[
|
|
1871
|
+
"onUpdate:visible": _cache[2] || (_cache[2] = ($event) => showDialog.value = $event),
|
|
1872
|
+
onCancel: _cache[3] || (_cache[3] = ($event) => showDialog.value = !showDialog.value),
|
|
1885
1873
|
onOk: beanPay
|
|
1886
1874
|
}, {
|
|
1887
1875
|
default: withCtx(() => [
|
package/package.json
CHANGED
|
@@ -15,18 +15,12 @@
|
|
|
15
15
|
@click="onPayClick"
|
|
16
16
|
class="recharge-button">立即充值</nut-button>
|
|
17
17
|
</view>
|
|
18
|
-
<app-drawer
|
|
19
|
-
v-model="state.agreementOpen"
|
|
20
|
-
title="充值协议">
|
|
21
|
-
</app-drawer>
|
|
22
18
|
</view>
|
|
23
19
|
</template>
|
|
24
20
|
|
|
25
21
|
<script lang="ts" setup>
|
|
26
22
|
import { onMounted, reactive, ref } from 'vue'
|
|
27
23
|
import AmountPicker from './AmountPicker.vue'
|
|
28
|
-
import UserAgreement from './UserAgreement.vue'
|
|
29
|
-
import { AppDrawer } from '../../shared'
|
|
30
24
|
import { useHttp, endpoints } from '../api'
|
|
31
25
|
import { requestPayment } from '../services'
|
|
32
26
|
import Taro from '@tarojs/taro'
|
|
@@ -53,7 +47,8 @@ export interface RechargeViewProps {
|
|
|
53
47
|
const props = defineProps<RechargeViewProps>()
|
|
54
48
|
|
|
55
49
|
const emit = defineEmits<{
|
|
56
|
-
(event: 'complete', value: boolean): void
|
|
50
|
+
(event: 'complete', value: boolean): void,
|
|
51
|
+
(event: 'agree'): void,
|
|
57
52
|
}>()
|
|
58
53
|
|
|
59
54
|
const state = reactive({
|
|
@@ -65,8 +60,11 @@ const state = reactive({
|
|
|
65
60
|
|
|
66
61
|
const amounts = ref<any[]>([])
|
|
67
62
|
|
|
68
|
-
const onAgreementLinkClick = (
|
|
69
|
-
|
|
63
|
+
const onAgreementLinkClick = (e) => {
|
|
64
|
+
e.preventDefault()
|
|
65
|
+
e.stopImmediatePropagation()
|
|
66
|
+
emit('agree')
|
|
67
|
+
// state.agreementOpen = true
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
const onAmountSelect = (selected: number) => {
|
|
@@ -33,13 +33,7 @@
|
|
|
33
33
|
@click="onPayClick"
|
|
34
34
|
class="recharge-button">购买</nut-button>
|
|
35
35
|
</div>
|
|
36
|
-
|
|
37
36
|
</view>
|
|
38
|
-
<app-drawer
|
|
39
|
-
v-model="state.agreementOpen"
|
|
40
|
-
title="充值协议">
|
|
41
|
-
<user-agreement />
|
|
42
|
-
</app-drawer>
|
|
43
37
|
<nut-dialog title="确认购买" custom-class="trade-dialog" v-model:visible="showDialog" @cancel="showDialog = !showDialog" @ok="beanPay" >
|
|
44
38
|
<template v-if="amounts[state.selected]">
|
|
45
39
|
<div class="item">云豆扣减:{{ amounts[state.selected].paymentAmount }}</div>
|
|
@@ -53,8 +47,6 @@
|
|
|
53
47
|
<script lang="ts" setup>
|
|
54
48
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
55
49
|
import RightsPicker, { Amount } from './RightsPicker.vue'
|
|
56
|
-
import UserAgreement from './UserAgreement.vue'
|
|
57
|
-
import { AppDrawer } from '../../shared'
|
|
58
50
|
import { endpoints, useHttp } from '../api'
|
|
59
51
|
import { requestPaymentByBean } from '../services'
|
|
60
52
|
import Taro from '@tarojs/taro'
|
|
@@ -81,13 +73,14 @@ export interface RechargeViewProps {
|
|
|
81
73
|
const props = defineProps<RechargeViewProps>()
|
|
82
74
|
|
|
83
75
|
const emit = defineEmits<{
|
|
84
|
-
(event: 'complete', value: {result: boolean, type: string}): void
|
|
76
|
+
(event: 'complete', value: {result: boolean, type: string}): void,
|
|
77
|
+
(event: 'agree'): void,
|
|
85
78
|
}>()
|
|
86
79
|
|
|
87
80
|
const state = reactive({
|
|
88
81
|
agreed: false,
|
|
89
82
|
selected: 0,
|
|
90
|
-
agreementOpen: false,
|
|
83
|
+
// agreementOpen: false,
|
|
91
84
|
buttonLoading: false,
|
|
92
85
|
})
|
|
93
86
|
|
|
@@ -96,8 +89,11 @@ const balance = ref<number>(0)
|
|
|
96
89
|
const amounts = ref<Amount[]>([])
|
|
97
90
|
const selectBean = ref<boolean>(false)
|
|
98
91
|
|
|
99
|
-
const onAgreementLinkClick = (
|
|
100
|
-
|
|
92
|
+
const onAgreementLinkClick = (e) => {
|
|
93
|
+
e.preventDefault()
|
|
94
|
+
e.stopImmediatePropagation()
|
|
95
|
+
emit('agree')
|
|
96
|
+
// state.agreementOpen = true
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
const onAmountSelect = (selected: number) => {
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
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://
|
|
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 =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
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>
|
package/src/styles/fonts.scss
CHANGED