@uxda/appkit 4.0.14 → 4.0.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "4.0.14",
3
+ "version": "4.0.18",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="date-range" @click="openDateRangePicker">
3
- <div class="text number">{{ dateRangeDisplay }}</div>
3
+ <div class="text">{{ dateRangeDisplay }}</div>
4
4
  <img
5
5
  style="margin-top: -2px"
6
6
  class="time-icon"
@@ -51,7 +51,7 @@ const openDateRangePicker = () => {
51
51
  const dateRangeDisplay = computed(() => {
52
52
  let startTime = (model.value.from || '').replace(/-/g, '.').substring(2)
53
53
  let endTime = (model.value.to || '').replace(/-/g, '.').substring(2)
54
- return startTime + ' - ' + endTime
54
+ return startTime + '-' + endTime
55
55
  })
56
56
 
57
57
  </script>
@@ -3,78 +3,84 @@
3
3
  <h2>{{ title || '手机号验证' }}</h2>
4
4
  <p class="caption">{{ message || '短信将发送至账号绑定手机号' }}</p>
5
5
  <p class="number">{{ phone }}</p>
6
- <ns-form v-model="formData">
6
+ <ns-form v-model="formData" class="form">
7
7
  <ns-input
8
+ class="form-input"
8
9
  name="code"
9
10
  v-model="formData.code"
10
11
  placeholder="请输入验证码"
12
+ maxlength="6"
11
13
  variant="solid"
12
14
  :rules="['required', {
13
- name: 'function',
14
- message: '输入错误, 请重新输入',
15
- method: (value: string) => value.length === 6,
16
- }]"
15
+ name: 'function',
16
+ message: '输入错误, 请重新输入',
17
+ method: (value: string) => value.length === 6,
18
+ }]"
17
19
  >
18
- <template #append>
19
- <ns-button
20
- v-if="!sent"
21
- size="xs"
22
- variant="plain"
23
- color="primary"
24
- @click="send"
25
- label="获取验证码"
26
- />
27
- <div class="caption" v-if="sent">{{ countdown }} 秒收重新发送</div>
28
- </template>
29
20
  </ns-input>
21
+ <div class="form-btn">
22
+ <ns-button
23
+ v-if="!sent"
24
+ size="xs"
25
+ variant="plain"
26
+ color="primary"
27
+ @click="send"
28
+ label="获取验证码"
29
+ />
30
+ <div class="caption" v-if="sent">{{ countdown }}s后重新发送</div>
31
+ </div>
30
32
  </ns-form>
31
33
  <div class="row buttons">
32
- <ns-button round @click="emits('cancel')">取消</ns-button>
33
- <ns-button round gradient="#FFEBC1,#FFD7A7,#FFB875/90" @click="onOk">确认</ns-button>
34
+ <ns-button class="cancel-btn" round @click="emits('cancel')"
35
+ >取消</ns-button
36
+ >
37
+ <ns-button round gradient="#FFEBC1,#FFD7A7,#FFB875/90" @click="onOk"
38
+ >确认</ns-button
39
+ >
34
40
  </div>
35
41
  </div>
36
42
  </template>
37
43
 
38
44
  <script lang="ts" setup>
39
- import { NsForm, NsInput, NsButton } from '@uxda/nutshell/taro'
40
- import { reactive, ref } from 'vue'
45
+ import { NsForm, NsInput, NsButton } from '@uxda/nutshell/taro';
46
+ import { reactive, ref } from 'vue';
41
47
 
42
48
  export interface AppVerifyProps {
43
- phone: string
44
- title?: string
45
- message?: string
46
- onSend?: Function
49
+ phone: string;
50
+ title?: string;
51
+ message?: string;
52
+ onSend?: Function;
47
53
  }
48
54
 
49
- const emits = defineEmits(['complete', 'cancel'])
55
+ const emits = defineEmits(['complete', 'cancel']);
50
56
 
51
57
  const sent = ref(false),
52
- countdown = ref(60)
58
+ countdown = ref(60);
53
59
 
54
60
  let formData = reactive({
55
61
  code: '',
56
- })
62
+ });
57
63
 
58
64
  const send = () => {
59
- sent.value = true
65
+ sent.value = true;
60
66
 
61
- props.onSend && props.onSend()
67
+ props.onSend && props.onSend();
62
68
 
63
- countdown.value = 60
69
+ countdown.value = 60;
64
70
  let timer = setInterval(() => {
65
- countdown.value--
71
+ countdown.value--;
66
72
  if (countdown.value <= 0) {
67
- clearInterval(timer)
68
- sent.value = false
73
+ clearInterval(timer);
74
+ sent.value = false;
69
75
  }
70
- }, 1000)
71
- }
76
+ }, 1000);
77
+ };
72
78
 
73
79
  const onOk = () => {
74
- emits('complete', { code: formData.code })
75
- }
80
+ emits('complete', { code: formData.code });
81
+ };
76
82
 
77
- const props = defineProps<AppVerifyProps>()
83
+ const props = defineProps<AppVerifyProps>();
78
84
  </script>
79
85
 
80
86
  <style lang="scss">
@@ -86,13 +92,38 @@ const props = defineProps<AppVerifyProps>()
86
92
  margin: 10px;
87
93
  }
