pdf+图片学习
This commit is contained in:
parent
c960a0a139
commit
b18427122c
|
|
@ -234,6 +234,13 @@
|
||||||
{
|
{
|
||||||
"navigationBarTitleText" : "公告通知"
|
"navigationBarTitleText" : "公告通知"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "pages/YNEduApp/learnProj/imageStudy",
|
||||||
|
"style" :
|
||||||
|
{
|
||||||
|
"navigationBarTitleText" : "图片学习"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
|
|
|
||||||
|
|
@ -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 监听
|
||||||
|
|
|
||||||
|
|
@ -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'
|
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({
|
||||||
|
|
|
||||||
|
|
@ -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 =
|
// 如果路径中带有http或者https则直接使用路径,否则拼接路径
|
||||||
// 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 倒计时
|
||||||
|
|
@ -64,13 +71,13 @@ export default {
|
||||||
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)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.updStudyDuration()
|
||||||
// 提示-学习时长已满
|
// 提示-学习时长已满
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '学习时长已满',
|
title: '学习时长已满',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
|
||||||
this.updStudyDuration()
|
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration)
|
console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration)
|
||||||
|
|
@ -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
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -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,23 +413,35 @@ 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
|
||||||
|
// }`
|
||||||
|
}, 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}:${
|
this.usedTime = `${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${
|
||||||
seconds < 10 ? '0' + seconds : seconds
|
seconds < 10 ? '0' + seconds : seconds
|
||||||
}`
|
}`
|
||||||
}, 1000)
|
|
||||||
},
|
},
|
||||||
clickImg(url) {
|
clickImg(url) {
|
||||||
console.log('🚀 ~ clickImg ~ url:', url)
|
console.log('🚀 ~ clickImg ~ url:', url)
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue