integrated_traffic_uniapp/pages/application/onlinexxks/temp-study-video.vue

160 lines
3.9 KiB
Vue
Raw Normal View History

2024-01-16 17:24:49 +08:00
<template>
<view >
<cu-custom ref="cuCustom" bgColor="bg-gradual-blueness" :isBack="true" :isRingt="true" :backUrl="backUrl">
<block slot="backText">返回</block>
<block slot="content">学习详细</block>
</cu-custom>
<video v-if="movie.poster" id="coursewareVideo" style="width: 100%;" :src="movie.src" :poster="movie.poster" :show-progress="false"
:enable-progress-gesture="false" direction="-90" @play="onPlayerPlay($event)"
@pause="onPlayerPause($event)" @ended="onPlayerEnded($event)"></video>
<view class="sdetail">
<view class="tcl_box" >
<view class="tcl_item">
<view class="sleft">
<text class=" cuIcon-videofill mr10 text-grey"></text>
<text class="text-title">{{pd.COURSEWARENAME}}</text>
</view>
</view>
</view>
<view class="cu-tabbar-height"></view>
</view>
</view>
</template>
<script>
import {
basePath,
corpinfoId,
baseImgPath,
loginUser
} from '@/common/tool.js';
export default {
data() {
return {
baseImgPath: baseImgPath,
backUrl: '/pages/application/onlinexxks/my-tasks',
loading: false,
noClick: true,
COURSEWARE_ID:'',
TEMPSTUDYUSERS_ID: '',
pd: {}, // 数据,
movie: {
'id': 0,
'title': '课件名称',
'src': '', //视频地址
'poster':'', //封面地址
'actors': '主讲人',
'desc': '课件简介'
},
isPaused: false,
}
},
async onLoad(event) {
this.TEMPSTUDYUSERS_ID = event.TEMPSTUDYUSERS_ID
this.COURSEWARE_ID = event.COURSEWARE_ID
await this.getData()
this.$forceUpdate()
},
methods: {
getData() {
return new Promise((resolve, reject) => {
var _this = this;
uni.showLoading({
title: '请稍候'
})
uni.request({
url: basePath + '/app/courseware/getVideoCourseware',
method: 'POST',
dataType: 'json',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: {
VIDEOCOURSEWARE_ID: this.COURSEWARE_ID,
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: (res) => {
if ("success" == res.data.result) {
uni.hideLoading();
_this.pd = res.data.pd;
this.getPlayInfo(_this.pd.VIDEOFILES)
} else {
uni.showToast({
icon: 'none',
title: res.data.message,
duration: 2000
});
}
resolve(true)
}
})
})
},
studyVideo(){
uni.request({
url: basePath + '/app/tempstudy/edit',
method: 'POST',
dataType: 'json',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: {
TEMPSTUDYUSERS_ID: this.TEMPSTUDYUSERS_ID,
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
}
})
},
// 监听播放
onPlayerPlay(player) {
this.studyVideo()
this.isPaused = false
},
// 监听暂停
onPlayerPause(player) {
this.isPaused = true
},
onPlayerEnded(player) {
this.isPaused = true
// localStorage.setItem('currentTime' + this.currentCoursewareID, 0)
this.playTime = 0
this.currentTime = 0
},
getPlayInfo(videoId) {
return new Promise((resolve, reject) => {
uni.request({
url: basePath + 'app/audioOrVideo/getPlayInfo',
method: 'POST',
dataType: 'json',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: {
videoId: videoId,
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: (res) => {
if (res.data != '') {
this.movie.poster = res.data.COVERURL
this.movie.src = res.data.PLAYURL
}
resolve(true)
}
})
})
},
BackPage() {
uni.redirectTo({
url: '/pages/application/onlinexxks/my-curriculum',
})
}
}
}
</script>
<style>
</style>