pdf+图片学习

This commit is contained in:
binbin_pan 2024-09-03 15:20:18 +08:00
parent c960a0a139
commit b18427122c
6 changed files with 239 additions and 60 deletions

View File

@ -234,6 +234,13 @@
{ {
"navigationBarTitleText" : "公告通知" "navigationBarTitleText" : "公告通知"
} }
},
{
"path" : "pages/YNEduApp/learnProj/imageStudy",
"style" :
{
"navigationBarTitleText" : "图片学习"
}
} }
], ],
"globalStyle": { "globalStyle": {

View File

@ -80,7 +80,7 @@ export default {
handlePostMessage(data) { handlePostMessage(data) {
let arr = data.detail.data.pop() let arr = data.detail.data.pop()
this.totalPage = arr[0].totalPage // this.totalPage = arr[0].totalPage //
this.currentReadPage = arr[1].page + 1 // this.currentReadPage = arr[1].page //
console.log('app:', this.totalPage, this.currentReadPage) console.log('app:', this.totalPage, this.currentReadPage)
}, },
//h5 //h5

View File

@ -0,0 +1,154 @@
<template>
<view class="content">
<u--image :showLoading="true" :src="path" width="300px" height="600px" @click="handleImage"></u--image>
</view>
</template>
<script>
import config from '@/config'
export default {
data() {
return {
isShow: true,
path: '',
params: {},
timer: null,
isEnd: false,
isShowImg: false
}
},
onLoad(opt) {
opt = JSON.parse(opt.params)
console.log('🚀 ~ onLoad ~ opt:', opt)
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
// this.path = 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)) {
this.isEnd = false
setTimeout(() => {
this.countDown()
}, 1000)
} else {
this.isEnd = true
// -
uni.showToast({
title: '学习时长已满, 随时可以结束学习',
icon: 'none'
})
}
},
onShow() {
console.log('🚀 ~ onShow ~ 页面显示')
this.isShowImg = false
},
// onHide
onHide() {
console.log('🚀 ~ onHide ~ 页面关闭')
if (this.isEnd) {
return
}
//
if (!this.isShowImg) {
clearInterval(this.timer)
this.updStudyDuration()
}
},
onUnload() {
console.log('🚀 ~ onUnload ~ onUnload-页面关闭:')
if (this.isEnd) {
return
}
//
if (!this.isShowImg) {
clearInterval(this.timer)
this.updStudyDuration()
}
},
methods: {
// allStudyDuration
countDown() {
let allStudyDuration = Number(this.params.allStudyDuration) - Number(this.params.studyDuration)
// 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)
if (allStudyDuration <= 0) {
this.isEnd = true
clearInterval(this.timer)
// -
uni.showToast({
title: '学习时长已满',
icon: 'none'
})
setTimeout(() => {
this.updStudyDuration()
}, 1000)
}
console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration)
console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration)
}, 1000)
},
//
updStudyDuration() {
const params = {
userId: this.params.userId,
studyId: this.params.studyId,
stageId: this.params.stageId,
stageContentId: this.params.stageContentId,
stageType: this.params.stageType,
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) > 100
? 100
: Math.ceil((Number(this.params.studyDuration) / Number(this.params.allStudyDuration)) * 100).toFixed(2)
}
console.log('🚀 ~ updStudyDuration ~ params:', params)
uni.request({
url: config.baseUrl + '/exam-student/student/updStudyDuration',
method: 'post',
data: params,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: uni.getStorageSync('access_token')
},
success: res => {
console.log('🚀 ~ handleEnd ~ res:', res)
this.isShow = false
uni.reLaunch({
url: '/pages/YNEduApp/learnProj/learnProjDetail?id=' + this.params.studyId
})
},
fail: err => {
console.log('🚀 ~ handleEnd ~ err:', err)
}
})
},
//
handleImage() {
this.isShowImg = true
uni.previewImage({
urls: [this.path]
})
}
}
}
</script>
<style lang="scss" scoped>
.content {
display: flex;
justify-content: center;
align-items: center;
}
</style>

