sh_real_name_system_app/src/pages/person-check/index.vue

113 lines
3.3 KiB
Vue
Raw Normal View History

<template>
<!-- 人员资质查询 -->
<view class="person-check">
<view class="person-check-item">
<view @tap="onFaceRecognition">
2025-09-03 09:25:57 +08:00
<up-image width="60px" height="60px" :src="FaceIcon" />
<text>人脸识别</text>
</view>
<view @tap="onPersonCheck">
2025-09-03 09:25:57 +08:00
<up-image width="60px" height="60px" :src="CheckIcon" />
<text>人员资质查询</text>
</view>
</view>
2025-09-04 13:18:24 +08:00
<up-loading-icon
:vertical="true"
duration="2000"
color="#3c9cff"
:show="showLoading"
textColor="#3c9cff"
text="正在识别中,请稍后..."
style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%)"
/>
</view>
</template>
<script setup name="PersonCheck">
import { ref } from 'vue'
2025-09-03 09:25:57 +08:00
import FaceIcon from '@/static/image/face.png'
import CheckIcon from '@/static/image/person-qua.png'
2025-09-04 13:18:24 +08:00
const showLoading = ref(false) // 是否显示加载中
2025-09-03 09:25:57 +08:00
2025-09-04 13:18:24 +08:00
const onFaceRecognition = () => {
2025-09-03 09:25:57 +08:00
uni.chooseImage({
count: 1, // 最多选择1张图片
sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], // 选择图片的来源
success: (res) => {
2025-09-04 13:18:24 +08:00
showLoading.value = true
const files = [
{
2025-09-05 14:08:12 +08:00
file: res.tempFilePaths[0],
2025-09-04 13:18:24 +08:00
name: 'file',
2025-09-05 14:08:12 +08:00
uri: res.tempFilePaths[0],
2025-09-04 13:18:24 +08:00
},
]
uni.uploadFile({
2025-09-05 14:08:12 +08:00
url: '/bmw/appRecognition/getFaceRecognition',
2025-09-04 13:18:24 +08:00
files: files,
name: 'file',
2025-09-05 14:08:12 +08:00
isUploadFile: true,
2025-09-04 13:18:24 +08:00
success: (res) => {
showLoading.value = false
const data = JSON.parse(res.data)
if (data.code === 200) {
uni.$u.toast('人脸识别成功')
setTimeout(() => {
uni.navigateTo({
url: `/pages/person-details/index?id=${data.data.userId}`,
})
}, 500)
} else {
2025-09-05 14:35:03 +08:00
uni.$u.toast('人脸识别失败,请重新识别' + data.msg)
2025-09-04 13:18:24 +08:00
}
},
fail: (err) => {
showLoading.value = false
2025-09-05 14:35:03 +08:00
uni.$u.toast('人脸识别失败')
2025-09-04 13:18:24 +08:00
},
})
2025-09-03 09:25:57 +08:00
},
fail: (err) => {
2025-09-04 13:18:24 +08:00
// uni.$u.toast({
// title: '选择图片失败',
// icon: 'none',
// })
2025-09-03 09:25:57 +08:00
},
})
}
// 打开人员资质查询页面
const onPersonCheck = () => {
console.log('onPersonCheck')
uni.navigateTo({
url: '/pages/person-check/aptitude-query/index',
})
}
</script>
<style scoped lang="scss">
.person-check-item {
padding: 30rpx 0;
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
view {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
& text {
margin-top: 10rpx;
font-size: 14px;
color: #3c9cff;
}
}
}
</style>