This commit is contained in:
binbin_pan 2024-11-25 15:04:09 +08:00
parent f25bda06a4
commit 10dc5bb077
5 changed files with 269 additions and 233 deletions

View File

@ -126,7 +126,7 @@
<script> <script>
import { pathToBase64, base64ToPath } from 'image-tools' import { pathToBase64, base64ToPath } from 'image-tools'
import face from '@/uni_modules/mcc-face/index.js' // import face from '@/uni_modules/mcc-face/index.js'
import { import {
getExamQuestionList, getExamQuestionList,
insertQuestionAnswerById, insertQuestionAnswerById,
@ -186,6 +186,7 @@ export default {
this.studyId = opt.studyId || '' this.studyId = opt.studyId || ''
this.score = opt.score this.score = opt.score
this.passScore = opt.passScore this.passScore = opt.passScore
this.getList()
}, },
onShow() { onShow() {
this.isHide = false this.isHide = false
@ -209,7 +210,7 @@ export default {
}, 500) }, 500)
}, },
mounted() { mounted() {
this.getList() // this.getList()
}, },
// onUnload() { // onUnload() {
// console.log('🚀 ~ onUnload ~ ') // console.log('🚀 ~ onUnload ~ ')
@ -222,7 +223,9 @@ export default {
const params = { const params = {
examId: this.examId examId: this.examId
} }
console.log('🚀 ~ 考试 ~ params:', params)
this.$verificationToken() this.$verificationToken()
console.log('🚀 ~ 考试 ~ config:', config)
uni.request({ uni.request({
url: config.baseUrl + '/exam-student/studentExam/getExamQuestionList', url: config.baseUrl + '/exam-student/studentExam/getExamQuestionList',
method: 'post', method: 'post',
@ -241,9 +244,9 @@ export default {
this.time = Number(data.answerTime) * 60 * 1000 this.time = Number(data.answerTime) * 60 * 1000
console.log('🚀 ~ getList ~ this.time:', this.time) console.log('🚀 ~ getList ~ this.time:', this.time)
console.log('🚀 ~ getList ~ this.questionList:', this.questionList) console.log('🚀 ~ getList ~ this.questionList:', this.questionList)
this.random1 = (data.answerTime / 3) * 60 + Math.ceil(Math.random() * 20) + 20 // this.random1 = (data.answerTime / 3) * 60 + Math.ceil(Math.random() * 20) + 20
this.random2 = (data.answerTime / 1.5) * 60 + Math.ceil(Math.random() * 30) + 30 // this.random2 = (data.answerTime / 1.5) * 60 + Math.ceil(Math.random() * 30) + 30
console.log('🚀 ~ getList ~ this.random1:', this.random1, this.random2) // console.log('🚀 ~ getList ~ this.random1:', this.random1, this.random2)
if (this.questionList.length > 0) { if (this.questionList.length > 0) {
this.questionList.forEach((item, index) => { this.questionList.forEach((item, index) => {
this.$set(item, 'isShow', index < 7) this.$set(item, 'isShow', index < 7)
@ -275,15 +278,13 @@ export default {
this.answerTime = this.answerTime =
this.time - (time.days * 24 * 60 * 60 + time.hours * 60 * 60 + time.minutes * 60 + time.seconds) * 1000 this.time - (time.days * 24 * 60 * 60 + time.hours * 60 * 60 + time.minutes * 60 + time.seconds) * 1000
// console.log('🚀 ~ changeCountDown ~ this.answerTime:', this.answerTime) // console.log('🚀 ~ changeCountDown ~ this.answerTime:', this.answerTime)
console.log( // console.log(
'🚀 ~ changeCountDown ~ this.answerTime:', // '🚀 ~ changeCountDown ~ this.answerTime:',
this.time, // this.time,
this.answerTime / 1000, // this.answerTime / 1000,
this.random1, // )
this.random2 // console.log('🚀 ~ changeCountDown ~:', this.answerTime / 1000 == this.random1)
) // console.log('🚀 ~ changeCountDown ~:', this.answerTime / 1000 == this.random2)
console.log('🚀 ~ changeCountDown ~:', this.answerTime / 1000 == this.random1)
console.log('🚀 ~ changeCountDown ~:', this.answerTime / 1000 == this.random2)
// if (this.answerTime / 1000 == this.random1) { // if (this.answerTime / 1000 == this.random1) {
// console.log('🚀 ~ changeCountDown ~ ') // console.log('🚀 ~ changeCountDown ~ ')
// // this.openFaceScan() // Android // // this.openFaceScan() // Android
@ -468,97 +469,97 @@ export default {
// }) // })
// }, // },
// //
openPhotograph() { // openPhotograph() {
this.isHide = true // this.isHide = true
setTimeout(() => { // setTimeout(() => {
this.$refs.countDown.pause() // this.$refs.countDown.pause()
uni.chooseImage({ // uni.chooseImage({
count: 1, // count: 1,
sizeType: ['compressed'], // sizeType: ['compressed'],
sourceType: ['camera'], // sourceType: ['camera'],
success: res => { // success: res => {
this.isHide = false // this.isHide = false
let url = '' // let url = ''
console.log('🚀 ~ res-拍照:', res) // console.log('🚀 ~ res-:', res)
this.imgToBase64(res.tempFilePaths[0]).then(base64 => { // this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
url = base64 // url = base64
console.log('🚀 ~ this.imgToBase64 ~ base64:', url) // console.log('🚀 ~ this.imgToBase64 ~ base64:', url)
this.getFaceRecognition({ userId: uni.getStorageSync('userId'), img: url }) // this.getFaceRecognition({ userId: uni.getStorageSync('userId'), img: url })
}) // })
}, // },
fail: err => { // fail: err => {
this.isHide = false // this.isHide = false
console.log('🚀 ~ err:', err) // console.log('🚀 ~ err:', err)
} // }
}) // })
}, 10) // }, 10)
}, // },
imgToBase64(data) { // imgToBase64(data) {
return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
pathToBase64(data) // pathToBase64(data)
.then(base64 => { // .then(base64 => {
resolve(base64) // resolve(base64)
}) // })
.catch(error => { // .catch(error => {
console.error(error) // console.error(error)
reject(error) // reject(error)
}) // })
}) // })
}, // },
// //
getFaceRecognition(params) { // getFaceRecognition(params) {
console.log('🚀 ~ getFaceRecognition ~ params:', params) // console.log('🚀 ~ getFaceRecognition ~ params:', params)
this.$verificationToken() // this.$verificationToken()
uni.request({ // uni.request({
url: config.baseUrl + '/exam-student/personalCenter/getFaceRecognition', // url: config.baseUrl + '/exam-student/personalCenter/getFaceRecognition',
method: 'POST', // method: 'POST',
header: { // header: {
'content-type': 'application/json', // 'content-type': 'application/json',
Authorization: uni.getStorageSync('access_token') // Authorization: uni.getStorageSync('access_token')
}, // },
data: params, // data: params,
success: res => { // success: res => {
console.log('🚀 ~ openFaceScan ~ res-人脸识别:', res) // console.log('🚀 ~ openFaceScan ~ res-:', res)
res = res.data // res = res.data
console.log('🚀 ~ openFaceScan ~ res-人脸识别:', res.code) // console.log('🚀 ~ openFaceScan ~ res-:', res.code)
if (res.code == 200) { // if (res.code == 200) {
this.$refs.uToast.show({ // this.$refs.uToast.show({
message: '人脸识别成功', // message: '',
duration: 1000 // duration: 1000
}) // })
this.failCount = 3 // this.failCount = 3
// // //
this.$refs.countDown.start() // this.$refs.countDown.start()
} else { // } else {
this.failCount-- // this.failCount--
if (this.failCount == 0) { // if (this.failCount == 0) {
this.$refs.uToast.show({ // this.$refs.uToast.show({
message: '人脸识别失败, 即将结束考试', // message: ', ',
duration: 1500 // duration: 1500
}) // })
setTimeout(() => { // setTimeout(() => {
this.handleConfirmSubmit() // this.handleConfirmSubmit()
}, 1000) // }, 1000)
} else { // } else {
this.$refs.uToast.show({ // this.$refs.uToast.show({
message: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次', // message: ', , : ' + this.failCount + '',
duration: 1500 // duration: 1500
}) // })
setTimeout(() => { // setTimeout(() => {
this.openPhotograph() // this.openPhotograph()
}, 1700) // }, 1700)
} // }
} // }
}, // },
fail(err) { // fail(err) {
console.log('🚀 ~ openFaceScan ~ 人脸识别失败', err) // console.log('🚀 ~ openFaceScan ~ ', err)
this.$refs.uToast.show({ // this.$refs.uToast.show({
message: err.errMsg, // message: err.errMsg,
duration: 1000 // duration: 1000
}) // })
} // }
}) // })
}, // },
clickImg(url) { clickImg(url) {
this.isHide = true this.isHide = true
uni.previewImage({ uni.previewImage({

View File

@ -20,7 +20,7 @@
</view> </view>
</view> --> </view> -->
<uni-easyinput <uni-easyinput
prefixIcon="search" suffixIcon="search"
v-model="totalStatus.keyword" v-model="totalStatus.keyword"
placeholder="请输入项目名称" placeholder="请输入项目名称"
@iconClick="toggleSearch" @iconClick="toggleSearch"
@ -354,7 +354,7 @@ export default {
.single-proj { .single-proj {
width: 49%; width: 49%;
height: 30vh; height: 22vh;
margin-bottom: 1vh; margin-bottom: 1vh;
border-radius: 10px; border-radius: 10px;
overflow: hidden; overflow: hidden;
@ -379,13 +379,18 @@ export default {
.detail-upper { .detail-upper {
width: 100%; width: 100%;
height: 65%; height: 50%;
border-bottom: 1px solid #dfdfdf; border-bottom: 1px solid #dfdfdf;
box-sizing: border-box; box-sizing: border-box;
padding: 5px; padding: 5px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
h5 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.icons { .icons {
font-size: 12px; font-size: 12px;
@ -406,7 +411,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
.avatar { /* .avatar {
width: 5vh; width: 5vh;
height: 5vh; height: 5vh;
border-radius: 50%; border-radius: 50%;
@ -417,7 +422,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
} } */
.progress { .progress {
flex: 1; flex: 1;

View File

@ -7,8 +7,7 @@
<view class="user-info"> <view class="user-info">
<div style="font-size: 18px">{{ createUserName }}</div> <div style="font-size: 18px">{{ createUserName }}</div>
<div class="training-content"> <div class="training-content">
<div style="width: 80px">培训内容:</div> <div>培训内容{{ listStageContentNum || '暂无' }}</div>
<span class="content">{{ listStageContentNum }}</span>
</div> </div>
<!-- <view class="info-lef"> <!-- <view class="info-lef">
<view class="avatar"> <view class="avatar">
@ -39,12 +38,15 @@
</view> --> </view> -->
</view> </view>
<!-- <view class="tip">已开启进度同步其他途径的学习进度已自动同步</view> --> <!-- <view class="tip">已开启进度同步其他途径的学习进度已自动同步</view> -->
<u-collapse> <div v-for="(stageItem, stageIndex) in listStage" :key="stageIndex" :title="stageItem.stageName">
<div v-for="(stageItem, stageIndex) in listStage" :key="stageIndex" :title="stageItem.stageName"> <div class="item-stage" @click="handleShow(stageItem)">
{{ stageItem.stageName }} <span>{{ stageItem.stageName }}</span>
<u-icon :name="stageItem.isShow ? 'arrow-down' : 'arrow-up'" size="17" />
</div>
<div v-if="stageItem.isShow">
<div v-for="(content, conIndex) in stageItem.listStageContent" :key="conIndex"> <div v-for="(content, conIndex) in stageItem.listStageContent" :key="conIndex">
<u-collapse-item title="素材" v-if="content.stageType == 1"> <u-collapse :border="false">
<uni-list> <u-collapse-item title="素材" v-if="content.stageType == 1" :border="false">
<div <div
class="list-wrapper" class="list-wrapper"
v-for="(item, index) in content.studyList" v-for="(item, index) in content.studyList"
@ -71,10 +73,8 @@
<div>{{ item.studyPercentage || 0 }}%</div> <div>{{ item.studyPercentage || 0 }}%</div>
</div> </div>
</div> </div>
</uni-list> </u-collapse-item>
</u-collapse-item> <u-collapse-item title="课程" v-if="content.stageType == 2" :border="false">
<u-collapse-item title="课程" v-if="content.stageType == 2">
<uni-list>
<div <div
class="list-wrapper" class="list-wrapper"
v-for="(item, index) in content.studyList" v-for="(item, index) in content.studyList"
@ -101,11 +101,9 @@
<div>{{ item.studyPercentage || 0 }}%</div> <div>{{ item.studyPercentage || 0 }}%</div>
</div> </div>
</div> </div>
</uni-list> </u-collapse-item>
</u-collapse-item>
<u-collapse-item title="练习" v-if="content.stageType == 3"> <u-collapse-item title="练习" v-if="content.stageType == 3" :border="false">
<uni-list>
<div class="list-wrapper" @click="toggleTheoryPrac(content)"> <div class="list-wrapper" @click="toggleTheoryPrac(content)">
<div class="left-content"> <div class="left-content">
<div class="title"> <div class="title">
@ -125,11 +123,9 @@
{{ content.practiceMsg && content.practiceMsg.allQuestionNum == 0 ? '未开始' : '已练习' }} {{ content.practiceMsg && content.practiceMsg.allQuestionNum == 0 ? '未开始' : '已练习' }}
</div> </div>
</div> </div>
</uni-list> </u-collapse-item>
</u-collapse-item>
<u-collapse-item title="考试" v-if="content.stageType == 4"> <u-collapse-item title="考试" v-if="content.stageType == 4" :border="false">
<uni-list>
<div class="list-wrapper" @click="toggleTheoryExam(content)"> <div class="list-wrapper" @click="toggleTheoryExam(content)">
<div class="left-content"> <div class="left-content">
<div class="title"> <div class="title">
@ -155,11 +151,11 @@
{{ !content.examMsg || content.examMsg.examNum == 0 ? '开始考试' : '重考' }} {{ !content.examMsg || content.examMsg.examNum == 0 ? '开始考试' : '重考' }}
</div> </div>
</div> </div>
</uni-list> </u-collapse-item>
</u-collapse-item> </u-collapse>
</div> </div>
</div> </div>
</u-collapse> </div>
</view> </view>
<!-- <view class="comment-area"> <!-- <view class="comment-area">
<h2 style="margin-bottom: 15rpx">最新评论 ({{ commentList.length }})</h2> <h2 style="margin-bottom: 15rpx">最新评论 ({{ commentList.length }})</h2>
@ -255,6 +251,10 @@ export default {
this.getStudyWorkAll() this.getStudyWorkAll()
}, },
methods: { methods: {
handleShow(item) {
console.log('🚀 ~ handleShow ~ item:', item.isShow)
item.isShow = this.$set(item, 'isShow', !item.isShow)
},
// //
async getStudyWorkAll() { async getStudyWorkAll() {
let params = { userId: uni.getStorageSync('userId'), id: this.projId, type: '1' } let params = { userId: uni.getStorageSync('userId'), id: this.projId, type: '1' }
@ -276,6 +276,11 @@ export default {
this.listStageContentNum = res.data.listStageContentNum this.listStageContentNum = res.data.listStageContentNum
this.eligibility = res.data.eligibility this.eligibility = res.data.eligibility
this.listStage = res.data.listStage this.listStage = res.data.listStage
if (this.listStage.length > 0) {
this.listStage.forEach((item, index) => {
this.$set(item, 'isShow', true)
})
}
} }
}) })
}, },
@ -406,13 +411,29 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
::v-deep .u-cell__body {
padding: 5px !important;
}
::v-deep .u-collapse-item__content__text{
padding: 0 5px !important;
}
.page { .page {
width: 100vw; width: 100vw;
height: 100vh;
background-color: #f8f8f8; background-color: #f8f8f8;
box-sizing: border-box; box-sizing: border-box;
padding: 5vw; padding: 5vw 5px;
position: relative; position: relative;
.item-stage {
margin: 8px 0;
font-size: 16px;
display: flex;
justify-content: space-between;
align-items: center;
}
.proj-cont { .proj-cont {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
@ -432,8 +453,11 @@ export default {
margin-bottom: 2vh; margin-bottom: 2vh;
.training-content { .training-content {
word-wrap: break-word; // display: flex;
margin-top: 10px;
white-space: normal; white-space: normal;
word-wrap: break-word;
word-break: break-all;
} }
.info-lef { .info-lef {
@ -498,19 +522,22 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 20px 10px; /* padding: 20px 0; */
margin-bottom: 10px;
padding-bottom: 5px;
border-bottom: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0;
font-size: 12px; font-size: 12px;
color: #b0b0b0; color: #b0b0b0;
/* height: 400px; */ /* height: 400px; */
overflow: auto; overflow: auto;
.left-content { .left-content {
width: 60vw;
.title { .title {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.note { .note {
width: 130px; /* width: 130px; */
margin-top: 10px; margin-top: 10px;
font-size: 14px; font-size: 14px;
color: #333; color: #333;
@ -518,6 +545,7 @@ export default {
} }
} }
.right-content { .right-content {
width: 35vw;
display: flex; display: flex;
align-items: center; align-items: center;
.progress { .progress {

View File

@ -851,7 +851,8 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.wrapper { .wrapper {
height: 100vh; height: 100vh;
background: url('/static/images/question-bg.png') no-repeat; /* background: url('/static/images/question-bg.png') no-repeat; */
background: #fff;
background-size: 100% 100%; background-size: 100% 100%;
.slot-content { .slot-content {
@ -998,7 +999,8 @@ export default {
.top-time { .top-time {
text-align: center; text-align: center;
font-size: 13px; font-size: 13px;
color: #fff; /* color: #fff; */
color: #333;
padding-top: 60px; padding-top: 60px;
} }

View File

@ -45,7 +45,7 @@
<script> <script>
import { pathToBase64, base64ToPath } from 'image-tools' import { pathToBase64, base64ToPath } from 'image-tools'
import face from '@/uni_modules/mcc-face/index.js' // import face from '@/uni_modules/mcc-face/index.js'
import config from 'config.js' import config from 'config.js'
export default { export default {
@ -69,103 +69,103 @@ export default {
}, },
methods: { methods: {
// //
openFaceScan() { // openFaceScan() {
this.url = '' // this.url = ''
face.open(['a'], e => { // face.open(['a'], e => {
console.log('🚀 ~ e-人脸识别:', e) // console.log('🚀 ~ e-:', e)
this.url = e // this.url = e
this.isShow = false // this.isShow = false
face.close() // face.close()
}) // })
if (!this.url) this.isShow = true // if (!this.url) this.isShow = true
}, // },
// //
handleSubmit() { // handleSubmit() {
console.log('🚀 ~ handleSubmit ~ this.url:', this.url) // console.log('🚀 ~ handleSubmit ~ this.url:', this.url)
// // //
uni.uploadFile({ // uni.uploadFile({
url: config.uploadUrl, // url: config.uploadUrl,
filePath: this.url, // filePath: this.url,
name: 'data', // name: 'data',
formData: { // formData: {
photoType: 'face', // photoType: 'face',
file: this.url // file: this.url
}, // },
header: { // header: {
Authorization: this.token // Authorization: this.token
}, // },
success: res => { // success: res => {
console.log('🚀 ~ res:', res) // console.log('🚀 ~ res:', res)
res = JSON.parse(res.data) // res = JSON.parse(res.data)
this.facePath = res.data.url // this.facePath = res.data.url
console.log('🚀 ~ handleSubmit ~ this.facePath:', this.facePath, this.optMode) // console.log('🚀 ~ handleSubmit ~ this.facePath:', this.facePath, this.optMode)
let params = { // let params = {
userId: this.userId, // userId: this.userId,
facePath: this.facePath, // facePath: this.facePath,
optMode: this.optMode, // optMode: this.optMode,
img: this.url // img: this.url
} // }
params = JSON.stringify(params) // params = JSON.stringify(params)
this.$verificationToken() // this.$verificationToken()
uni.request({ // uni.request({
url: config.baseUrl + '/exam-student/personalCenter/uploadFaceRecognition', // url: config.baseUrl + '/exam-student/personalCenter/uploadFaceRecognition',
method: 'POST', // method: 'POST',
data: params, // data: params,
header: { // header: {
'content-type': 'application/json', // 'content-type': 'application/json',
Authorization: this.token // Authorization: this.token
}, // },
success: res => { // success: res => {
res = res.data // res = res.data
console.log('🚀 ~ this.uploadFaceRecognition ~ res上传成功:', res, res.code) // console.log('🚀 ~ this.uploadFaceRecognition ~ res:', res, res.code)
if (res.code == 200) { // if (res.code == 200) {
uni.showToast({ // uni.showToast({
title: '人脸信息录入成功', // title: '',
icon: 'none' // icon: 'none'
}) // })
uni.removeStorageSync('facePath') // uni.removeStorageSync('facePath')
uni.setStorageSync('facePath', this.facePath) // uni.setStorageSync('facePath', this.facePath)
setTimeout(() => { // setTimeout(() => {
uni.navigateTo({ // uni.navigateTo({
url: '/pages/YNEduApp/user/user' // url: '/pages/YNEduApp/user/user'
}) // })
}, 1000) // }, 1000)
} else { // } else {
uni.showToast({ // uni.showToast({
title: res.msg, // title: res.msg,
icon: 'none' // icon: 'none'
}) // })
} // }
}, // },
fail: err => { // fail: err => {
console.log('🚀 ~ this.uploadFaceRecognition ~ err:', err) // console.log('🚀 ~ this.uploadFaceRecognition ~ err:', err)
} // }
}) // })
}, // },
fail: err => { // fail: err => {
console.log('🚀 ~ err:', err) // console.log('🚀 ~ err:', err)
} // }
}) // })
}, // },
// //
openPhotograph() { // openPhotograph() {
uni.chooseImage({ // uni.chooseImage({
count: 1, // count: 1,
sizeType: ['compressed'], // sizeType: ['compressed'],
sourceType: ['camera'], // sourceType: ['camera'],
success: res => { // success: res => {
console.log('🚀 ~ res-拍照:', res) // console.log('🚀 ~ res-:', res)
this.imgToBase64(res.tempFilePaths[0]).then(base64 => { // this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
console.log('🚀 ~ this.imgToBase64 ~ base64:', base64) // console.log('🚀 ~ this.imgToBase64 ~ base64:', base64)
this.url = base64 // this.url = base64
}) // })
this.isShow = false // this.isShow = false
}, // },
fail: err => { // fail: err => {
console.log('🚀 ~ err:', err) // console.log('🚀 ~ err:', err)
} // }
}) // })
}, // },
imgToBase64(data) { imgToBase64(data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
pathToBase64(data) pathToBase64(data)