88
94
  .caption {
89
- font-size: 14px;
90
- color: #666;
95
+ font-size: 10px !important;
96
+ color: #ccc;
97
+ line-height: 21px;
98
+ }
99
+ .number {
100
+ line-height: 21px;
101
+ }
102
+ .form .nut-cell-group__wrap {
103
+ display: flex;
104
+ align-items: center;
105
+ margin: 20px 0 !important;
106
+ .form-input {
107
+ height: 36px;
108
+ line-height: 36px;
109
+ border: none;
110
+ background: #f5f5f5;
111
+ border-radius: 5px;
112
+ flex: 1;
113
+ padding-left: 12px;
114
+ }
115
+ .form-btn {
116
+ margin-left: 12px;
117
+ width: 90px;
118
+ }
91
119
  }
92
120
  .buttons {
93
121
  .ns-button {
94
122
  width: 104px;
95
123
  }
124
+ .cancel-btn {
125
+ border: 1px solid #969696 !important;
126
+ }
96
127
  }
97
128
  }
98
129
  </style>
@@ -0,0 +1,115 @@
1
+ <template>
2
+ <div class="ocr-icon" @click="onIconClick">
3
+ <ns-icon name="https://simple.shensi.tech/icons/ocr.svg" />
4
+ </div>
5
+ </template>
6
+
7
+ <script lang="ts" setup>
8
+ import Taro from '@tarojs/taro';
9
+ import { NsIcon } from '@uxda/nutshell/taro';
10
+ import { useAppKitOptions } from '../../Appkit';
11
+
12
+ const appKitOptions = useAppKitOptions();
13
+
14
+ const emits = defineEmits(['complete']);
15
+
16
+ export type OcrResult = {
17
+ companyName: string;
18
+ idCardNo: string;
19
+ legalPersonName: string;
20
+ };
21
+
22
+ async function taroImgCompress(src: string, quality = 80) {
23
+ return new Promise((resolve, reject) => {
24
+ Taro.compressImage({
25
+ src: src,
26
+ quality: quality,
27
+ success: (res) => {
28
+ resolve(res);
29
+ },
30
+ fail: (res) => {
31
+ reject(res);
32
+ },
33
+ });
34
+ });
35
+ }
36
+
37
+ function getCompressQuality(size: number) {
38
+ let quality = 100;
39
+ const curSize = size / (1024 * 1024);
40
+ if (curSize > 6) {
41
+ quality = quality - ((curSize - 6) / curSize) * 100;
42
+ }
43
+ return quality;
44
+ }
45
+
46
+ function allTrim(str: string) {
47
+ return str.replace(/\s+/g, '');
48
+ }
49
+
50
+ async function onIconClick() {
51
+ console.log('===onIconClick');
52
+ let result: OcrResult | null = null;
53
+ try {
54
+ const csRes = await Taro.chooseImage({
55
+ count: 1,
56
+ });
57
+ let { path, size } = csRes.tempFiles[0];
58
+ const compressImg: any =
59
+ (await taroImgCompress(path, getCompressQuality(size))) || {};
60
+ const filePath = compressImg.tempFilePath || path;
61
+ Taro.showLoading({ title: '营业执照识别中..' });
62
+ const session = appKitOptions.token();
63
+ const baseUrl = appKitOptions.baseUrl();
64
+ const upRes: any = await Taro.uploadFile({
65
+ url: baseUrl + '/promoact/common/parseBusinessLicense',
66
+ filePath,
67
+ name: 'file',
68
+ formData: {
69
+ objectNo: `min${Date.now()}`,
70
+ },
71
+ header: {
72
+ sessionKey: session || '',
73
+ token: session || '',
74
+ },
75
+ });
76
+ Taro.hideLoading();
77
+ const res = JSON.parse(upRes.data);
78
+ if (res.code === '200') {
79
+ const faceInfo = res.result || {};
80
+ result = {
81
+ companyName: allTrim(faceInfo.companyName || ''),
82
+ idCardNo: allTrim(faceInfo.idCardNo || ''),
83
+ legalPersonName: allTrim(faceInfo.legalPersonName || ''),
84
+ fileId: faceInfo.fileId,
85
+ originalUrl: faceInfo.originalUrl,
86
+ downloadUrl: faceInfo.downloadUrl,
87
+ };
88
+ console.log('===识别', result);
89
+ if (!result.companyName && !result.idCardNo) {
90
+ Taro.showToast({ title: '识别失败,请重试', icon: 'none' });
91
+ }
92
+ } else {
93
+ Taro.showToast({
94
+ title: res.msg,
95
+ icon: 'error',
96
+ });
97
+ }
98
+ } catch (err) {
99
+ Taro.hideLoading();
100
+ console.log(err);
101
+ }
102
+ emits('complete', result);
103
+ }
104
+ </script>
105
+
106
+ <style lang="scss">
107
+ .ocr-icon {
108
+ width: 24px;
109
+ height: 24px;
110
+ .ns-icon {
111
+ width: 24px;
112
+ height: 24px;
113
+ }
114
+ }
115
+ </style>
@@ -3,5 +3,6 @@ import PageHeader from './PageHeader.vue'
3
3
  import AppVerify from './AppVerify.vue'
4
4
  import DeviceVersion from './DeviceVersion.vue'
5
5
  import OcrIcon from './OcrIcon.vue'
6
+ import OcrBusinessLicense from './OcrBusinessLicense.vue'
6
7
 
7
- export { AppDrawer, PageHeader, DeviceVersion, AppVerify, OcrIcon }
8
+ export { AppDrawer, PageHeader, DeviceVersion, AppVerify, OcrIcon, OcrBusinessLicense }
@@ -7,7 +7,7 @@ export type UploadConfig = {
7
7
  headers?: Record<string, string>
8
8
  }
9
9
 
10
- const mappings = {
10
+ const mappings: {[x: string]: keyof Media} = {
11
11
  downloadUrl: 'thrumb',
12
12
  fileId: 'id',
13
13
  fileName: 'name',