View File

@ -286,6 +286,8 @@ export default {
url = '/pages/YNEduApp/learn/learn' url = '/pages/YNEduApp/learn/learn'
} else if (item.path.includes('.pdf')) { } else if (item.path.includes('.pdf')) {
url = '/pages/YNEduApp/learnProj/pdfStudy' url = '/pages/YNEduApp/learnProj/pdfStudy'
} else {
url = '/pages/YNEduApp/learnProj/imageStudy'
} }
uni.navigateTo({ uni.navigateTo({

View File

@ -1,7 +1,7 @@
<template> <template>
<view> <view>
<div> <div>
<PdfView v-if="isShow" :path="path"/> <PdfView v-if="isShow" :path="path" />
</div> </div>
</view> </view>
</template> </template>
@ -26,30 +26,37 @@ export default {
this.params = JSON.parse(JSON.stringify(opt)) this.params = JSON.parse(JSON.stringify(opt))
this.params.studyDuration = Number(opt.studyDuration) this.params.studyDuration = Number(opt.studyDuration)
this.params.allStudyDuration = Number(opt.allStudyDuration) this.params.allStudyDuration = Number(opt.allStudyDuration)
// this.path = // httphttps使
// config.fileUrl + opt.path + `&studyDuration=${opt.studyDuration}&allStudyDuration=${opt.allStudyDuration}` if (opt.path.indexOf('http') !== -1) {
this.path = opt.path this.path = opt.path
} else {
this.path = config.fileUrl + opt.path
}
console.log('🚀 ~ onLoad ~ this.params:', this.path) console.log('🚀 ~ onLoad ~ this.params:', this.path)
console.log('🚀 ~ onLoad ~ this.params:', Number(opt.studyDuration), Number(opt.allStudyDuration)) console.log('🚀 ~ onLoad ~ this.params:', Number(opt.studyDuration), Number(opt.allStudyDuration))
if (Number(opt.studyDuration) <= Number(opt.allStudyDuration)) {
// if (Number(opt.studyDuration) <= Number(opt.allStudyDuration)) { setTimeout(() => {
// setTimeout(() => { this.countDown()
// this.countDown() }, 1000)
// }, 1000) } else {
// } else { // -
// // - uni.showToast({
// uni.showToast({ title: '学习时长已满, 随时可以结束学习',
// title: ', ', icon: 'none'
// icon: 'none' })
// }) }
// } },
onHide() {
clearInterval(this.timer)
//
this.updStudyDuration()
}, },
// //
onUnload() { onUnload() {
console.log('🚀 ~ onUnload ~ 页面关闭') console.log('🚀 ~ onUnload ~ 页面关闭')
clearInterval(this.timer) clearInterval(this.timer)
// //
// this.updStudyDuration() this.updStudyDuration()
}, },
methods: { methods: {
// allStudyDuration // allStudyDuration
@ -58,23 +65,23 @@ export default {
// let studyDuration = Number(this.params.studyDuration) // let studyDuration = Number(this.params.studyDuration)
this.timer = setInterval(() => { this.timer = setInterval(() => {
allStudyDuration-- allStudyDuration--
// studyDuration++ // studyDuration++
this.params.studyDuration++ this.params.studyDuration++
// this.$set(this.params, 'studyDuration', studyDuration) // this.$set(this.params, 'studyDuration', studyDuration)
console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration) console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration)
if (allStudyDuration <= 0) { if (allStudyDuration <= 0) {
clearInterval(this.timer) clearInterval(this.timer)
// -
uni.showToast({
title: '学习时长已满',
icon: 'none'
})
setTimeout(() => { setTimeout(() => {
this.updStudyDuration() this.updStudyDuration()
// -
uni.showToast({
title: '学习时长已满',
icon: 'none'
})
}, 1000) }, 1000)
} }
console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration) console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration)
console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration) console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration)
}, 1000) }, 1000)
}, },
// //
@ -88,9 +95,10 @@ export default {
studyCourseId: this.params.studyCourseId, studyCourseId: this.params.studyCourseId,
sourceId: this.params.sourceId, sourceId: this.params.sourceId,
studyDuration: this.params.studyDuration, studyDuration: this.params.studyDuration,
studyPercentage: Math.ceil( studyPercentage:
(Number(this.params.studyDuration) / Number(this.params.allStudyDuration)) * 100 Math.ceil((Number(this.params.studyDuration) / Number(this.params.allStudyDuration)) * 100).toFixed(2) > 100
).toFixed(2) ? 100
: Math.ceil((Number(this.params.studyDuration) / Number(this.params.allStudyDuration)) * 100).toFixed(2)
} }
console.log('🚀 ~ updStudyDuration ~ params:', params) console.log('🚀 ~ updStudyDuration ~ params:', params)
uni.request({ uni.request({
@ -104,7 +112,7 @@ export default {
success: res => { success: res => {
console.log('🚀 ~ handleEnd ~ res:', res) console.log('🚀 ~ handleEnd ~ res:', res)
this.isShow = false this.isShow = false
uni.navigateTo({ uni.reLaunch({
url: '/pages/YNEduApp/learnProj/learnProjDetail?id=' + this.params.studyId url: '/pages/YNEduApp/learnProj/learnProjDetail?id=' + this.params.studyId
}) })
}, },

View File

@ -230,6 +230,7 @@ export default {
correctRate: '0', correctRate: '0',
// - - 00:00:00 // - - 00:00:00
usedTime: '00:00:00', usedTime: '00:00:00',
serviceTime: 0,
// //
trueNum: 0, trueNum: 0,
// //
@ -412,24 +413,36 @@ export default {
// - // -
startTimer() { startTimer() {
this.intervalId = setInterval(() => { this.intervalId = setInterval(() => {
const time = this.usedTime.split(':') this.serviceTime++
let hours = parseInt(time[0]) this.handleTime()
let minutes = parseInt(time[1]) // const time = this.usedTime.split(':')
let seconds = parseInt(time[2]) // let hours = parseInt(time[0])
seconds++ // let minutes = parseInt(time[1])
if (seconds === 60) { // let seconds = parseInt(time[2])
seconds = 0 // seconds++
minutes++ // if (seconds === 60) {
if (minutes === 60) { // seconds = 0
minutes = 0 // minutes++
hours++ // if (minutes === 60) {
} // minutes = 0
} // hours++
this.usedTime = `${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${ // }
seconds < 10 ? '0' + seconds : seconds // }
}` // this.usedTime = `${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${
// seconds < 10 ? '0' + seconds : seconds
// }`
}, 1000) }, 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) { clickImg(url) {
console.log('🚀 ~ clickImg ~ url:', url) console.log('🚀 ~ clickImg ~ url:', url)
uni.previewImage({ uni.previewImage({
@ -580,6 +593,8 @@ export default {
}, },
// //
async handleSubmit() { async handleSubmit() {
//
clearInterval(this.intervalId)
console.log('提交') console.log('提交')
this.answerNum = this.trueNum + this.falseNum this.answerNum = this.trueNum + this.falseNum
let rate = ((Number(this.trueNum) / Number(this.answerNum)) * 100).toFixed(2) let rate = ((Number(this.trueNum) / Number(this.answerNum)) * 100).toFixed(2)
@ -609,24 +624,17 @@ export default {
handleConfirm() { handleConfirm() {
console.log('确认') console.log('确认')
this.showModal = false this.showModal = false
//
this.startTimer()
}, },
// //
handleClose() { handleClose() {
this.isEnd = true this.isEnd = true
// //
clearInterval() clearInterval(this.intervalId)
console.log('结束', this.usedTime) console.log('结束', this.usedTime, this.serviceTime)
// //
// savePracticeDuration({ let time = Math.ceil(this.serviceTime / 60)
// 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)
console.log('🚀 ~ handleClose ~ time:', time) console.log('🚀 ~ handleClose ~ time:', time)
const params = { const params = {
id: this.recordId, id: this.recordId,