refactor(qa-prevention-xgf-app): 重构 api 调用和班级信息获取

-重命名 getListAll 为 getClassInfoByParams,提高代码可读性
- 在 api.js 中添加 getClassList 和 getStudentInfoApi调用
- 优化 store 中的 setStudentInfo action
- 在首页和培训管理页面中集成新的 api 调用
- 添加人脸信息认证提示功能
hyx_2025-01-13_xgf2.0
wangyan 2025-03-07 17:46:52 +08:00
parent d630c82b07
commit 83f1310d06
6 changed files with 42 additions and 18 deletions

View File

@ -9,3 +9,4 @@ export const setRefreshToken = (params) => post("/sys/refreshToken", params ); /
export const setEntryV1 = (params) => post("/app/sys/user/entry", params ); // 入职 export const setEntryV1 = (params) => post("/app/sys/user/entry", params ); // 入职
export const resignV1 = (params) => post("/app/sys/user/resign", params ); // 离职 export const resignV1 = (params) => post("/app/sys/user/resign", params ); // 离职
export const getStudentInfoApi = (params) => post("/app/student/getStudentInfo", params ); // 获取学员信息 export const getStudentInfoApi = (params) => post("/app/student/getStudentInfo", params ); // 获取学员信息

View File

@ -84,5 +84,5 @@ export const compareUserFaceCertify = (params) => post('/app/user/compareFace',
export const compareUserVideoFaceCertify = (params) => post('/app/user/compareVideoFace', params) // 视频人脸验证 export const compareUserVideoFaceCertify = (params) => post('/app/user/compareVideoFace', params) // 视频人脸验证
export const compareUserExamFaceCertify = (params) => post('/app/user/compareExamFace', params) // 考试照片人脸认证 export const compareUserExamFaceCertify = (params) => post('/app/user/compareExamFace', params) // 考试照片人脸认证
export const compareUserExamVideoFaceCertify = (params) => post('/app/user/compareExamVideoFace', params) // 考试视频人脸认证 export const compareUserExamVideoFaceCertify = (params) => post('/app/user/compareExamVideoFace', params) // 考试视频人脸认证
export const getListAll = (params) => post("/app/stagestudentrelation/getClassInfoByParams", params); export const getClassInfoByParams = (params) => post("/app/stagestudentrelation/getClassInfoByParams", params ); // 获取班级信息
// ********************* end *********************** // ********************* end ***********************

View File

@ -46,8 +46,9 @@
<script> <script>
import updateVersion from '../../utils/updateVersion' import updateVersion from '../../utils/updateVersion'
import { setEntry, getIsUploadFace } from '../../api' import {setEntry, getIsUploadFace, getClassInfoByParams, getClassList} from '../../api'
import {setEntryV1} from "../../api/api"; import { getStudentInfoApi, setEntryV1} from "../../api/api";
import store from "../../store";
export default { export default {
mixins: [updateVersion], mixins: [updateVersion],
@ -103,10 +104,10 @@ export default {
this.getUserFaceCompleted() this.getUserFaceCompleted()
}, },
methods: { methods: {
handleGetListAll(classId) { handleGetClassInfoByParams(classId) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const userInfo = store.getters.getUserInfo const userInfo = store.getters.getUserInfo
await getListAll({ await getClassInfoByParams({
classId, classId,
userId: userInfo.USER_ID userId: userInfo.USER_ID
}) })
@ -125,7 +126,9 @@ export default {
// 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, type, RELEVANT_UNIT_NAME } = JSON.parse(res.result)
const classInfo = await this.handleGetListAll(classId); const classInfo = await this.handleGetClassInfoByParams(classId);
const resData = await getStudentInfoApi({classId:classInfo.classId})
await this.$store.dispatch('setStudentInfo', resData.studentInfo)
switch(type) { switch(type) {
case "0": { case "0": {
let info = await setEntryV1({ let info = await setEntryV1({
@ -154,6 +157,25 @@ export default {
// }; // };
case "2": { case "2": {
// , [type: 2 --> ] // , [type: 2 --> ]
if (store.getters.getVerification === '0') {
uni.showModal({
title: '温馨提示',
content: '检测到您还未完成人脸信息读取,请先完成人脸信息认证!',
success: function (res) {
if (res.confirm) {
uni.$u.route({
url: '/pages/train_management/face_authentication',
params: {
type: 'facial_input'
}
})
}
if (res.cancel) {
uni.navigateBack({ delta: 1 })
}
}
})
}
if (classInfo) { if (classInfo) {
uni.$u.route({ uni.$u.route({
url: '/pages/train_management/realname_info_auth', url: '/pages/train_management/realname_info_auth',

View File

@ -45,8 +45,9 @@
</template> </template>
<script> <script>
import { getClassList, getIsUploadFace, getStudentInfoApi, getListAll } from '@/api'
import store from '@/store/index' import store from '@/store/index'
import {getClassInfoByParams, getClassList} from "../../api";
import {getStudentInfoApi} from "../../api/api";
export default { export default {
data() { data() {
@ -93,10 +94,10 @@ export default {
this.currentPage++ this.currentPage++
if (this.totalPage >= this.currentPage) this.getData() if (this.totalPage >= this.currentPage) this.getData()
}, },
handleGetListAll(classId) { handleGetClassInfoByParams(classId) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const userInfo = store.getters.getUserInfo const userInfo = store.getters.getUserInfo
await getListAll({ await getClassInfoByParams({
classId, classId,
userId: userInfo.USER_ID userId: userInfo.USER_ID
}) })
@ -113,9 +114,6 @@ export default {
* 右上角自定义扫码图标触发事件 * 右上角自定义扫码图标触发事件
*/ */
onNavigationBarButtonTap(e) { onNavigationBarButtonTap(e) {
//
// this.getStudentInfoFunc();
// //
uni.scanCode({ uni.scanCode({
// scanType: ['qrCode'], // // scanType: ['qrCode'], //
@ -123,7 +121,9 @@ export default {
hideAlbum: false, // , hideAlbum: false, // ,
success:async (response) => { success:async (response) => {
const { stageexampaperinputId, classId, type } = JSON.parse(response.result) const { stageexampaperinputId, classId, type } = JSON.parse(response.result)
const classInfo = await this.handleGetListAll(classId); //
await this.getStudentInfoFunc(classId);
const classInfo = await this.handleGetClassInfoByParams(classId);
if (type === '2') { if (type === '2') {
// , [type: 2 --> ] // , [type: 2 --> ]
if (classInfo) { if (classInfo) {
@ -164,15 +164,15 @@ export default {
/** /**
* 使用网络接口获取学员信息 * 使用网络接口获取学员信息
*/ */
async getStudentInfoFunc() { async getStudentInfoFunc(classId) {
const resData = await getStudentInfoApi() const resData = await getStudentInfoApi({classId})
console.log('resData :>> ', resData);
await this.$store.dispatch('studentInfo', resData.studentInfo) await this.$store.dispatch('studentInfo', resData.studentInfo)
}, },
/** /**
* 获取是否已经完成上传人脸信息 * 获取是否已经完成上传人脸信息
*/ */
async getUserFaceCompleted() { async getUserFaceCompleted() {
// const userFaceData = await getIsUploadFace()
// verification --> 0: // verification --> 0:
// verification --> 1: // verification --> 1:
if (store.getters.getVerification === '0') { if (store.getters.getVerification === '0') {

View File

@ -181,6 +181,7 @@ export default {
onLoad(query) { onLoad(query) {
this.routeQuery = query // 1 this.routeQuery = query // 1
const { name,// const { name,//
phone, // phone, //
userIdCard,// userIdCard,//

View File

@ -48,7 +48,7 @@ const store = new Vuex.Store({
setUserInfo({commit}, userInfo) { setUserInfo({commit}, userInfo) {
commit('setUserInfo', userInfo) commit('setUserInfo', userInfo)
}, },
setStudentInfo(state, studentInfo) { setStudentInfo({commit}, studentInfo) {
commit('setStudentInfo', studentInfo) commit('setStudentInfo', studentInfo)
}, },
setVerification({commit}, verification) { setVerification({commit}, verification) {