NurseStationPersonAppletUl/pages/Ordervideolearning/Ordervideolearning.vue
2023-04-26 14:38:43 +08:00

165 lines
5.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="app" v-if="list">
<image class="topimage" :src="baseurl + list.trainingItemPosterUrl" mode=""></image>
<view class="title">
{{list.trainingItemTitle}}
</view>
<view class="border"></view>
<u-tabs :list="tablist" :is-scroll="false" :current="tabcurrent" @change="change" font-size='34' bar-height='3'>
</u-tabs>
<view class="detail" v-if="tabcurrent==0">
{{list.trainingItemDetails}}
</view>
<view class="directory" v-if="tabcurrent==1">
<view class="item" v-for="(item,index) in list.trainingOrderItemDirectoryVOList" :key="index">
<view class="text">
<span class='DirectoryName'>{{item.itemDirectoryName}}</span>
<span class='texttitle'>{{item.itemDirectoryTitle}}</span>
</view>
<view class="Introduce">
{{item.itemDirectoryIntroduce}}
</view>
<view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='NOT_WATCHED'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='NOT_WATCHED'">
开始播放
</view>
<view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='WATCHED'?'background-color: #E3EAF5;color:#3D7DCA':''"
v-if="item.itemDirectoryWatchStatus=='WATCHED'">
继续播放
</view>
<view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='FINISHED_READING'?'background-color: #E6E6E6;color:#76777B':''"
v-if="item.itemDirectoryWatchStatus=='FINISHED_READING'">
已看完
</view>
</view>
</view>
<u-popup v-model="videoshow" mode="center" closeable @close='videoshowfalse'>
<view>
<video v-if="videoshow" :src="baseurl+videoitem.itemDirectoryUrl" @timeupdate='videotimeupdate'
:initial-time='videoitem.watchTime'></video>
</view>
</u-popup>
</view>
</template>
<script>
import baseurl from '@/api/baseurl.js'
import {
selectTrainingOrderVideoDetails,
insertTrainingItemWatchRecord,
getTrainingItemWatchRecord
} from '@/api/Ordervideolearning/index.js'
export default {
data() {
return {
list: undefined,
baseurl: undefined,
nurseStationPersonId: undefined,
tabcurrent: 0, //tabsindex
tablist: [{ //tabs的list
name: '详情'
}, {
name: '目录'
}],
trainingItemId: undefined, //上个页面id
trainingOrderNo: undefined, //上个页面orderno
videoshow: false, //视频开关
videoitem: {
watchTime: 0,
}, //视频对象
};
},
methods: {
//播放进度变化
videotimeupdate(e) {
//e.detail.currentTime是已经播放了多久e.detail.duration是该视频多长
this.videoitem.watchTime = e.detail.currentTime
},
//关闭播放弹出框
videoshowfalse() {
this.videoitem.watchTime = '00:00:01'
// this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime)
insertTrainingItemWatchRecord(this.videoitem).then(res => {
this.videoitem.watchTime = 0
this.info();
this.videoshow = false
})
},
//视频播放
videoplay(item) {
if (!item.watchTime) {
this.videoitem.watchTime = 0
}
this.videoitem = item
this.videoitem.trainingOrderId = this.list.trainingOrderId
this.videoitem.trainingItemId = this.list.trainingItemId
this.videoitem.nurseStationPersonId = this.nurseStationPersonId
if (item.itemDirectoryWatchStatus == 'WATCHED') {
getTrainingItemWatchRecord(this.videoitem.trainingOrderId, this.videoitem.trainingItemId, this
.videoitem
.trainingItemDirectoryId, this.videoitem.nurseStationPersonId).then(res => {
if (res.code == 200) {
if (res.data.watchTime) {
this.videoitem.watchTime = res.data.watchTime
this.videoitem.watchTime = this.formatsecond(this.videoitem.watchTime)
}
}
})
}
this.videoshow = true
},
info() {
selectTrainingOrderVideoDetails(this.trainingItemId, this.trainingOrderNo).then(
res => {
this.list = res.data
})
},
//点击tabs
change(index) {
this.tabcurrent = index;
},
//时分秒转秒
formatsecond(value) {
value = value.split(':')
value.forEach(e => {
e = Number(e)
})
value[0] = value[0] * 24 * 60
value[1] = value[1] * 60
value = value[0] + value[1] + value[2]
return value
},
//秒转时分秒
formatSeconds(value) {
let result = parseInt(value)
let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result /
60 % 60));
let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
let res = '';
res += `${h}:`;
res += `${m}:`;
res += `${s}`;
return res;
},
},
onLoad(options) {
const that = this
this.baseurl = baseurl
this.trainingItemId = options.trainingItemId
this.trainingOrderNo = options.trainingOrderNo
this.info();
const value = uni.getStorageSync('nursePersonId');
if (value) {
that.nurseStationPersonId = value
} else {}
},
}
</script>
<style lang="scss">
@import "./Ordervideolearning.scss";
</style>