This commit is contained in:
zhaoxinyu
2024-07-03 14:53:24 +08:00
parent 6c65eb929c
commit e67b63616e
9 changed files with 293 additions and 114 deletions
@@ -75,6 +75,10 @@ layout("/mobile/platform.html"){
word-break: break-all;
}
.myWatchRecord{
font-size: 14px;
}
</style>
@@ -135,7 +139,7 @@ layout("/mobile/platform.html"){
</span>
</template>
<template #label>
{{getWatchStatus(o)}}
<!-- {{getWatchStatus(o)}}-->
</template>
<template>
@@ -143,10 +147,45 @@ layout("/mobile/platform.html"){
</van-cell>
</van-cell-group>
</van-tab>
<van-tab title="学习记录">
<div style="height: 5px;background-color: #f6f7f9"></div>
<van-cell-group class="video-list">
<van-cell v-for="(o,i) in videoList" :key="o.id" @click="playVideo(o)">
<template #title>
<van-tag plain type="primary" style="margin-right: 10px">视频</van-tag>
<span style="margin-right: 10px">
{{i+1}}.
</span>
<span>
{{o.title}}
</span>
</template>
<template #label>
<div v-if="o.everyDayMaxWatchNum && o.everyDayMaxWatchNum>0" style="padding: 10px 0;color: #0a84ff;white-space: normal">
本视频在活动结束时每天最多只会统计
<span style="color: #0a84ff;font-weight: bold">{{o.everyDayMaxWatchNum}}</span>
次完整观看记录,您可以无限制的观看。
</div>
<div v-for="(v,k) in Object.groupBy(watchRecordList,v=>v.watchTime)" :key="k" class="myWatchRecord">
<div style="display: flex;justify-content: space-between">
<div>
{{moment(k).format('YYYY年MM月DD日')}}
</div>
<div style="color: #000000;">
观看次数
<span style="font-weight: bold">{{v.length}}</span>
</div>
</div>
</div>
</template>
</van-cell>
</van-cell-group>
</van-tab>
</van-tabs>
<div class="bottom-wrap">
<van-button type="danger" block @click="endLearn">结束本次学习</van-button>
<div class="bottom-wrap" v-show="isPlay">
<van-button type="info" block @click="endLearn">上传学习记录</van-button>
</div>
</div>
@@ -176,6 +215,9 @@ layout("/mobile/platform.html"){
}
},
computed: {},
methods: {
async getVideoInfo() {
const {data} = await $.get('/mobile/trainEducation/getVideoList', {albumId: this.albumId})
@@ -197,7 +239,6 @@ layout("/mobile/platform.html"){
return
}
this.currentVideo = o
const playVideo_ = (time = 0) => {
@@ -223,9 +264,10 @@ layout("/mobile/platform.html"){
const v = this.watchRecordList.find(v => v.videoId === o.id)
if (v && v.finish) {
this.$modal.confirm('本视频您已学习完成,是否重新观看,不会影响到完成的学习记录').then(() => {
playVideo_(0)
})
playVideo_(0)
// this.$modal.confirm('本视频您已学习完成,是否重新观看,不会影响到完成的学习记录').then(() => {
// playVideo_(0)
// })
} else if (v && !v.finish) {
playVideo_(v.watchDuration)
} else {
@@ -235,10 +277,10 @@ layout("/mobile/platform.html"){
playEnd() {
this.player.on('ended', async () => {
const v = this.watchRecordList.find(v => v.videoId === this.currentVideo.id)
if (v.finish) {
return
}
// const v = this.watchRecordList.find(v => v.videoId === this.currentVideo.id)
// if (v.finish) {
// return
// }
const loading = this.$toast.loading({
duration: 0,
@@ -253,14 +295,6 @@ layout("/mobile/platform.html"){
setTimeout(() => {
loading.clear()
}, 2000)
// this.addWatchRecord()
// this.getMyWatchRecord()
// const currentIndex = this.videoList.findIndex(v => v.id === this.currentVideo.id)
// const nextVideo = this.videoList[currentIndex + 1]
// if (nextVideo) {
// this.playVideo(nextVideo)
// }
})
},
@@ -272,19 +306,23 @@ layout("/mobile/platform.html"){
albumId: this.currentVideo.albumId
}
const resp = await $.post('/mobile/trainEducation/addWatchRecord', params)
this.getMyWatchRecord()
return resp
if (resp.code === 0) {
this.getMyWatchRecord()
return resp
} else {
this.$modal.msgError(resp.msg)
}
},
//监听页面关闭 隐藏
watchPage() {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
if (this.player && this.currentVideo) {
this.addWatchRecord()
}
}
})
},
// watchPage() {
// document.addEventListener('visibilitychange', () => {
// if (document.visibilityState === 'hidden') {
// if (this.player && this.currentVideo) {
// this.addWatchRecord()
// }
// }
// })
// },
async getMyWatchRecord() {
const {data} = await $.get('/mobile/trainEducation/getMyWatchRecord')
this.watchRecordList = data
@@ -310,10 +348,10 @@ layout("/mobile/platform.html"){
endLearn() {
const v = this.watchRecordList.find(v => v.videoId === this.currentVideo.id)
console.log(v)
if (v && v.finish) {
this.$modal.msg('本视频您已学习完成,无需重复上传')
return
}
// if (v && v.finish) {
// this.$modal.msg('本视频您已学习完成,无需重复上传')
// return
// }
this.$modal.confirm('您是否要结束本视频学习?').then(() => {
//暂停
@@ -336,7 +374,7 @@ layout("/mobile/platform.html"){
},
created() {
this.watchPage()
// this.watchPage()
const id = this.GetQueryString("id")
if (id) {
this.albumId = id