diff --git a/pages/YNEduApp/exam/examination.vue b/pages/YNEduApp/exam/examination.vue index 59964e8..820af59 100644 --- a/pages/YNEduApp/exam/examination.vue +++ b/pages/YNEduApp/exam/examination.vue @@ -171,7 +171,8 @@ export default { fileUrl: config.fileUrl, score: 0, passScore: 0, - isHide: false + isHide: false, + failCount: 3 } }, onLoad(opt) { @@ -241,7 +242,7 @@ export default { console.log('🚀 ~ getList ~ this.time:', this.time) console.log('🚀 ~ getList ~ this.questionList:', this.questionList) this.random1 = (data.answerTime / 3) * 60 + Math.ceil(Math.random() * 20) + 20 - this.random2 = (data.answerTime / 2) * 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) if (this.questionList.length > 0) { this.questionList.forEach((item, index) => { @@ -468,25 +469,28 @@ export default { // 拍照录入 openPhotograph() { this.isHide = true - uni.chooseImage({ - count: 1, - sizeType: ['compressed'], - sourceType: ['camera'], - success: res => { - this.isHide = false - let url = '' - console.log('🚀 ~ res-拍照:', res) - this.imgToBase64(res.tempFilePaths[0]).then(base64 => { - url = base64 - console.log('🚀 ~ this.imgToBase64 ~ base64:', url) - this.getFaceRecognition({ userId: uni.getStorageSync('userId'), img: url }) - }) - }, - fail: err => { - this.isHide = false - console.log('🚀 ~ err:', err) - } - }) + setTimeout(() => { + this.$refs.countDown.pause() + uni.chooseImage({ + count: 1, + sizeType: ['compressed'], + sourceType: ['camera'], + success: res => { + this.isHide = false + let url = '' + console.log('🚀 ~ res-拍照:', res) + this.imgToBase64(res.tempFilePaths[0]).then(base64 => { + url = base64 + console.log('🚀 ~ this.imgToBase64 ~ base64:', url) + this.getFaceRecognition({ userId: uni.getStorageSync('userId'), img: url }) + }) + }, + fail: err => { + this.isHide = false + console.log('🚀 ~ err:', err) + } + }) + }, 10) }, imgToBase64(data) { return new Promise((resolve, reject) => { @@ -521,14 +525,28 @@ export default { message: '人脸识别成功', duration: 1000 }) + this.failCount = 3 + // 继续计时 + this.$refs.countDown.start() } else { - this.$refs.uToast.show({ - message: '人脸识别失败, 即将结束考试', - duration: 1000 - }) - setTimeout(() => { - this.handleConfirmSubmit() - }, 1000) + this.failCount-- + if (this.failCount == 0) { + this.$refs.uToast.show({ + message: '人脸识别失败, 即将结束考试', + duration: 1500 + }) + setTimeout(() => { + this.handleConfirmSubmit() + }, 1000) + } else { + this.$refs.uToast.show({ + message: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次', + duration: 1500 + }) + setTimeout(() => { + this.openPhotograph() + }, 1700) + } } }, fail(err) { @@ -561,7 +579,7 @@ export default { console.log(err) } }) - }, + } }, onBackPress(options) { console.log(options) diff --git a/pages/YNEduApp/learn/learn.vue b/pages/YNEduApp/learn/learn.vue index 15cf40e..618016c 100644 --- a/pages/YNEduApp/learn/learn.vue +++ b/pages/YNEduApp/learn/learn.vue @@ -61,7 +61,9 @@ export default { isHide: false, oldTime: 0, random1: 0, - random2: 0 + random2: 0, + // 失败次数 + failCount: 3 } }, onLoad(opt) { @@ -193,30 +195,32 @@ export default { // 拍照录入 openPhotograph() { this.isHide = true - uni.chooseImage({ - count: 1, - sizeType: ['compressed'], - sourceType: ['camera'], - success: res => { - let url = '' - console.log('🚀 ~ res-拍照:', res) - this.imgToBase64(res.tempFilePaths[0]).then(base64 => { - url = base64 - console.log('🚀 ~ this.imgToBase64 ~ base64:', url) - this.getFaceRecognition({ userId: uni.getStorageSync('userId'), img: url }) - }) - }, - fail(err) { - console.log('🚀 ~ openFaceScan ~ 人脸识别失败', err) - uni.showToast({ - title: '人脸识别失败', - icon: '' - }) - setTimeout(() => { - this.handleEnd() - }, 1000) - } - }) + setTimeout(() => { + uni.chooseImage({ + count: 1, + sizeType: ['compressed'], + sourceType: ['camera'], + success: res => { + let url = '' + console.log('🚀 ~ res-拍照:', res) + this.imgToBase64(res.tempFilePaths[0]).then(base64 => { + url = base64 + console.log('🚀 ~ this.imgToBase64 ~ base64:', url) + this.getFaceRecognition({ userId: uni.getStorageSync('userId'), img: url }) + }) + }, + fail(err) { + console.log('🚀 ~ openFaceScan ~ 人脸识别失败', err) + uni.showToast({ + title: '人脸识别失败', + icon: '' + }) + setTimeout(() => { + this.handleEnd() + }, 1000) + } + }) + }, 100) }, imgToBase64(data) { return new Promise((resolve, reject) => { @@ -250,18 +254,33 @@ export default { // 提示 uni.showToast({ title: '人脸识别成功', - icon: '' + icon: '', + duration: 1500 }) + this.failCount = 3 // 重置次数 this.isHide = false this.video.play() } else { - uni.showToast({ - title: '人脸识别失败', - icon: '' - }) - setTimeout(() => { - this.handleEnd() - }, 1000) + this.failCount-- + if (this.failCount == 0) { + uni.showToast({ + title: '人脸识别失败, 即将结束学习', + icon: 'none', + duration: 1500 + }) + setTimeout(() => { + this.handleEnd() + }, 1500) + } else { + uni.showToast({ + title: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次', + icon: 'none', + duration: 1500 + }) + setTimeout(() => { + this.openPhotograph() + }, 1500) + } } }, fail(err) { diff --git a/pages/YNEduApp/learnProj/imageStudy.vue b/pages/YNEduApp/learnProj/imageStudy.vue index 1c31d97..1e1c6de 100644 --- a/pages/YNEduApp/learnProj/imageStudy.vue +++ b/pages/YNEduApp/learnProj/imageStudy.vue @@ -24,7 +24,9 @@ export default { time: '', isHide: false, allStudyDuration: 0, - random: 0 + random: 0, + // 失败次数 + failCount: 3 } }, onLoad(opt) { @@ -248,13 +250,26 @@ export default { this.isShow = true this.countDown() } else { - uni.showToast({ - title: '人脸识别失败', - icon: '' - }) - setTimeout(() => { - this.updStudyDuration() - }, 1000) + this.failCount-- + if (this.failCount == 0) { + uni.showToast({ + title: '人脸识别失败, 即将结束学习', + icon: 'none', + duration: 1500 + }) + setTimeout(() => { + this.updStudyDuration() + }, 1500) + } else { + uni.showToast({ + title: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次', + icon: 'none', + duration: 1500 + }) + setTimeout(() => { + this.openPhotograph() + }, 1500) + } } }, fail(err) { diff --git a/pages/YNEduApp/learnProj/pdfStudy.vue b/pages/YNEduApp/learnProj/pdfStudy.vue index 169b490..8ce1814 100644 --- a/pages/YNEduApp/learnProj/pdfStudy.vue +++ b/pages/YNEduApp/learnProj/pdfStudy.vue @@ -24,7 +24,9 @@ export default { isHide: false, allStudyDuration: 0, random1: 0, - random2: 0 + random2: 0, + // 失败次数 + failCount: 3 } }, onLoad(opt) { @@ -211,9 +213,9 @@ export default { if (res.code == 200) { // 提示 uni.showToast({ - title: '人脸识别成功', - icon: '' + title: '人脸识别成功' }) + this.failCount = 3 this.isHide = false // 重新计算 this.surplusTime this.surplusTime = this.allStudyDuration @@ -225,13 +227,25 @@ export default { this.isShow = true this.countDown() } else { - uni.showToast({ - title: '人脸识别失败', - icon: '' - }) - setTimeout(() => { - this.updStudyDuration() - }, 1000) + this.failCount-- + if (this.failCount == 0) { + uni.showToast({ + title: '人脸识别失败, 即将结束学习', + icon: 'none' + }) + setTimeout(() => { + this.updStudyDuration() + }, 1000) + } else { + uni.showToast({ + title: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次', + icon: 'none', + duration: 1500 + }) + setTimeout(() => { + this.openPhotograph() + }, 1500) + } } }, fail(err) {