人脸认证组件添加扫描类型

xgf-training-dev
mengfanliang 2025-02-18 16:54:09 +08:00
parent 909d4ab415
commit 4a9faf7cac
3 changed files with 186 additions and 150 deletions

View File

@ -77,4 +77,9 @@ export const getHistoricalApprovalRecords = (params) => post("/app/Task/getHis",
* 获取班级管理分页列表 * 获取班级管理分页列表
*/ */
export const getClassList = (params) => post("/app/stagestudentrelation/pageTaskByUser", params); export const getClassList = (params) => post("/app/stagestudentrelation/pageTaskByUser", params);
/**
* 获取是否上传人脸信息
*/
export const getIsUploadFace = (params) => post("/app/user/getUserFace", params);
// ********************* end *********************** // ********************* end ***********************

View File

@ -60,12 +60,13 @@ export default {
// scan_face 扫码 // scan_face 扫码
// learning_certification 学习认证 // learning_certification 学习认证
// meeting_attendance 会议签到 // meeting_attendance 会议签到
const typeKey = ["scan_face", "learning_certification"]; const typeKey = ["facial_input", "scan_face", "learning_certification"];
if (!typeKey.includes(query.type)) { if (!typeKey.includes(query.type)) {
uni.$u.toast("type参数错误"); uni.$u.toast("type参数错误");
return; return;
} }
this.isFirst = query.isFirst || ""; this.isFirst = query.isFirst || "";
if (query.type === "facial_input") this.btnTextStr = "人脸认证";
if (query.type === "scan_face") this.btnTextStr = "签到"; if (query.type === "scan_face") this.btnTextStr = "签到";
if (query.type === "learning_certification") this.btnTextStr = "开始考试"; if (query.type === "learning_certification") this.btnTextStr = "开始考试";
this.type = query.type; this.type = query.type;
@ -74,7 +75,7 @@ export default {
}, },
onBackPress(event) { onBackPress(event) {
if (event.from === "backbutton") { if (event.from === "backbutton") {
if ( if (this.type === "facial_input" ||
(this.type === "scan_face" && this.isFirst === "1") || (this.type === "scan_face" && this.isFirst === "1") ||
this.type === "learning_certification" this.type === "learning_certification"
) { ) {
@ -125,7 +126,10 @@ export default {
speech.indexOf("base64,") + 7, speech.indexOf("base64,") + 7,
); );
try { try {
if (this.type === "scan_face") { if (this.type === "facial_input") {
uni.$u.toast("人脸认证成功");
uni.navigateBack({ delta: 1 });
} else if (this.type === "scan_face") {
// await setScanCodeToVerifyFace({ // await setScanCodeToVerifyFace({
// USERAVATARPREFIX, // USERAVATARPREFIX,
// USERAVATARURL, // USERAVATARURL,

View File

@ -1,6 +1,6 @@
<template> <template>
<view class="content"> <view class="content">
<u-list @scrolltolower="scrolltolower"> <u-list @scrolltolower="scrolltolower" v-if="trainList.length > 0">
<u-list-item v-for="(item, index) in trainList" :key="index"> <u-list-item v-for="(item, index) in trainList" :key="index">
<view class="container_item"> <view class="container_item">
<view class="container_item_name"> <view class="container_item_name">
@ -28,14 +28,10 @@
</view> </view>
<view class="content_text"> <view class="content_text">
<view class="content_bottom"> <view class="content_bottom">
<view> <view> <text class="content_label">任务状态: </text>{{ handleCalcTaskStatus(item.taskStatus) }} </view>
<text class="content_label">任务状态: </text>{{ handleCalcTaskStatus(item.taskStatus) }}
</view>
<view class="action-row"> <view class="action-row">
<u-button size="mini" type="primary" text="签到信息" <u-button size="mini" type="primary" text="签到信息" @click="signInInformation(item.classId)" />
@click="signInInformation(item.classId)" /> <u-button size="mini" type="primary" text="考试记录" @click="ExamRecord(item.classId)" />
<u-button size="mini" type="primary" text="考试记录"
@click="ExamRecord(item.classId)" />
</view> </view>
</view> </view>
</view> </view>
@ -43,163 +39,194 @@
</view> </view>
</u-list-item> </u-list-item>
</u-list> </u-list>
<empty v-else></empty>
</view> </view>
</template> </template>
<script> <script>
import { getClassList } from '../../api'; import { getClassList, getIsUploadFace } from '../../api'
export default { export default {
data() { data() {
return { return {
pageSize: 10, pageSize: 10,
currentPage: 1, currentPage: 1,
totalPage: 0, totalPage: 0,
trainList: [], trainList: [],
taskStatusMap: { taskStatusMap: {
0: '未开始', 0: '未开始',
1: '进行中' 1: '进行中'
}
}
},
/* 监听页面显示,页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面 */
onShow() {
this.resetList()
},
methods: {
async getData() {
let resData = await getClassList({
showCount: this.pageSize,
currentPage: this.currentPage,
});
console.log(resData)
this.trainList = [...this.trainList, ...resData.page.list];
this.totalPage = resData.page.totalPage;
},
resetList() {
this.pageSize = 10
this.currentPage = 1
this.trainList = []
this.getData()
},
scrolltolower() {
this.currentPage++
if (this.totalPage >= this.currentPage) this.getData()
},
/**
* 右上角自定义扫码图标触发事件
*/
onNavigationBarButtonTap(e) {
//
uni.scanCode({
// scanType: ['qrCode'], //
onlyFromCamera: false, //
hideAlbum: false, // ,,
success: function(res) {
if (res.result === '0') {
//
uni.$u.route({
url: '/pages/train_management/realname_info_auth',
params: {
type: 'scan_face',
}
})
} else if (res.result === '1') {
//
uni.$u.route({
url: '/pages/train_management/face_authentication',
params: {
type: 'learning_certification'
}
})
}
},
fail: function(error) {
console.log("error :>> ", error)
},
complete: function(result) {
console.log("扫码完成,正在跳转功能页!")
}
});
},
handleCalcTaskStatus(type) {
return this.taskStatusMap[type]
},
/**
* 签到信息
*/
signInInformation(classId) {
uni.$u.route({
url: '/pages/train_management/sign_information',
params: {
classId
}
})
},
/**
* 考试记录
*/
ExamRecord(classId) {
uni.$u.route({
url: '/pages/train_management/exam_record',
params: {
classId
}
})
} }
} }
},
async onLoad(query) {
console.log('页面加载完成 :>> ', query)
// await this.getUserFaceCompleted()
},
/* 监听页面显示,页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面 */
onShow() {
this.resetList()
},
methods: {
async getData() {
let resData = await getClassList({
showCount: this.pageSize,
currentPage: this.currentPage
})
this.trainList = [...this.trainList, ...resData.page.list]
this.totalPage = resData.page.totalPage
},
resetList() {
this.pageSize = 10
this.currentPage = 1
this.trainList = []
this.getData()
},
scrolltolower() {
this.currentPage++
if (this.totalPage >= this.currentPage) this.getData()
},
/**
* 获取是否已经完成上传人脸信息
*/
// async getUserFaceCompleted() {
// const userFaceData = await getIsUploadFace()
// console.log('userFaceData :>> ', userFaceData)
// if (!userFaceData?.data) {
// uni.showModal({
// title: '',
// content: '!',
// success: function (res) {
// if (res.confirm) {
// uni.$u.route({
// url: '/pages/train_management/face_authentication',
// params: {
// type: 'facial_input'
// }
// })
// } else if (res.cancel) {
// uni.navigateBack({ delta: 1 });
// }
// }
// })
// }
// },
/**
* 右上角自定义扫码图标触发事件
*/
onNavigationBarButtonTap(e) {
//
uni.scanCode({
// scanType: ['qrCode'], //
onlyFromCamera: false, //
hideAlbum: false, // ,,
success: function (res) {
if (res.result === '0') {
//
uni.$u.route({
url: '/pages/train_management/realname_info_auth',
params: {
type: 'scan_face'
}
})
} else if (res.result === '1') {
//
uni.$u.route({
url: '/pages/train_management/face_authentication',
params: {
type: 'learning_certification'
}
})
}
},
fail: function (error) {
console.log('error :>> ', error)
},
complete: function (result) {
console.log('扫码完成,正在跳转功能页!')
}
})
},
handleCalcTaskStatus(type) {
return this.taskStatusMap[type]
},
/**
* 签到信息
*/
signInInformation(classId) {
uni.$u.route({
url: '/pages/train_management/sign_information',
params: {
classId
}
})
},
/**
* 考试记录
*/
ExamRecord(classId) {
uni.$u.route({
url: '/pages/train_management/exam_record',
params: {
classId
}
})
}
} }
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.container_item { .container_item {
padding-left: 16rpx; padding-left: 16rpx;
.container_item_name { .container_item_name {
font-size: 32rpx; font-size: 32rpx;
font-weight: 500; font-weight: 500;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.container_item_content { .container_item_content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8rpx; gap: 8rpx;
.content_text { .content_text {
color: #acafb3; color: #acafb3;
font-size: 30rpx; font-size: 30rpx;
.content_label { .content_label {
display: inline-block; display: inline-block;
width: 220rpx; width: 220rpx;
} }
.content_value { .content_value {
display: inline-block; display: inline-block;
transform: translateY(8rpx); transform: translateY(8rpx);
padding: 0; padding: 0;
width: 452rpx; width: 452rpx;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.content_bottom { .content_bottom {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.action-row { .action-row {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 16rpx; gap: 16rpx;
}
} }
} }
} }
}
</style> </style>