1
This commit is contained in:
@ -41,7 +41,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { listByIds, delOss, recognizeidCard, recognizeBankCard } from '@/api/system/oss';
|
||||
import { listByIds, delOss, recognizeidCard, recognizeBankCard, recognizeFace } from '@/api/system/oss';
|
||||
import { OssVO } from '@/api/system/oss/types';
|
||||
import { propTypes } from '@/utils/propTypes';
|
||||
import { globalHeaders } from '@/utils/request';
|
||||
@ -64,6 +64,11 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 是否支持压缩,默认否
|
||||
compressSupport: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isGo: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@ -73,11 +78,6 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 是否支持压缩,默认否
|
||||
compressSupport: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 压缩目标大小,单位KB。默认300KB以上文件才压缩,并压缩至300KB以内
|
||||
compressTargetSize: propTypes.number.def(300),
|
||||
idCardType: {
|
||||
@ -96,7 +96,6 @@ const dialogVisible = ref(false);
|
||||
const baseUrl = props.isGo ? import.meta.env.VITE_APP_BASE_API_GO : import.meta.env.VITE_APP_BASE_API;
|
||||
const uploadImgUrl = ref(baseUrl + (props.action ? props.action : '/resource/oss/upload')); // 上传的图片服务器地址
|
||||
console.log('🚀 ~ uploadImgUrl:', uploadImgUrl.value, baseUrl, props.action);
|
||||
|
||||
const headers = ref(globalHeaders());
|
||||
|
||||
const fileList = ref<any[]>([]);
|
||||
@ -188,7 +187,6 @@ const handleExceed = () => {
|
||||
const handleUploadSuccess = async (res: any, file: UploadFile) => {
|
||||
if (res.code === 200) {
|
||||
uploadList.value.push({ name: res.data.fileName, url: res.data.url, ossId: res.data.ossId });
|
||||
uploadedSuccessfully();
|
||||
if (props.idCardType) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file.raw); // 假设后端接收的字段名为file
|
||||
@ -197,8 +195,11 @@ const handleUploadSuccess = async (res: any, file: UploadFile) => {
|
||||
if (res.code === 200) {
|
||||
proxy?.$modal.msgSuccess('身份证识别成功');
|
||||
emit('success', res.data);
|
||||
uploadedSuccessfully();
|
||||
} else {
|
||||
proxy?.$modal.msgError('身份证识别失败');
|
||||
proxy?.$modal.closeLoading();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (props.idCardType === 'bank') {
|
||||
@ -206,10 +207,27 @@ const handleUploadSuccess = async (res: any, file: UploadFile) => {
|
||||
if (res.code === 200) {
|
||||
proxy?.$modal.msgSuccess('银行卡识别成功');
|
||||
emit('success', res.data);
|
||||
uploadedSuccessfully();
|
||||
} else {
|
||||
proxy?.$modal.msgError('银行卡识别失败');
|
||||
proxy?.$modal.closeLoading();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (props.idCardType === 'face') {
|
||||
const res = await recognizeFace(formData);
|
||||
if (res.code === 200) {
|
||||
proxy?.$modal.msgSuccess('人脸识别成功');
|
||||
emit('success', res.data);
|
||||
uploadedSuccessfully();
|
||||
} else {
|
||||
console.log('人脸识别失败', res);
|
||||
proxy?.$modal.closeLoading();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uploadedSuccessfully();
|
||||
}
|
||||
} else {
|
||||
number.value--;
|
||||
|
||||
Reference in New Issue
Block a user