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

147 lines
4.3 KiB
Vue
Raw Normal View History

<template>
<!-- 人员入场 -->
<view
:key="item.name"
class="person-handle"
v-for="item in handleList"
@tap="handleTapPersonEntry(item)"
:style="{
background: `linear-gradient(to bottom, ${item.bgc_color_1}, ${item.bgc_color_2})`,
}"
>
<image :src="item.icon" mode="widthFix" class="icon-img" />
<view>
<view>{{ item.title }}</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="personEntry">
import AddIcon from '@/static/image/person/add.png'
import EditIcon from '@/static/image/person/edit.png'
import FaceIcon from '@/static/image/person/face.png'
2025-09-04 13:18:24 +08:00
import { ref } from 'vue'
const showLoading = ref(false) // 是否显示加载中
const handleList = [
{
name: 'add',
icon: AddIcon,
title: '新增人员信息',
bgc_color_1: '#9ee07f',
bgc_color_2: '#57cd7e',
2025-08-29 14:23:29 +08:00
url: `/pages/person-entry/child-pages/addAndEditPerson?type=${1}`,
},
{
name: 'edit',
icon: EditIcon,
title: '修改人员信息',
bgc_color_1: '#14e3fe',
bgc_color_2: '#3ebefe',
url: '/pages/person-entry/child-pages/editPerson',
},
{
name: 'face',
icon: FaceIcon,
title: '人脸识别查找',
bgc_color_1: '#d8c1ea',
bgc_color_2: '#91cbf0',
url: '/pages/person-entry/child-pages/faceRecognition',
},
]
// 点击跳转
const handleTapPersonEntry = (item) => {
2025-08-29 14:23:29 +08:00
if (item.name === 'face') {
2025-09-04 13:18:24 +08:00
uni.chooseImage({
count: 1, // 最多选择1张图片
sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], // 选择图片的来源
2025-09-05 14:08:12 +08:00
isUploadFile: true,
2025-09-04 13:18:24 +08:00
success: (res) => {
showLoading.value = true
const files = [
{
2025-09-05 14:08:12 +08:00
file: res.tempFiles[0].path,
2025-09-04 13:18:24 +08:00
name: 'file',
2025-09-05 14:08:12 +08:00
uri: res.tempFiles[0].path,
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) => {
2025-09-05 14:08:12 +08:00
console.log(res, 'res人脸识别结果')
2025-09-04 13:18:24 +08:00
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:08:12 +08:00
console.log(err, 'err人脸识别失败')
2025-09-05 14:35:03 +08:00
uni.$u.toast('人脸识别失败')
2025-09-04 13:18:24 +08:00
},
})
},
fail: (err) => {
// uni.$u.toast({
// title: '选择图片失败',
// icon: 'none',
// })
},
})
} else {
uni.navigateTo({
url: item.url,
})
2025-08-29 14:23:29 +08:00
}
}
</script>
<style scoped lang="scss">
.person-handle {
display: flex;
align-items: center;
justify-content: center;
padding: 70rpx 0;
border-radius: 20rpx;
margin: 20rpx;
.icon-img {
width: 64rpx;
height: 64rpx;
}
view {
margin-left: 28rpx !important;
color: #fff;
font-size: 48rpx;
font-weight: bold;
margin-left: 20rpx;
font-family: PingFang SC;
}
}
</style>