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", "clipboard": "^2.0.11",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"image-tools": "^1.4.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"pinia": "^2.3.0", "pinia": "^2.3.0",
"pinia-plugin-persistedstate": "^4.2.0", "pinia-plugin-persistedstate": "^4.2.0",
@ -7790,6 +7791,12 @@
"node": ">= 4" "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": { "node_modules/immutable": {
"version": "4.3.7", "version": "4.3.7",
"resolved": "https://repo.huaweicloud.com/repository/npm/immutable/-/immutable-4.3.7.tgz", "resolved": "https://repo.huaweicloud.com/repository/npm/immutable/-/immutable-4.3.7.tgz",

View File

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

View File

@ -21,7 +21,7 @@
size="small" size="small"
type="primary" type="primary"
text="识别身份证(人像)" text="识别身份证(人像)"
@tap="onHandleRecognizeIdCard" @tap="onHandleRecognizeIdCard(1)"
/> />
</template> </template>
</up-cell> </up-cell>
@ -93,7 +93,7 @@
size="small" size="small"
type="primary" type="primary"
text="识别身份证(国徽)" text="识别身份证(国徽)"
@tap="onHandleRecognizeIdCard" @tap="onHandleRecognizeIdCard(2)"
/> />
</template> </template>
</up-cell> </up-cell>
@ -153,6 +153,10 @@
<script setup name="personIdCardForm"> <script setup name="personIdCardForm">
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { pathToBase64 } from 'image-tools'
import { useMemberStore } from '@/stores'
const memberStore = useMemberStore()
const idCardFormRef = ref(null) // ref const idCardFormRef = ref(null) // ref
const idCardModel = ref({ const idCardModel = ref({
age: '', age: '',
@ -322,11 +326,67 @@ const onCancelBirthday = () => {
showPikerBirthday.value = false showPikerBirthday.value = false
} }
// const imgToBase64Fun = async (path) => {
const onHandleRecognizeIdCard = () => { 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('') // console.log('')
uni.$u.toast('功能正在开发中,敬请期待...') 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> 1 未完成工资卡上传为黄灯人员</text>
<text> 2 生成工资册之前必须上传工资卡</text> <text> 2 生成工资册之前必须上传工资卡</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> </view>
</template> </template>
<script setup name="wageCardForm"> <script setup name="wageCardForm">
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { pathToBase64 } from 'image-tools'
import { useMemberStore } from '@/stores'
const memberStore = useMemberStore()
const wageCardFormRef = ref(null) // ref const wageCardFormRef = ref(null) // ref
const showLoading = ref(false) //
const wageCardInfoForm = ref({ const wageCardInfoForm = ref({
bankName: '', // bankName: '', //
@ -250,9 +264,63 @@ const updateWageCardInfo = () => {
Object.assign(wageCardInfoForm.value, props.wageCardInfo) 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 = () => { 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> <template>
<!-- 考勤打卡页面 --> <!-- 考勤打卡页面 -->
<view class="attendance-container"> <view class="attendance-container app-container">
<view class="project-name"> {{ activeProjectName }}</view> <view class="project-name"> {{ activeProjectName }}</view>
<view class="attendance-content"> <view class="attendance-content">
@ -32,18 +32,31 @@
</view> </view>
</view> </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> </view>
</template> </template>
<script setup name="Attendance"> <script setup name="Attendance">
import { ref, onMounted, onBeforeUnmount } from 'vue' import { ref, onMounted, onBeforeUnmount } from 'vue'
import { useCommonStore } from '@/stores' import { useCommonStore, useMemberStore } from '@/stores'
import { pathToBase64 } from 'image-tools'
import dayjs from 'dayjs' import dayjs from 'dayjs'
const commonStore = useCommonStore() const commonStore = useCommonStore()
const memberStore = useMemberStore()
const currentTime = ref('') // const currentTime = ref('') //
const timeInterval = ref(null) // const timeInterval = ref(null) //
const activeProjectName = ref('') // const activeProjectName = ref('') //
const showLoading = ref(false) //
// //
const onAttendanceRecord = () => { const onAttendanceRecord = () => {
@ -66,7 +79,82 @@ const onAttendanceHandle = () => {
// icon: 'none', // 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 // onMounted

View File

@ -11,6 +11,16 @@
<text>人员资质查询</text> <text>人员资质查询</text>
</view> </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> </view>
</template> </template>
@ -19,31 +29,51 @@ import { ref } from 'vue'
import FaceIcon from '@/static/image/face.png' import FaceIcon from '@/static/image/face.png'
import CheckIcon from '@/static/image/person-qua.png' import CheckIcon from '@/static/image/person-qua.png'
const showLoading = ref(false) //
const onFaceRecognition = () => { const onFaceRecognition = () => {
// uni.$u.toast('...')
// console.log('onFaceRecognition')
//
// uni.scanCode({
// scanType: ['barCode', 'qrCode'],
// success: (result) => {
// console.log(result)
// },
// })
uni.chooseImage({ uni.chooseImage({
count: 1, // 1 count: 1, // 1
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['camera', 'album'], // sourceType: ['camera', 'album'], //
success: (res) => { 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) => { fail: (err) => {
uni.$u.toast({ showLoading.value = false
title: '选择图片失败', uni.$u.toast('人脸识别失败:' + err.msg)
icon: 'none', },
}) })
}, },
fail: (err) => {
// uni.$u.toast({
// title: '',
// icon: 'none',
// })
},
}) })
} }

View File

@ -13,6 +13,16 @@
<view> <view>
<view>{{ item.title }}</view> <view>{{ item.title }}</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> </view>
</template> </template>
@ -20,6 +30,9 @@
import AddIcon from '@/static/image/person/add.png' import AddIcon from '@/static/image/person/add.png'
import EditIcon from '@/static/image/person/edit.png' import EditIcon from '@/static/image/person/edit.png'
import FaceIcon from '@/static/image/person/face.png' import FaceIcon from '@/static/image/person/face.png'
import { ref } from 'vue'
const showLoading = ref(false) //
const handleList = [ const handleList = [
{ {
@ -52,12 +65,54 @@ const handleList = [
// //
const handleTapPersonEntry = (item) => { const handleTapPersonEntry = (item) => {
if (item.name === 'face') { if (item.name === 'face') {
uni.$u.toast('功能正在开发中,敬请期待...') uni.chooseImage({
return 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({ uni.navigateTo({
url: item.url, url: item.url,
}) })
}
} }
</script> </script>