refactor(train_management): 优化人脸认证逻辑和首页功能

- 修改了 face_authentication 页面的返回逻辑- 优化了 index 页面的扫码功能和人脸认证提示
-移除了生成二维码的冗余请求
hyx_2025-01-13_xgf2.0
wangyan 2025-03-12 14:01:21 +08:00
parent 4934e79c45
commit e348a2248f
2 changed files with 243 additions and 222 deletions

View File

@ -26,16 +26,9 @@
</view> </view>
</view> </view>
</view> </view>
<u-modal <u-modal :show="updateVersion.modalShow" title="温馨提示" :showConfirmButton="updateVersion.showConfirmButton"
:show="updateVersion.modalShow" :showCancelButton="updateVersion.showCancelButton" :confirmText="updateVersion.confirmText"
title="温馨提示" :cancelText="updateVersion.cancelText" @cancel="modalCancel" @confirm="modalConfirm">
:showConfirmButton="updateVersion.showConfirmButton"
:showCancelButton="updateVersion.showCancelButton"
:confirmText="updateVersion.confirmText"
:cancelText="updateVersion.cancelText"
@cancel="modalCancel"
@confirm="modalConfirm"
>
<view style="text-align: center; color: #606266"> <view style="text-align: center; color: #606266">
<rich-text :nodes="updateVersion.modalContent"></rich-text> <rich-text :nodes="updateVersion.modalContent"></rich-text>
</view> </view>
@ -45,17 +38,24 @@
</template> </template>
<script> <script>
import updateVersion from '../../utils/updateVersion' import updateVersion from '../../utils/updateVersion'
import {setEntry, getIsUploadFace, getClassInfoByParams, getClassList} from '../../api' import {
import { getStudentInfoApi, setEntryV1} from "../../api/api"; setEntry,
import store from "../../store"; getIsUploadFace,
getClassInfoByParams,
getClassList
} from '../../api'
import {
getStudentInfoApi,
setEntryV1
} from "../../api/api";
import store from "../../store";
export default { export default {
mixins: [updateVersion], mixins: [updateVersion],
data() { data() {
return { return {
baseList: [ baseList: [{
{
img: require('../../static/icon-apps/app_icons.png'), img: require('../../static/icon-apps/app_icons.png'),
title: '电子工牌', title: '电子工牌',
url: '/pages/electronic_work_card/index' url: '/pages/electronic_work_card/index'
@ -127,15 +127,25 @@ export default {
success: async (res) => { success: async (res) => {
// let obj = JSON.parse(res.result) // let obj = JSON.parse(res.result)
// let type = obj[0].CODE_TYPE // let type = obj[0].CODE_TYPE
const { classId, type, RELEVANT_UNIT_NAME } = JSON.parse(res.result) const {
classId,
stageexampaperinputId,
type,
CORPINFO_ID,
RELEVANT_UNIT_NAME
} = JSON.parse(res.result);
if (type !== '0') {
const classInfo = await this.handleGetClassInfoByParams(classId); const classInfo = await this.handleGetClassInfoByParams(classId);
const resData = await getStudentInfoApi({classId:classInfo.classId}) const resData = await getStudentInfoApi({
classId: classInfo.classId
})
await this.$store.dispatch('setStudentInfo', resData.studentInfo) await this.$store.dispatch('setStudentInfo', resData.studentInfo)
switch(type) { }
switch (type) {
case "0": { case "0": {
let info = await setEntryV1({ let info = await setEntryV1({
userId: this.userInfo.USER_ID, userId: this.userInfo.USER_ID,
// corpinfoId: obj[0].CORPINFO_ID, corpinfoId: CORPINFO_ID,
RELEVANT_UNIT_NAME: RELEVANT_UNIT_NAME, RELEVANT_UNIT_NAME: RELEVANT_UNIT_NAME,
postMethod: 'application/json' postMethod: 'application/json'
}) })
@ -145,7 +155,7 @@ export default {
uni.$u.toast('入职失败,请联系管理员') uni.$u.toast('入职失败,请联系管理员')
} }
break; break;
}; }
// case "1": { // case "1": {
// // type=1 // // type=1
// uni.$u.route({ // uni.$u.route({
@ -163,7 +173,7 @@ export default {
uni.showModal({ uni.showModal({
title: '温馨提示', title: '温馨提示',
content: '检测到您还未完成人脸信息读取,请先完成人脸信息认证!', content: '检测到您还未完成人脸信息读取,请先完成人脸信息认证!',
success: function (res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
uni.$u.route({ uni.$u.route({
url: '/pages/train_management/face_authentication', url: '/pages/train_management/face_authentication',
@ -173,12 +183,19 @@ export default {
}) })
} }
if (res.cancel) { if (res.cancel) {
uni.navigateBack({ delta: 1 }) uni.navigateBack({
delta: 1
})
} }
} }
}) })
} }
if (store.getters.getVerification === '1') {
if (classInfo) { if (classInfo) {
if (classInfo.studystate === "3") {
uni.$u.toast("您已经入班签到,无需再次签到!")
return;
}
uni.$u.route({ uni.$u.route({
url: '/pages/train_management/realname_info_auth', url: '/pages/train_management/realname_info_auth',
params: { params: {
@ -189,11 +206,16 @@ export default {
} else { } else {
uni.$u.toast('您未在培训计划内,无法入班签到,请联系教师') uni.$u.toast('您未在培训计划内,无法入班签到,请联系教师')
} }
} else {
uni.$u.toast('您还未完成人脸信息读取,请先完成人脸信息认证!')
}
break; break;
}; };
case "3": { case "3": {
// [type: 3 --> ] // [type: 3 --> ]
if (store.getters.getVerification === '1') {
if (classInfo) { if (classInfo) {
uni.$u.route({ uni.$u.route({
url: '/pages/train_management/face_authentication', url: '/pages/train_management/face_authentication',
params: { params: {
@ -202,9 +224,13 @@ export default {
classId, classId,
} }
}) })
} else { } else {
uni.$u.toast('您未在培训计划内,无法进行考试,请联系教师') uni.$u.toast('您未在培训计划内,无法进行考试,请联系教师')
} }
} else {
uni.$u.toast('您还未完成人脸信息读取,请先完成人脸信息认证!')
}
break; break;
} }
default: { default: {
@ -230,13 +256,14 @@ export default {
const userFaceData = await getIsUploadFace() const userFaceData = await getIsUploadFace()
// userFaceData.authentication --> 0: // userFaceData.authentication --> 0:
// userFaceData.authentication --> 1: // userFaceData.authentication --> 1:
this.$store.dispatch('setVerification', userFaceData.authentication ? userFaceData.authentication : "0"); // this.$store.dispatch('setVerification', userFaceData.authentication ? userFaceData.authentication :
"0"); //
const isPassedVerification = userFaceData.authentication === '0' const isPassedVerification = userFaceData.authentication === '0'
if (isPassedVerification) { if (isPassedVerification) {
uni.showModal({ uni.showModal({
title: '温馨提示', title: '温馨提示',
content: '为了能够得到更好的体验,我们会获取您个人信息,请完成人脸信息认证!', content: '为了能够得到更好的体验,我们会获取您个人信息,请完成人脸信息认证!',
success: function (res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
uni.$u.route({ uni.$u.route({
url: '/pages/train_management/face_authentication', url: '/pages/train_management/face_authentication',
@ -253,12 +280,12 @@ export default {
} }
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.page { .page {
background-color: #f7f9ff; background-color: #f7f9ff;
min-height: 100vh; min-height: 100vh;
} }
</style> </style>

View File

@ -43,6 +43,7 @@
}, 1000) }, 1000)
}, },
onLoad(query) { onLoad(query) {
console.log('query: >> ', query)
// facial_input 人脸认证 isFirst 1 第一次登录添加人脸 // facial_input 人脸认证 isFirst 1 第一次登录添加人脸
// scan_face 扫码 // scan_face 扫码
// update_facial_input 更新人脸 // update_facial_input 更新人脸
@ -61,25 +62,18 @@
// this.showButton = query.showButton || "yes"; // this.showButton = query.showButton || "yes";
this.routeQueryparams = query ?? {} this.routeQueryparams = query ?? {}
}, },
onBackPress(event) { // onBackPress(event) {
// if (event.from === 'backbutton') { // return false
// if ((this.type === 'scan_face' && this.isFirst === '1') || this.type === 'learning_certification' || this.type === 'facial_input') { // },
// uni.$u.toast('请完成人脸验证')
// return true
// }
// }
if (this.type === 'facial_input') {
uni.$u.route({
type: 'redirect',
url: '/pages/index/index',
})
}
return false
},
onUnload() { onUnload() {
this.startPreviewTimer && clearInterval(this.startPreviewTimer) this.startPreviewTimer && clearInterval(this.startPreviewTimer)
}, },
methods: { methods: {
handleBack() {
uni.navigateBack({
delta: 2,
})
},
snapshot() { snapshot() {
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中'