|
@@ -24,6 +24,7 @@ export default defineComponent({
|
|
|
const forms = reactive({
|
|
|
coverImg: '',
|
|
|
introductionVideo: '',
|
|
|
+ introductionVideoTime: 0, // 视频总时长
|
|
|
videoBrowsePoint: 0,
|
|
|
saveId: route.query.saveId,
|
|
|
orchestraId: route.query.id,
|
|
@@ -31,7 +32,8 @@ export default defineComponent({
|
|
|
loading: false,
|
|
|
player: null as any,
|
|
|
playerSpeed: 1,
|
|
|
- intervalFnRef: null as any
|
|
|
+ intervalFnRef: null as any,
|
|
|
+ isPageHide: false // 处理页面返回没有刷新的问题
|
|
|
})
|
|
|
|
|
|
// 播放视频总时长
|
|
@@ -244,6 +246,7 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
watch(pageVisibility, (value: any) => {
|
|
|
+ console.log('watch', value)
|
|
|
if (value == 'hidden') {
|
|
|
forms.player.pause()
|
|
|
}
|
|
@@ -255,9 +258,8 @@ export default defineComponent({
|
|
|
const videoBrowseData = moreTime.value.length > 0 ? formatEffectiveTime(moreTime.value) : []
|
|
|
const time = moreTime.value.length > 0 ? formatTimer(moreTime.value) : 0
|
|
|
// const videoCountTime = videoIntervalRef?.counter.value
|
|
|
- const videoDuration = forms.player.duration
|
|
|
// 判断如何视屏播放时间大于视屏播放有效时间则说明数据有问题,进行重置数据
|
|
|
- const rate = Math.floor((time / Math.floor(videoDuration)) * 100)
|
|
|
+ const rate = Math.floor((time / Math.floor(forms.introductionVideoTime)) * 100)
|
|
|
// console.log('videoIntervalRef?.counter.value', videoIntervalRef?.counter.value)
|
|
|
await request.post('/api-student/open/studentBrowseRecord/updateStat', {
|
|
|
data: {
|
|
@@ -314,7 +316,7 @@ export default defineComponent({
|
|
|
|
|
|
onMounted(async () => {
|
|
|
try {
|
|
|
- const { data } = await request.get('/api-student//open/studentBrowseRecord/query', {
|
|
|
+ const { data } = await request.get('/api-student/open/studentBrowseRecord/query', {
|
|
|
params: {
|
|
|
openId: forms.openId,
|
|
|
orchestraId: forms.orchestraId
|
|
@@ -325,6 +327,7 @@ export default defineComponent({
|
|
|
forms.player.currentTime = data.videoBrowsePoint || 0
|
|
|
}
|
|
|
forms.introductionVideo = data.introductionVideo
|
|
|
+ forms.introductionVideoTime = data.introductionVideoTime
|
|
|
forms.coverImg = data.coverImg
|
|
|
moreTime.value = data.videoBrowseData ? JSON.parse(data.videoBrowseData) : []
|
|
|
|
|
@@ -358,6 +361,26 @@ export default defineComponent({
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ const onPageShow = () => {
|
|
|
+ console.log(forms.isPageHide, 'showInfo')
|
|
|
+ if (forms.isPageHide) {
|
|
|
+ window.location.reload()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理监听页面返回不刷新的问题
|
|
|
+ window.addEventListener('pageshow', onPageShow)
|
|
|
+
|
|
|
+ const onPageHide = () => {
|
|
|
+ console.log(forms.isPageHide, 'showInfo')
|
|
|
+ forms.isPageHide = true
|
|
|
+ }
|
|
|
+ window.addEventListener('pagehide', onPageHide)
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ window.removeEventListener('pageshow', onPageShow)
|
|
|
+ window.removeEventListener('pagehide', onPageHide)
|
|
|
+ })
|
|
|
return () => (
|
|
|
<div class={styles['pre-register-video']}>
|
|
|
<div class={styles.videoContainer}>
|