refactor(train_management): 优化人脸认证页面代码结构

-调整代码格式,提高可读性
- 移除冗余的空行和注释
- 统一代码风格
-优化部分变量和方法的命名
hyx_2025-01-13_xgf2.0
wangyan 2025-03-10 18:19:33 +08:00
parent 25d047341a
commit 4934e79c45
1 changed files with 187 additions and 175 deletions

View File

@ -5,7 +5,8 @@
</view> </view>
<view class="livefater"> <view class="livefater">
<view style="width: 700upx; height: 700upx; border-radius: 700upx; overflow: hidden"> <view style="width: 700upx; height: 700upx; border-radius: 700upx; overflow: hidden">
<live-pusher id="livePusher" ref="livePusher" class="livePusher" url="" mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2" aspect="1:1" /> <live-pusher id="livePusher" ref="livePusher" class="livePusher" url="" mode="SD" :muted="true"
:enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2" aspect="1:1" />
</view> </view>
<cover-image src="/static/images/gaiz.png" class="gaiimg"></cover-image> <cover-image src="/static/images/gaiz.png" class="gaiimg"></cover-image>
</view> </view>
@ -17,10 +18,14 @@
</template> </template>
<script> <script>
// import {setMeetingFace, setScanCodeToVerifyFace, setUserFace, setVerifyFace} from "@/api"; // import {setMeetingFace, setScanCodeToVerifyFace, setUserFace, setVerifyFace} from "@/api";
import { submitEditUserFace, compareUserFaceCertify, compareUserExamFaceCertify } from '@/api'; import {
submitEditUserFace,
compareUserFaceCertify,
compareUserExamFaceCertify
} from '@/api';
export default { export default {
data() { data() {
return { return {
startPreviewTimer: null, // 开始预览计时器实例 startPreviewTimer: null, // 开始预览计时器实例
@ -57,11 +62,17 @@ export default {
this.routeQueryparams = query ?? {} this.routeQueryparams = query ?? {}
}, },
onBackPress(event) { onBackPress(event) {
if (event.from === 'backbutton') { // if (event.from === 'backbutton') {
if ((this.type === 'scan_face' && this.isFirst === '1') || this.type === 'learning_certification' || this.type === 'facial_input') { // if ((this.type === 'scan_face' && this.isFirst === '1') || this.type === 'learning_certification' || this.type === 'facial_input') {
uni.$u.toast('请完成人脸验证') // uni.$u.toast('请完成人脸验证')
return true // return true
} // }
// }
if (this.type === 'facial_input') {
uni.$u.route({
type: 'redirect',
url: '/pages/index/index',
})
} }
return false return false
}, },
@ -89,8 +100,7 @@ export default {
}) })
}, },
getMinImage(imgPath) { getMinImage(imgPath) {
plus.zip.compressImage( plus.zip.compressImage({
{
src: imgPath, src: imgPath,
dst: imgPath, dst: imgPath,
overwrite: true, overwrite: true,
@ -102,7 +112,8 @@ export default {
reader.onloadend = async (res) => { reader.onloadend = async (res) => {
const speech = res.target.result const speech = res.target.result
// 获取 base 64 图片编码的前缀 // 获取 base 64 图片编码的前缀
const USERAVATARPREFIX = speech.substring(0, speech.indexOf('base64,') + 7) const USERAVATARPREFIX = speech.substring(0, speech.indexOf(
'base64,') + 7)
// 获取 base 64 图片的二进制到文本 // 获取 base 64 图片的二进制到文本
const USERAVATARURL = speech.substring(speech.indexOf('base64,') + 7) const USERAVATARURL = speech.substring(speech.indexOf('base64,') + 7)
try { try {
@ -110,7 +121,8 @@ export default {
...this.routeQueryparams ...this.routeQueryparams
} }
delete otherParams.type delete otherParams.type
if (this.type === 'facial_input' || this.type === 'update_facial_input') { if (this.type === 'facial_input' || this.type ===
'update_facial_input') {
await submitEditUserFace({ await submitEditUserFace({
...otherParams, ...otherParams,
USERAVATARPREFIX, USERAVATARPREFIX,
@ -165,41 +177,41 @@ export default {
) )
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.container { .container {
background-color: #fff; background-color: #fff;
} }
.livePusher { .livePusher {
width: 700upx; width: 700upx;
height: 700upx; height: 700upx;
} }
.livefater { .livefater {
display: flex; display: flex;
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
margin-bottom: 100upx; margin-bottom: 100upx;
height: 700upx; height: 700upx;
} }
.fat { .fat {
margin: 100upx; margin: 100upx;
} }
.fatt { .fatt {
text-align: center; text-align: center;
font-size: 36upx; font-size: 36upx;
font-weight: 800; font-weight: 800;
} }
.gaiimg { .gaiimg {
width: 700upx; width: 700upx;
height: 700upx; height: 700upx;
margin-top: -700upx; margin-top: -700upx;
} }
</style> </style>