diff --git a/pages.json b/pages.json index 2fd41dd..3ba06e9 100644 --- a/pages.json +++ b/pages.json @@ -234,6 +234,13 @@ { "navigationBarTitleText" : "公告通知" } + }, + { + "path" : "pages/YNEduApp/learnProj/imageStudy", + "style" : + { + "navigationBarTitleText" : "图片学习" + } } ], "globalStyle": { diff --git a/pages/YNEduApp/learnProj/components/PdfView.vue b/pages/YNEduApp/learnProj/components/PdfView.vue index fa163ca..c5e9e50 100644 --- a/pages/YNEduApp/learnProj/components/PdfView.vue +++ b/pages/YNEduApp/learnProj/components/PdfView.vue @@ -80,7 +80,7 @@ export default { handlePostMessage(data) { let arr = data.detail.data.pop() this.totalPage = arr[0].totalPage //总页数 - this.currentReadPage = arr[1].page + 1 //当前页数 + this.currentReadPage = arr[1].page //当前页数 console.log('app:', this.totalPage, this.currentReadPage) }, //h5 监听 diff --git a/pages/YNEduApp/learnProj/imageStudy.vue b/pages/YNEduApp/learnProj/imageStudy.vue new file mode 100644 index 0000000..1a6fa6a --- /dev/null +++ b/pages/YNEduApp/learnProj/imageStudy.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/pages/YNEduApp/learnProj/learnProjDetail.vue b/pages/YNEduApp/learnProj/learnProjDetail.vue index 5d43504..9a6fbef 100644 --- a/pages/YNEduApp/learnProj/learnProjDetail.vue +++ b/pages/YNEduApp/learnProj/learnProjDetail.vue @@ -286,6 +286,8 @@ export default { url = '/pages/YNEduApp/learn/learn' } else if (item.path.includes('.pdf')) { url = '/pages/YNEduApp/learnProj/pdfStudy' + } else { + url = '/pages/YNEduApp/learnProj/imageStudy' } uni.navigateTo({ diff --git a/pages/YNEduApp/learnProj/pdfStudy.vue b/pages/YNEduApp/learnProj/pdfStudy.vue index 8725906..05c8045 100644 --- a/pages/YNEduApp/learnProj/pdfStudy.vue +++ b/pages/YNEduApp/learnProj/pdfStudy.vue @@ -1,7 +1,7 @@ @@ -26,30 +26,37 @@ export default { this.params = JSON.parse(JSON.stringify(opt)) this.params.studyDuration = Number(opt.studyDuration) this.params.allStudyDuration = Number(opt.allStudyDuration) - // this.path = - // config.fileUrl + opt.path + `&studyDuration=${opt.studyDuration}&allStudyDuration=${opt.allStudyDuration}` - this.path = opt.path + // 如果路径中带有http或者https则直接使用路径,否则拼接路径 + if (opt.path.indexOf('http') !== -1) { + this.path = opt.path + } else { + this.path = config.fileUrl + opt.path + } console.log('🚀 ~ onLoad ~ this.params:', this.path) console.log('🚀 ~ onLoad ~ this.params:', Number(opt.studyDuration), Number(opt.allStudyDuration)) - - // if (Number(opt.studyDuration) <= Number(opt.allStudyDuration)) { - // setTimeout(() => { - // this.countDown() - // }, 1000) - // } else { - // // 提示-学习时长已满 - // uni.showToast({ - // title: '学习时长已满, 随时可以结束学习', - // icon: 'none' - // }) - // } + if (Number(opt.studyDuration) <= Number(opt.allStudyDuration)) { + setTimeout(() => { + this.countDown() + }, 1000) + } else { + // 提示-学习时长已满 + uni.showToast({ + title: '学习时长已满, 随时可以结束学习', + icon: 'none' + }) + } + }, + onHide() { + clearInterval(this.timer) + // 关闭页面时,修改项目进度 + this.updStudyDuration() }, // 卸载 onUnload() { console.log('🚀 ~ onUnload ~ 页面关闭') clearInterval(this.timer) // 关闭页面时,修改项目进度 - // this.updStudyDuration() + this.updStudyDuration() }, methods: { // 根据allStudyDuration 倒计时 @@ -58,23 +65,23 @@ export default { // let studyDuration = Number(this.params.studyDuration) this.timer = setInterval(() => { allStudyDuration-- - // studyDuration++ - this.params.studyDuration++ - // this.$set(this.params, 'studyDuration', studyDuration) - console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration) + // studyDuration++ + this.params.studyDuration++ + // this.$set(this.params, 'studyDuration', studyDuration) + console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration) if (allStudyDuration <= 0) { clearInterval(this.timer) - // 提示-学习时长已满 - uni.showToast({ - title: '学习时长已满', - icon: 'none' - }) setTimeout(() => { this.updStudyDuration() + // 提示-学习时长已满 + uni.showToast({ + title: '学习时长已满', + icon: 'none' + }) }, 1000) } console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration) - console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration) + console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration) }, 1000) }, // 修改项目进度 @@ -88,9 +95,10 @@ export default { studyCourseId: this.params.studyCourseId, sourceId: this.params.sourceId, studyDuration: this.params.studyDuration, - studyPercentage: Math.ceil( - (Number(this.params.studyDuration) / Number(this.params.allStudyDuration)) * 100 - ).toFixed(2) + studyPercentage: + Math.ceil((Number(this.params.studyDuration) / Number(this.params.allStudyDuration)) * 100).toFixed(2) > 100 + ? 100 + : Math.ceil((Number(this.params.studyDuration) / Number(this.params.allStudyDuration)) * 100).toFixed(2) } console.log('🚀 ~ updStudyDuration ~ params:', params) uni.request({ @@ -104,7 +112,7 @@ export default { success: res => { console.log('🚀 ~ handleEnd ~ res:', res) this.isShow = false - uni.navigateTo({ + uni.reLaunch({ url: '/pages/YNEduApp/learnProj/learnProjDetail?id=' + this.params.studyId }) }, diff --git a/pages/YNEduApp/prac/exercises.vue b/pages/YNEduApp/prac/exercises.vue index 062c463..40422b0 100644 --- a/pages/YNEduApp/prac/exercises.vue +++ b/pages/YNEduApp/prac/exercises.vue @@ -230,6 +230,7 @@ export default { correctRate: '0', // 已用时间 - 计时器 - 用于显示已用时间 格式 00:00:00 usedTime: '00:00:00', + serviceTime: 0, // 正确题数 trueNum: 0, // 错误题数 @@ -412,24 +413,36 @@ export default { // 开始计时 - 实时更新已用时间 startTimer() { this.intervalId = setInterval(() => { - const time = this.usedTime.split(':') - let hours = parseInt(time[0]) - let minutes = parseInt(time[1]) - let seconds = parseInt(time[2]) - seconds++ - if (seconds === 60) { - seconds = 0 - minutes++ - if (minutes === 60) { - minutes = 0 - hours++ - } - } - this.usedTime = `${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${ - seconds < 10 ? '0' + seconds : seconds - }` + this.serviceTime++ + this.handleTime() + // const time = this.usedTime.split(':') + // let hours = parseInt(time[0]) + // let minutes = parseInt(time[1]) + // let seconds = parseInt(time[2]) + // seconds++ + // if (seconds === 60) { + // seconds = 0 + // minutes++ + // if (minutes === 60) { + // minutes = 0 + // hours++ + // } + // } + // this.usedTime = `${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${ + // seconds < 10 ? '0' + seconds : seconds + // }` }, 1000) }, + // 处理时间 + handleTime() { + // this.serviceTime 是秒数 + let hours = parseInt(this.serviceTime / 3600) + let minutes = parseInt((this.serviceTime % 3600) / 60) + let seconds = parseInt(this.serviceTime % 60) + this.usedTime = `${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${ + seconds < 10 ? '0' + seconds : seconds + }` + }, clickImg(url) { console.log('🚀 ~ clickImg ~ url:', url) uni.previewImage({ @@ -580,6 +593,8 @@ export default { }, // 提交 async handleSubmit() { + // 暂停时间 + clearInterval(this.intervalId) console.log('提交') this.answerNum = this.trueNum + this.falseNum let rate = ((Number(this.trueNum) / Number(this.answerNum)) * 100).toFixed(2) @@ -609,24 +624,17 @@ export default { handleConfirm() { console.log('确认') this.showModal = false + // 继续计时 + this.startTimer() }, // 结束答题 handleClose() { this.isEnd = true // 停止计时 - clearInterval() - console.log('结束', this.usedTime) + clearInterval(this.intervalId) + console.log('结束', this.usedTime, this.serviceTime) // 保存练习时长 - // savePracticeDuration({ - // id: this.practiceId, - // practiceDuration: Math.ceil(this.usedTime.split(':')[0] * 60 + this.usedTime.split(':')[1] / 60) - // }) - // 将this.usedTime 00:00:00 转换为分钟 - let time = this.usedTime.split(':').reduce((acc, cur, index) => { - return acc + cur * Math.pow(60, 2 - index) - }, 0) - // 再将秒数转换为分钟, 不足一分钟算一分钟 - time = Math.ceil(time / 60) + let time = Math.ceil(this.serviceTime / 60) console.log('🚀 ~ handleClose ~ time:', time) const params = { id: this.recordId,