This commit is contained in:
BianLzhaoMin 2025-09-04 13:18:24 +08:00
parent bd19e3fc5f
commit 8020780cdc
7 changed files with 338 additions and 29 deletions

7
package-lock.json generated
View File

@ -26,6 +26,7 @@
"clipboard": "^2.0.11",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.13",
"image-tools": "^1.4.0",
"lodash-es": "^4.17.21",
"pinia": "^2.3.0",
"pinia-plugin-persistedstate": "^4.2.0",
@ -7790,6 +7791,12 @@
"node": ">= 4"
}
},
"node_modules/image-tools": {
"version": "1.4.0",
"resolved": "https://repo.huaweicloud.com/repository/npm/image-tools/-/image-tools-1.4.0.tgz",
"integrity": "sha512-TKtvJ6iUwM0mfaD4keMnk1ENHFC470QEjBfA3IlvKdEOufzvWbjbaoNcoyYq6HlViF8+d5tOS1ooE6j7CHf1lQ==",
"license": "ISC"
},
"node_modules/immutable": {
"version": "4.3.7",
"resolved": "https://repo.huaweicloud.com/repository/npm/immutable/-/immutable-4.3.7.tgz",

View File

@ -52,6 +52,7 @@
"clipboard": "^2.0.11",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.13",
"image-tools": "^1.4.0",
"lodash-es": "^4.17.21",
"pinia": "^2.3.0",
"pinia-plugin-persistedstate": "^4.2.0",

View File

@ -21,7 +21,7 @@
size="small"
type="primary"
text="识别身份证(人像)"
@tap="onHandleRecognizeIdCard"
@tap="onHandleRecognizeIdCard(1)"
/>
</template>
</up-cell>
@ -93,7 +93,7 @@
size="small"
type="primary"
text="识别身份证(国徽)"
@tap="onHandleRecognizeIdCard"
@tap="onHandleRecognizeIdCard(2)"
/>
</template>
</up-cell>
@ -153,6 +153,10 @@
<script setup name="personIdCardForm">
import { ref, watch } from 'vue'
import { pathToBase64 } from 'image-tools'
import { useMemberStore } from '@/stores'
const memberStore = useMemberStore()
const idCardFormRef = ref(null) // ref
const idCardModel = ref({
age: '',
@ -322,11 +326,67 @@ const onCancelBirthday = () => {
showPikerBirthday.value = false
}
//
const onHandleRecognizeIdCard = () => {
const imgToBase64Fun = async (path) => {
return new Promise((resolve, reject) => {
pathToBase64(path)
.then((base64) => {
resolve(base64)
})
.catch((error) => {
console.error(error)
reject(error)
})
})
}
//
const onHandleRecognizeIdCard = (type) => {
// 1 2
// console.log('')
uni.$u.toast('功能正在开发中,敬请期待...')
return
uni.chooseImage({
count: 1, // 1
sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], //
success: async (res) => {
const base64 = await imgToBase64Fun(res.tempFilePaths[0])
const param = {
imageBase64: base64.split(',')[1],
}
//
uni.request({
url: '/bmw/appRecognition/bankCardRecognition',
method: 'POST',
data: param,
header: {
// 'Content-Type': 'application/Json',
Authorization: memberStore?.token, // token
},
success: (res) => {
const { data: result } = res
if (result.code === 200) {
uni.$u.toast('识别身份证成功')
} else {
uni.$u.toast('识别身份证失败,请重新识别')
}
},
fail: (err) => {
console.log(err, '----识别身份证失败')
},
})
},
fail: (err) => {
// uni.$u.toast({
// title: '',
// icon: 'none',
// })
},
})
}
//

View File

@ -84,13 +84,27 @@
<text> 1 未完成工资卡上传为黄灯人员</text>
<text> 2 生成工资册之前必须上传工资卡</text>
</view>
<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="wageCardForm">
import { ref, watch } from 'vue'
import { pathToBase64 } from 'image-tools'
import { useMemberStore } from '@/stores'
const memberStore = useMemberStore()
const wageCardFormRef = ref(null) // ref
const showLoading = ref(false) //
const wageCardInfoForm = ref({
bankName: '', //
@ -250,9 +264,63 @@ const updateWageCardInfo = () => {
Object.assign(wageCardInfoForm.value, props.wageCardInfo)
}
const imgToBase64Fun = async (path) => {
return new Promise((resolve, reject) => {
pathToBase64(path)
.then((base64) => {
resolve(base64)
})
.catch((error) => {
console.error(error)
reject(error)
})
})
}
//
const onHandleRecognizeBankCard = () => {
uni.$u.toast('功能正在开发中,敬请期待...')
uni.chooseImage({
count: 1, // 1
sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], //
success: async (res) => {
showLoading.value = true
const base64 = await imgToBase64Fun(res.tempFilePaths[0])
const param = {
imageBase64: base64.split(',')[1],
}
//
uni.request({
url: '/bmw/appRecognition/bankCardRecognition',
method: 'POST',
data: param,
header: {
Authorization: memberStore?.token, // token
},
success: (res) => {
showLoading.value = false
const { data: result } = res
if (result.code === 200) {
const { bankCard, bankName } = result.data
wageCardInfoForm.value.bankCardCode = bankCard
wageCardInfoForm.value.bankName = bankName
} else {
uni.$u.toast('识别银行卡失败,请重新识别')
}
},
fail: (err) => {
showLoading.value = false
uni.$u.toast('识别银行卡失败,请重新识别')
},
})
},
fail: (err) => {
// uni.$u.toast({
// title: '',
// icon: 'none',
// })
},
})
}
//

View File

@ -1,6 +1,6 @@
<template>
<!-- 考勤打卡页面 -->
<view class="attendance-container">
<view class="attendance-container app-container">
<view class="project-name"> {{ activeProjectName }}</view>
<view class="attendance-content">
@ -32,18 +32,31 @@
</view>
</view>
</view>
<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="Attendance">
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { useCommonStore } from '@/stores'
import { useCommonStore, useMemberStore } from '@/stores'
import { pathToBase64 } from 'image-tools'
import dayjs from 'dayjs'
const commonStore = useCommonStore()
const memberStore = useMemberStore()
const currentTime = ref('') //
const timeInterval = ref(null) //
const activeProjectName = ref('') //
const showLoading = ref(false) //
//
const onAttendanceRecord = () => {
@ -66,7 +79,82 @@ const onAttendanceHandle = () => {
// icon: 'none',
// })
uni.$u.toast('功能正在开发中,敬请期待...')
uni.chooseImage({
count: 1, // 1
sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], //
success: (res) => {
showLoading.value = true
const files = [
{
file: res.tempFiles[0],
name: 'file',
},
]
//
uni.uploadFile({
url: '/api/bmw/appRecognition/getFaceRecognition',
files: files,
name: 'file',
success: (res) => {
showLoading.value = false
const data = JSON.parse(res.data)
if (data.code === 200) {
uni.$u.toast('人脸识别成功')
//
uni.uploadFile({
url: '/api/bmw/appRecognition/appPlayCard',
files: files,
name: 'file',
formData: {
params: JSON.stringify({
idNumber: data.data.idNumber,
}),
},
success: (res) => {
const result = JSON.parse(res.data)
if (result.code === 200) {
uni.$u.toast('打卡成功')
} else {
uni.$u.toast('打卡失败:' + result.msg)
}
},
fail: (err) => {
uni.$u.toast('打卡失败:' + err.msg)
},
})
} else {
uni.$u.toast('人脸识别失败,请重新识别')
}
},
fail: (err) => {
showLoading.value = false
uni.$u.toast('人脸识别失败:' + err.msg)
},
})
},
fail: (err) => {
// uni.$u.toast({
// title: '',
// icon: 'none',
// })
},
})
}
const imgToBase64Fun = async (data) => {
return new Promise((resolve, reject) => {
pathToBase64(data)
.then((base64) => {
resolve(base64)
})
.catch((error) => {
console.error(error)
reject(error)
})
})
}
// onMounted

View File

@ -11,6 +11,16 @@
<text>人员资质查询</text>
</view>
</view>
<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>
@ -19,30 +29,50 @@ import { ref } from 'vue'
import FaceIcon from '@/static/image/face.png'
import CheckIcon from '@/static/image/person-qua.png'
const showLoading = ref(false) //
const onFaceRecognition = () => {
// uni.$u.toast('...')
// console.log('onFaceRecognition')
//
// uni.scanCode({
// scanType: ['barCode', 'qrCode'],
// success: (result) => {
// console.log(result)
// },
// })
uni.chooseImage({
count: 1, // 1
sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], //
success: (res) => {
console.log(res, '----选取的文件')
showLoading.value = true
const files = [
{
file: res.tempFiles[0],
name: 'file',
},
]
uni.uploadFile({
url: '/api/bmw/appRecognition/getFaceRecognition',
files: files,
name: 'file',
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 {
uni.$u.toast('人脸识别失败,请重新识别')
}
},
fail: (err) => {
showLoading.value = false
uni.$u.toast('人脸识别失败:' + err.msg)
},
})
},
fail: (err) => {
uni.$u.toast({
title: '选择图片失败',
icon: 'none',
})
// uni.$u.toast({
// title: '',
// icon: 'none',
// })
},
})
}

View File

@ -13,6 +13,16 @@
<view>
<view>{{ item.title }}</view>
</view>
<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>
@ -20,6 +30,9 @@
import AddIcon from '@/static/image/person/add.png'
import EditIcon from '@/static/image/person/edit.png'
import FaceIcon from '@/static/image/person/face.png'
import { ref } from 'vue'
const showLoading = ref(false) //
const handleList = [
{
@ -52,12 +65,54 @@ const handleList = [
//
const handleTapPersonEntry = (item) => {
if (item.name === 'face') {
uni.$u.toast('功能正在开发中,敬请期待...')
return
uni.chooseImage({
count: 1, // 1
sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], //
success: (res) => {
showLoading.value = true
const files = [
{
file: res.tempFiles[0],
name: 'file',
},
]
uni.uploadFile({
url: '/api/bmw/appRecognition/getFaceRecognition',
files: files,
name: 'file',
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 {
uni.$u.toast('人脸识别失败,请重新识别')
}
},
fail: (err) => {
showLoading.value = false
uni.$u.toast('人脸识别失败:' + err.msg)
},
})
},
fail: (err) => {
// uni.$u.toast({
// title: '',
// icon: 'none',
// })
},
})
} else {
uni.navigateTo({
url: item.url,
})
}
uni.navigateTo({
url: item.url,
})
}
</script>