人脸识别优化

This commit is contained in:
binbin_pan 2024-09-18 17:15:31 +08:00
parent ad60298cdd
commit d2bb0079e6
4 changed files with 146 additions and 80 deletions

View File

@ -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,6 +469,8 @@ export default {
//
openPhotograph() {
this.isHide = true
setTimeout(() => {
this.$refs.countDown.pause()
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
@ -487,6 +490,7 @@ export default {
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.failCount--
if (this.failCount == 0) {
this.$refs.uToast.show({
message: '人脸识别失败, 即将结束考试',
duration: 1000
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)

View File

@ -61,7 +61,9 @@ export default {
isHide: false,
oldTime: 0,
random1: 0,
random2: 0
random2: 0,
//
failCount: 3
}
},
onLoad(opt) {
@ -193,6 +195,7 @@ export default {
//
openPhotograph() {
this.isHide = true
setTimeout(() => {
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
@ -217,6 +220,7 @@ export default {
}, 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 {
this.failCount--
if (this.failCount == 0) {
uni.showToast({
title: '人脸识别失败',
icon: ''
title: '人脸识别失败, 即将结束学习',
icon: 'none',
duration: 1500
})
setTimeout(() => {
this.handleEnd()
}, 1000)
}, 1500)
} else {
uni.showToast({
title: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次',
icon: 'none',
duration: 1500
})
setTimeout(() => {
this.openPhotograph()
}, 1500)
}
}
},
fail(err) {

View File

@ -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 {
this.failCount--
if (this.failCount == 0) {
uni.showToast({
title: '人脸识别失败',
icon: ''
title: '人脸识别失败, 即将结束学习',
icon: 'none',
duration: 1500
})
setTimeout(() => {
this.updStudyDuration()
}, 1000)
}, 1500)
} else {
uni.showToast({
title: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次',
icon: 'none',
duration: 1500
})
setTimeout(() => {
this.openPhotograph()
}, 1500)
}
}
},
fail(err) {

View File

@ -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 {
this.failCount--
if (this.failCount == 0) {
uni.showToast({
title: '人脸识别失败',
icon: ''
title: '人脸识别失败, 即将结束学习',
icon: 'none'
})
setTimeout(() => {
this.updStudyDuration()
}, 1000)
} else {
uni.showToast({
title: '人脸识别失败, 请重新录入, 剩余次数: ' + this.failCount + '次',
icon: 'none',
duration: 1500
})
setTimeout(() => {
this.openPhotograph()
}, 1500)
}
}
},
fail(err) {