|
@@ -26,7 +26,7 @@ import { browser } from '@/helpers/utils'
|
|
|
import { Vue3Lottie } from 'vue3-lottie'
|
|
|
import playLoadData from './datas/data.json'
|
|
|
import { usePageVisibility } from '@vant/use'
|
|
|
-import { useInterval } from '@vueuse/core'
|
|
|
+import { useInterval, useIntervalFn } from '@vueuse/core'
|
|
|
import PlayRecordTime from './playRecordTime'
|
|
|
import { handleCheckVip } from '../hook/useFee'
|
|
|
import OGuide from '@/components/o-guide'
|
|
@@ -236,7 +236,6 @@ export default defineComponent({
|
|
|
popupData.itemActive = item.id
|
|
|
popupData.itemName = item.name
|
|
|
nextTick(() => {
|
|
|
- console.log(list, 'list')
|
|
|
data.itemList = list
|
|
|
checkedAnimation(popupData.activeIndex)
|
|
|
postMessage({
|
|
@@ -324,9 +323,12 @@ export default defineComponent({
|
|
|
const getLookVideoData = async () => {
|
|
|
try {
|
|
|
const { data } = await request.get(
|
|
|
- state.platformApi + `/studentCoursewareMaterialRelation/findByDetailId/${route.query.id}`,
|
|
|
+ state.platformApi + `/studentCoursewareMaterialRelation/findByDetailId`,
|
|
|
{
|
|
|
- hideLoading: true
|
|
|
+ hideLoading: true,
|
|
|
+ params: {
|
|
|
+ lessonCoursewareDetailId: route.query.id
|
|
|
+ }
|
|
|
}
|
|
|
)
|
|
|
console.log(data)
|
|
@@ -650,6 +652,7 @@ export default defineComponent({
|
|
|
/**
|
|
|
* 统计视频播放时间段
|
|
|
*/
|
|
|
+ const intervalFnRef = ref() // 定时任务
|
|
|
// 播放视频总时长
|
|
|
const videoIntervalRef = useInterval(1000, { controls: true })
|
|
|
videoIntervalRef.pause()
|
|
@@ -748,8 +751,24 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
// 更新时间
|
|
|
- const updateStat = async (pageBrowseTime = 10) => {
|
|
|
+ const updateStat = async () => {
|
|
|
try {
|
|
|
+ const itemList = data.itemList
|
|
|
+ const params: any = []
|
|
|
+ itemList.forEach((item: any) => {
|
|
|
+ if (item.moreTime.length > 0) {
|
|
|
+ const videoBrowseData = formatEffectiveTime(item.moreTime)
|
|
|
+ const time = videoBrowseData.length > 0 ? formatTimer(videoBrowseData) : 0
|
|
|
+ const temp = {
|
|
|
+ lessonCoursewareDetailId: route.query.id,
|
|
|
+ browseTime: time, // 播放时长
|
|
|
+ videoBrowseData: JSON.stringify(videoBrowseData), // 播放的数据
|
|
|
+ videoTime: item.videoTime, // 视频时长
|
|
|
+ materialId: item.materialId
|
|
|
+ }
|
|
|
+ params.push(temp)
|
|
|
+ }
|
|
|
+ })
|
|
|
// const videoBrowseData = moreTime.value.length > 0 ? formatEffectiveTime(moreTime.value) : []
|
|
|
// console.log(moreTime.value, videoBrowseData, 'video')
|
|
|
// const time = videoBrowseData.length > 0 ? formatTimer(videoBrowseData) : 0
|
|
@@ -757,20 +776,24 @@ export default defineComponent({
|
|
|
// 判断如何视屏播放时间大于视屏播放有效时间则说明数据有问题,进行重置数据
|
|
|
// const rate = Math.floor((time / Math.floor(forms.pointVideoTime)) * 100)
|
|
|
// console.log('videoIntervalRef?.counter.value', videoIntervalRef?.counter.value)
|
|
|
- // await request.post('/api-student/studentCoursewareMaterialRelation/save', {
|
|
|
- // data: {
|
|
|
- // lessonCoursewareDetailId: route.query.id,
|
|
|
- // pageBrowseTime, // 固定10秒
|
|
|
- // videoBrowseData: JSON.stringify(videoBrowseData), // 视屏播放数据
|
|
|
- // videoBrowseDataTime: time || 0, // 有效的视频观看时长
|
|
|
- // // videoBrowseTime: videoIntervalRef?.counter.value, // 视频观看时长
|
|
|
- // // videoBrowsePoint: Math.floor(forms.player.currentTime || 0) // 视频最后观看点 - 向下取整
|
|
|
- // }
|
|
|
- // })
|
|
|
+ await request.post('/api-student/studentCoursewareMaterialRelation/save', {
|
|
|
+ data: params
|
|
|
+ })
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ // 间隔多少时间同步数据
|
|
|
+ intervalFnRef.value = useIntervalFn(async () => {
|
|
|
+ // 同步数据时先进行有效时间进行保存
|
|
|
+ initVideoCount(false, true)
|
|
|
+
|
|
|
+ // await updateStat()
|
|
|
+ videoIntervalRef.counter.value = 0
|
|
|
+ }, 10000)
|
|
|
+ })
|
|
|
/** 统计视频播放时间段 */
|
|
|
return () => (
|
|
|
<div id="playContent" class={styles.playContent}>
|
|
@@ -822,10 +845,16 @@ export default defineComponent({
|
|
|
activeData.model = true
|
|
|
videoIntervalRef.pause()
|
|
|
}}
|
|
|
- onEnded={() => {
|
|
|
+ onEnded={async () => {
|
|
|
const _index = popupData.activeIndex + 1
|
|
|
if (_index < data.itemList.length) {
|
|
|
handleSwipeChange(_index)
|
|
|
+ } else {
|
|
|
+ // 说明是最后一个
|
|
|
+ intervalFnRef.value.pause()
|
|
|
+ // 同步数据时先进行有效时间进行保存
|
|
|
+ initVideoCount(false, true)
|
|
|
+ await updateStat()
|
|
|
}
|
|
|
}}
|
|
|
onSeeked={() => {
|