pdf+图片学习
This commit is contained in:
parent
c960a0a139
commit
b18427122c
|
|
@ -234,6 +234,13 @@
|
|||
{
|
||||
"navigationBarTitleText" : "公告通知"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/YNEduApp/learnProj/imageStudy",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "图片学习"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
|
|
|||
|
|
@ -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 监听
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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}`
|
||||
// 如果路径中带有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 倒计时
|
||||
|
|
@ -64,13 +71,13 @@ export default {
|
|||
console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration)
|
||||
if (allStudyDuration <= 0) {
|
||||
clearInterval(this.timer)
|
||||
setTimeout(() => {
|
||||
this.updStudyDuration()
|
||||
// 提示-学习时长已满
|
||||
uni.showToast({
|
||||
title: '学习时长已满',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.updStudyDuration()
|
||||
}, 1000)
|
||||
}
|
||||
console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration)
|
||||
|
|
@ -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
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ export default {
|
|||
correctRate: '0',
|
||||
// 已用时间 - 计时器 - 用于显示已用时间 格式 00:00:00
|
||||
usedTime: '00:00:00',
|
||||
serviceTime: 0,
|
||||
// 正确题数
|
||||
trueNum: 0,
|
||||
// 错误题数
|
||||
|
|
@ -412,23 +413,35 @@ 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.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
|
||||
}`
|
||||
}, 1000)
|
||||
},
|
||||
clickImg(url) {
|
||||
console.log('🚀 ~ clickImg ~ url:', url)
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue