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

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 getIsUploadFace = (params) => post("/app/user/getUserFace", params);
// ********************* end ***********************

View File

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

View File

@ -1,6 +1,6 @@
<template>
<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">
<view class="container_item">
<view class="container_item_name">
@ -28,14 +28,10 @@
</view>
<view class="content_text">
<view class="content_bottom">
<view>
<text class="content_label">任务状态: </text>{{ handleCalcTaskStatus(item.taskStatus) }}
</view>
<view> <text class="content_label">任务状态: </text>{{ handleCalcTaskStatus(item.taskStatus) }} </view>
<view class="action-row">
<u-button size="mini" type="primary" text="签到信息"
@click="signInInformation(item.classId)" />
<u-button size="mini" type="primary" text="考试记录"
@click="ExamRecord(item.classId)" />
<u-button size="mini" type="primary" text="签到信息" @click="signInInformation(item.classId)" />
<u-button size="mini" type="primary" text="考试记录" @click="ExamRecord(item.classId)" />
</view>
</view>
</view>
@ -43,163 +39,194 @@
</view>
</u-list-item>
</u-list>
<empty v-else></empty>
</view>
</template>
<script>
import { getClassList } from '../../api';
import { getClassList, getIsUploadFace } from '../../api'
export default {
data() {
return {
pageSize: 10,
currentPage: 1,
totalPage: 0,
trainList: [],
taskStatusMap: {
0: '未开始',
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
}
})
export default {
data() {
return {
pageSize: 10,
currentPage: 1,
totalPage: 0,
trainList: [],
taskStatusMap: {
0: '未开始',
1: '进行中'
}
}
},
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>
<style scoped lang="scss">
.container_item {
padding-left: 16rpx;
.container_item {
padding-left: 16rpx;
.container_item_name {
font-size: 32rpx;
font-weight: 500;
margin-bottom: 20rpx;
}
.container_item_name {
font-size: 32rpx;
font-weight: 500;
margin-bottom: 20rpx;
}
.container_item_content {
display: flex;
flex-direction: column;
gap: 8rpx;
.container_item_content {
display: flex;
flex-direction: column;
gap: 8rpx;
.content_text {
color: #acafb3;
font-size: 30rpx;
.content_text {
color: #acafb3;
font-size: 30rpx;
.content_label {
display: inline-block;
width: 220rpx;
}
.content_label {
display: inline-block;
width: 220rpx;
}
.content_value {
display: inline-block;
transform: translateY(8rpx);
padding: 0;
width: 452rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.content_value {
display: inline-block;
transform: translateY(8rpx);
padding: 0;
width: 452rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.content_bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.content_bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.action-row {
display: flex;
align-items: center;
justify-content: center;
gap: 16rpx;
}
.action-row {
display: flex;
align-items: center;
justify-content: center;
gap: 16rpx;
}
}
}
}
</style>