作者 张晓杰

培训课程播放视频,证照管理路由修改

... ... @@ -53,12 +53,14 @@
"quill": "1.3.7",
"screenfull": "5.0.2",
"sortablejs": "1.10.2",
"video.js": "^8.16.1",
"vue": "2.6.12",
"vue-count-to": "1.0.13",
"vue-cropper": "0.5.5",
"vue-meta": "2.4.0",
"vue-pdf": "^4.3.0",
"vue-router": "3.4.9",
"vue-video-player": "^5.0.2",
"vuedraggable": "2.24.3",
"vuex": "3.6.0",
"xml-js": "1.6.11"
... ...
... ... @@ -38,6 +38,10 @@ import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData'
// import VideoPlayer from 'vue-video-player'
// // import 'vue-video-player/src/custom-theme.css'
// import 'video.js/dist/video-js.css'
// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
... ... @@ -62,6 +66,7 @@ Vue.component('ImagePreview', ImagePreview)
Vue.use(directive)
Vue.use(plugins)
Vue.use(VueMeta)
// Vue.use(VideoPlayer)
DictData.install()
/**
... ...
... ... @@ -102,19 +102,31 @@ export const constantRoutes = [
]
},
{
path: '/contract/compliancemanagement/orginfoCertificate',
path: '/system/orginfo/orginfoCertificate',
component: Layout,
hidden: true,
children: [
{
path: 'orginfoCertificate/index',
component: () => import('@/views/compliancemanagement/orginfoCertificate/index'),
component: () => import('@/views/system/orginfo/orginfoCertificate/index'),
name: 'orginfoCertificate',
meta: { title: '证照管理', icon: '' }
}
]
},
{
path: '/compliance/compliancemanagement/compliancetraining',
component: Layout,
hidden: true,
children: [
{
path: 'trainingcourse/play',
component: () => import('@/views/compliancemanagement/compliancetraining/trainingcourse/play'),
name: 'orginfoCertificate',
meta: { title: '培训课程', icon: '' }
}
]
}
// /contract/compliancemanagement/orginfoCertificate
]
// 动态路由,基于用户权限动态去加载
... ...
... ... @@ -107,6 +107,11 @@
@click="handleDelete(scope.row)"
v-hasPermi="['system:trainingcourse:remove']"
>删除</el-button>
<el-button
size="mini"
type="text"
@click="handlePlayer(scope.row)"
>播放视频</el-button>
</template>
</el-table-column>
</el-table>
... ... @@ -229,13 +234,17 @@ export default {
id: [
{ required: true, message: "不能为空", trigger: "blur" }
]
}
},
};
},
created() {
this.getList();
},
methods: {
//视频播放
handlePlayer(){
this.$router.push({ path: '/compliance/compliancemanagement/compliancetraining/trainingcourse/play'});
},
/** 查询【请填写功能名称】列表 */
getList() {
this.loading = true;
... ...
<template>
<div class="info">
<div class="container">
<div class="play">
<el-row>
<el-col :span="24">
<video-player
id="video"
class="video-player vjs-custom-skin"
ref="videoPlayer"
@ended="videoEnded"
@timeupdate="videoTimeUp"
@loadeddata="videoLoaded"
@seeking="videoSeeking"
@seeked="videoSeeked"
:events="['seeking', 'seeked']"
:playsinline="true"
:options="playerOptions"
></video-player>
<!-- <h3 id="text-progress">{{ this.progress }}</h3> -->
</el-col>
<!-- <el-col :span="6" class="text"> -->
<!-- </el-col> -->
</el-row>
</div>
</div>
</div>
</template>
<script>
import Vue from 'vue'
import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
Vue.use(VideoPlayer)
export default {
data() {
return {
classHour : [],
data : [],
userId :'',
videoInformation : [],
progress : '0.00%',
durationTime : '' ,// 视频总时常
currentTime : '' ,// 当前播放进度时长
saveDurationTime : '', // 视频总时常
saveCurrentTime:'', // 当前播放进度时长
isShowSubs: false,
recodrTime :null,
playerOptions:{
playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
autoplay: false, //如果true,浏览器准备好时开始回放。
muted: false, // 默认情况下将会消除任何音频。
loop: false, // 导致视频一结束就重新开始。
preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
language: 'zh-CN',
aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
sources: [
{
type: 'video/mp4', //这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目
src: 'http://vjs.zencdn.net/v/oceans.mp4' //url地址
}
],
poster: '', //你的封面地址
// width: document.documentElement.clientWidth, //播放器宽度
notSupportedMessage: '此视频暂无法播放,请稍后再试', //允许覆盖Video.js无法播放媒体源时显示的默认信息。
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //全屏按钮
}
}
}
},
created() {
},
methods: {
// 视频信息加载完成,获取总时长,若接口返回进度,断点播放
videoLoaded(item) {
this.durationTime = item.cache_.duration
this.videoInformation = item
// console.log('progress', this.progress)
if (this.progress > '0.00%') {
item.currentTime(Number(this.currentTime))
}
// console.log('视频信息videoLoaded:', this.videoInformation)
},
// 当前播放进度
videoTimeUp(item) {
this.currentTime = item.cache_.currentTime
this.progress = ((this.currentTime.toFixed(2) / item.cache_.duration.toFixed(2)) * 100).toFixed(2) + '%'
// console.log('当前播放进度', item)
},
// 正在拖动
videoSeeking(item) {
// console.log('正在拖动',item)
this.isSeeking = true
},
// 拖动结束
videoSeeked(item) {
// console.log('拖动结束',item)
this.isSeeking = false
},
// 点击播放
videoPlay() {
//清除定时器
if (this.pauseTimer) {
clearTimeout(this.pauseTimer)
}
},
// 触发暂停
videoPause(item) {
//利用定时器延迟
this.pauseTimer = setTimeout(() => {
if (this.isVideoEnd) return
if (this.isSeeking) return
// 展示蒙层
this.isShowSubs = true
}, 100)
},
// 播放结束
videoEnded() {
this.isVideoEnd = true
}
}
}
</script>
<style lang="scss" scoped>
$width: 1140px;
.info {
width: 100%;
}
.container {
width: $width;
margin: auto;
.breadcrumb {
padding-top: 20px;
padding-bottom: 20px;
}
.play {
box-shadow: 0 4px 8px 0 rgba(28, 31, 33, 0.1);
background-color: #26262b;
.text {
font-size: 15px;
color: #fff;
text-align: left;
.title {
padding: 12px 15px;
}
.teacher {
padding: 12px 0 12px 10px;
background: #2d2d2d;
}
.list {
height: 393px;
width: 283px;
.name1 {
cursor: pointer;
background: #2d2d2d;
font-size: 15px;
padding: 10px 0 10px 47px;
margin-top: 2px;
}
.name2 {
cursor: pointer;
color: rgb(61, 231, 112);
background: #2d2d2d;
font-size: 15px;
padding: 10px 0 10px 47px;
margin-top: 2px;
}
}
}
}
// .biref {
// box-shadow: 0 4px 8px 0 rgba(28, 31, 33, 0.1);
// background-color: #ffffff;
// font-size: 15px;
// text-align: left;
// color: #5e5e5e;
// padding: 25px 20px;
// margin: 30px 0;
// img {
// vertical-align: middle;
// margin-right: 5px;
// }
// }
}
</style>
<style>
body {
background-color: #f7f9fc !important;
/* background-color: #d7e4f7 !important; */
}
.vjs-custom-skin > .video-js .vjs-big-play-button {
width: 70px;
border-radius: 50%;
}
.el-breadcrumb__inner {
color: #2c3e50 !important;
}
.el-scrollbar__wrap {
overflow: hidden;
position: relative;
}
</style>
\ No newline at end of file
... ...
... ... @@ -198,9 +198,8 @@ export default {
},
methods: {
toOrginfoCertificateList(row){
console.log('row=====',row)
this.$router.push({ path: '/contract/compliancemanagement/orginfoCertificate/orginfoCertificate/index', query: {orgcode: row.orgcode }});
},
this.$router.push({ path: '/system/orginfo/orginfoCertificate/orginfoCertificate/index', query: {orgcode: row.orgcode }});
},
/** 查询【请填写功能名称】列表 */
getList() {
this.loading = true;
... ...
... ... @@ -304,7 +304,7 @@ export default {
methods: {
//根据单位编号查询列表
getorgcode(orgcode){
console.log(orgcode)
// console.log(orgcode)
selectByOrgnCode(orgcode).then(response =>{
console.log(response.data)
this.orginfoCertificateList = response.data
... ...