移动端返回
This commit is contained in:
@@ -3,7 +3,7 @@ layout("/mobile/platform.html"){
|
||||
#-->
|
||||
|
||||
<script src="https://cdn-go.cn/cdn/vod-js-sdk-v6/latest/vod-js-sdk-v6.js"></script>
|
||||
<link href="https://web.sdk.qcloud.com/player/tcplayer/release/v4.3.0/tcplayer.min.css" rel="stylesheet"/>
|
||||
<link href="https://web.sdk.qcloud.com/player/tcplayer/release/v4.3.0/tcplayer.min.css" rel="stylesheet" />
|
||||
<!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.vx.x.x.min.js 之前引入 hls.min.x.xx.xm.js。-->
|
||||
<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.3.0/libs/hls.min.0.13.2m.js"></script>
|
||||
<!--播放器脚本文件-->
|
||||
@@ -11,7 +11,7 @@ layout("/mobile/platform.html"){
|
||||
|
||||
<style>
|
||||
#app {
|
||||
background: #FFFFFF;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.video-container {
|
||||
@@ -57,41 +57,24 @@ layout("/mobile/platform.html"){
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<van-nav-bar
|
||||
title=""
|
||||
left-arrow
|
||||
placeholder
|
||||
fixed
|
||||
@click-left="window.history.back()"
|
||||
></van-nav-bar>
|
||||
<van-nav-bar title="" left-arrow placeholder fixed @click-left="pjaxReplace('/mobile/index')"></van-nav-bar>
|
||||
|
||||
<div class="video-container">
|
||||
<video v-if="isPlay" id="player-container-id" preload="auto" playsinline
|
||||
webkit-playsinline>
|
||||
</video>
|
||||
|
||||
<van-image
|
||||
v-else
|
||||
style="width: 100%;height: 100%"
|
||||
:src="FILE_DOMAIN+'/fileStreamPreview?id='+albumInfo.cover"
|
||||
></van-image>
|
||||
<video v-if="isPlay" id="player-container-id" preload="auto" playsinline webkit-playsinline></video>
|
||||
|
||||
<van-image v-else style="width: 100%; height: 100%" :src="FILE_DOMAIN+'/fileStreamPreview?id='+albumInfo.cover"></van-image>
|
||||
</div>
|
||||
|
||||
<van-tabs v-model="tabIndex" sticky>
|
||||
<van-tab title="介绍">
|
||||
<div style="height: 5px;background-color: #f6f7f9"></div>
|
||||
<div style="height: 5px; background-color: #f6f7f9"></div>
|
||||
|
||||
<div style="padding: 16px">
|
||||
{{albumInfo.title}}
|
||||
</div>
|
||||
<div style="padding: 16px">{{albumInfo.title}}</div>
|
||||
|
||||
<div style="height: 5px;background-color: #f6f7f9"></div>
|
||||
<div style="height: 5px; background-color: #f6f7f9"></div>
|
||||
|
||||
<van-cell class="descriptionCell">
|
||||
<template #title>
|
||||
@@ -101,29 +84,20 @@ layout("/mobile/platform.html"){
|
||||
<div class="album-description" v-html="albumInfo.description"></div>
|
||||
</template>
|
||||
</van-cell>
|
||||
|
||||
</van-tab>
|
||||
<van-tab title="目录">
|
||||
<div style="height: 5px;background-color: #f6f7f9"></div>
|
||||
<div style="height: 5px; background-color: #f6f7f9"></div>
|
||||
|
||||
<van-cell-group class="video-list">
|
||||
<van-cell v-for="(o,i) in videoList" @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>
|
||||
{{getWatchStatus(o)}}
|
||||
<span style="margin-right: 10px">{{i+1}}.</span>
|
||||
<span>{{o.title}}</span>
|
||||
</template>
|
||||
<template #label>{{getWatchStatus(o)}}</template>
|
||||
<template>
|
||||
<span v-if="o.id === currentVideo.id">
|
||||
播放中
|
||||
</span>
|
||||
<span v-if="o.id === currentVideo.id">播放中</span>
|
||||
</template>
|
||||
</van-cell>
|
||||
</van-cell-group>
|
||||
@@ -137,15 +111,13 @@ layout("/mobile/platform.html"){
|
||||
<!-- </van-cell>-->
|
||||
<!-- </van-tab>-->
|
||||
</van-tabs>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
let player = null
|
||||
|
||||
const vue = new Vue({
|
||||
el: '#app',
|
||||
el: "#app",
|
||||
mixins: [mobileMixins],
|
||||
data() {
|
||||
return {
|
||||
@@ -160,17 +132,15 @@ layout("/mobile/platform.html"){
|
||||
watchRecordList: [],
|
||||
lastTime: 0,
|
||||
isPlay: false
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getVideoInfo() {
|
||||
const {data} = await $.get('/mobile/trainEducation/getVideoList', {albumId: this.albumId})
|
||||
const { data } = await $.get("/mobile/trainEducation/getVideoList", { albumId: this.albumId })
|
||||
this.videoList = data
|
||||
|
||||
},
|
||||
async getAlbumInfo() {
|
||||
const {data} = await $.get('/mobile/trainEducation/getAlbumInfo', {id: this.albumId})
|
||||
const { data } = await $.get("/mobile/trainEducation/getAlbumInfo", { id: this.albumId })
|
||||
this.albumInfo = data
|
||||
},
|
||||
//播放视频
|
||||
@@ -178,19 +148,18 @@ layout("/mobile/platform.html"){
|
||||
this.isPlay = true
|
||||
this.currentVideo = o
|
||||
|
||||
this.$nextTick(()=>{
|
||||
this.$nextTick(() => {
|
||||
if (!player) {
|
||||
player = TCPlayer('player-container-id', {})
|
||||
player = TCPlayer("player-container-id", {})
|
||||
}
|
||||
player.src(o.mediaUrl)
|
||||
})
|
||||
|
||||
|
||||
// await this.addWatchRecord()
|
||||
await this.getMyWatchRecord()
|
||||
|
||||
//接着上次继续看
|
||||
const v = this.watchRecordList.find(v => v.videoId === o.id)
|
||||
const v = this.watchRecordList.find((v) => v.videoId === o.id)
|
||||
if (v) {
|
||||
this.lastTime = v.watchDuration
|
||||
setTimeout(() => {
|
||||
@@ -211,14 +180,14 @@ layout("/mobile/platform.html"){
|
||||
|
||||
//快进 快退
|
||||
playSeeked() {
|
||||
player.on('seeked', () => {
|
||||
player.on("seeked", () => {
|
||||
this.lastTime = player.currentTime()
|
||||
this.addWatchRecord()
|
||||
})
|
||||
},
|
||||
playTimeUpdate() {
|
||||
this.lastTime = player.currentTime()
|
||||
player.on('timeupdate', () => {
|
||||
player.on("timeupdate", () => {
|
||||
const nowTime = player.currentTime()
|
||||
if (nowTime - this.lastTime > 5) {
|
||||
this.lastTime = nowTime
|
||||
@@ -227,16 +196,16 @@ layout("/mobile/platform.html"){
|
||||
})
|
||||
},
|
||||
playPause() {
|
||||
player.on('pause', () => {
|
||||
player.on("pause", () => {
|
||||
this.addWatchRecord()
|
||||
})
|
||||
},
|
||||
|
||||
playEnd() {
|
||||
player.on('ended', () => {
|
||||
player.on("ended", () => {
|
||||
this.addWatchRecord()
|
||||
this.getMyWatchRecord()
|
||||
const currentIndex = this.videoList.findIndex(v => v.id === this.currentVideo.id)
|
||||
const currentIndex = this.videoList.findIndex((v) => v.id === this.currentVideo.id)
|
||||
const nextVideo = this.videoList[currentIndex + 1]
|
||||
if (nextVideo) {
|
||||
this.playVideo(nextVideo)
|
||||
@@ -254,12 +223,12 @@ layout("/mobile/platform.html"){
|
||||
currentTime: parseInt(player.currentTime()),
|
||||
albumId: this.currentVideo.albumId
|
||||
}
|
||||
await $.post('/mobile/trainEducation/addWatchRecord', params)
|
||||
await $.post("/mobile/trainEducation/addWatchRecord", params)
|
||||
},
|
||||
//监听页面关闭 隐藏
|
||||
watchPage() {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (document.visibilityState === "hidden") {
|
||||
if (player && this.currentVideo) {
|
||||
this.addWatchRecord()
|
||||
}
|
||||
@@ -267,18 +236,18 @@ layout("/mobile/platform.html"){
|
||||
})
|
||||
},
|
||||
async getMyWatchRecord() {
|
||||
const {data} = await $.get('/mobile/trainEducation/getMyWatchRecord')
|
||||
const { data } = await $.get("/mobile/trainEducation/getMyWatchRecord")
|
||||
this.watchRecordList = data
|
||||
},
|
||||
getWatchStatus(video) {
|
||||
const v = this.watchRecordList.find(v => v.videoId === video.id)
|
||||
const v = this.watchRecordList.find((v) => v.videoId === video.id)
|
||||
if (!v) {
|
||||
return '学习进度:还未开始学习'
|
||||
return "学习进度:还未开始学习"
|
||||
}
|
||||
if (v.videoId === this.currentVideo.id) {
|
||||
return '学习进度:正在学习中'
|
||||
return "学习进度:正在学习中"
|
||||
}
|
||||
const percentage = (parseInt((v.watchDuration / (video.fileDuration - 1)).toFixed(2) * 100)) + "%"
|
||||
const percentage = parseInt((v.watchDuration / (video.fileDuration - 1)).toFixed(2) * 100) + "%"
|
||||
return "学习进度:" + percentage
|
||||
}
|
||||
},
|
||||
@@ -291,7 +260,6 @@ layout("/mobile/platform.html"){
|
||||
this.getVideoInfo()
|
||||
this.getMyWatchRecord()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user