This commit is contained in:
曹辉 2023-05-04 14:02:14 +08:00
parent 25860e2d18
commit ea7911bd77
4 changed files with 352 additions and 201 deletions

View File

@ -95,6 +95,8 @@
// //
tobuy() { tobuy() {
var that = this var that = this
const nurseStationId = uni.getStorageSync('nurseStationId');
if (nurseStationId) {
if (this.list.trainingOrderAmount > 0) { if (this.list.trainingOrderAmount > 0) {
let objs = { let objs = {
"openid": uni.getStorageSync('openid'), "openid": uni.getStorageSync('openid'),
@ -143,6 +145,14 @@
} }
}) })
} }
} else {
that.$refs.uToast.show({
title: '请您重新登录',
type: 'error',
duration: 1500,
url: "/pages/login/login"
})
}
}, },
} }
} }

View File

@ -1,6 +1,9 @@
<template> <template>
<view class="app" v-if="list"> <view class="app" v-if="list">
<image class="topimage" :src="baseurl + list.trainingItemPosterUrl" mode=""></image> <image class="topimage" v-if='!videoshow' :src="baseurl + list.trainingItemPosterUrl" mode=""></image>
<video class="topimage" id="video" v-if="videoshow" :src="baseurl+videoitem.itemDirectoryUrl"
@timeupdate='videotimeupdate' :initial-time='videoitem.watchTime' @error='videoerror' :custom-cache="false"
@play='videoplays' @pause='videopause' @ended='videoended'></video>
<view class="title"> <view class="title">
{{list.trainingItemTitle}} {{list.trainingItemTitle}}
</view> </view>
@ -22,30 +25,45 @@
<view class="" v-if="trainingOrderStatus=='PAY'"> <view class="" v-if="trainingOrderStatus=='PAY'">
<view class="play" @tap='videoplay(item)' <view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='NOT_WATCHED'?'background-color: #3D7DCA;color:#fff':''" :style="item.itemDirectoryWatchStatus=='NOT_WATCHED'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='NOT_WATCHED'"> v-if="item.itemDirectoryWatchStatus=='NOT_WATCHED'&&!item.videoshow">
开始播放 开始播放
</view> </view>
<view class="play"
:style="item.itemDirectoryWatchStatus=='NOT_WATCHED'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='NOT_WATCHED'&&item.videoshow">
播放中
</view>
<view class="play" @tap='videoplay(item)' <view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='WATCHED'?'background-color: #E3EAF5;color:#3D7DCA':''" :style="item.itemDirectoryWatchStatus=='WATCHED'?'background-color: #E3EAF5;color:#3D7DCA':''"
v-if="item.itemDirectoryWatchStatus=='WATCHED'"> v-if="item.itemDirectoryWatchStatus=='WATCHED'&&!item.videoshow">
继续播放 继续播放
</view> </view>
<view class="play"
:style="item.itemDirectoryWatchStatus=='WATCHED'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='WATCHED'&&item.videoshow">
播放中
</view>
<view class="play" @tap='videoplay(item)' <view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='FINISHED_READING'?'background-color: #E6E6E6;color:#76777B':''" :style="item.itemDirectoryWatchStatus=='FINISHED_READING'?'background-color: #E6E6E6;color:#76777B':''"
v-if="item.itemDirectoryWatchStatus=='FINISHED_READING'"> v-if="item.itemDirectoryWatchStatus=='FINISHED_READING'&&!item.videoshow">
已看完 已看完
</view> </view>
<view class="play"
:style="item.itemDirectoryWatchStatus=='FINISHED_READING'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='FINISHED_READING'&&item.videoshow">
播放中
</view>
</view> </view>
<view class="play" v-else @tap='novideoplay'> <view class="play" v-else @tap='novideoplay'>
开始播放 开始播放
</view> </view>
</view> </view>
</view> </view>
<u-popup v-model="videoshow" mode="center" closeable @close='videoshowfalse'> <!-- <u-popup v-model="videoshow" mode="center" closeable @close='videoshowfalse'>
<video id="video" v-if="videoshow" :src="baseurl+videoitem.itemDirectoryUrl" @timeupdate='videotimeupdate' <video id="video" v-if="videoshow" :src="baseurl+videoitem.itemDirectoryUrl" @timeupdate='videotimeupdate'
:initial-time='videoitem.watchTime' @error='videoerror' :custom-cache="false" :initial-time='videoitem.watchTime' @error='videoerror' :custom-cache="false"
@play='videoplays'></video> @play='videoplays'></video>
</u-popup> </u-popup> -->
<u-toast ref="uToast" /> <u-toast ref="uToast" />
</view> </view>
<view class="" v-else style="padding-top: 100rpx;"> <view class="" v-else style="padding-top: 100rpx;">
@ -100,24 +118,41 @@
}); });
}, },
methods: { methods: {
// //
videotimeupdate(e) { videoended(e) {
//e.detail.currentTimee.detail.duration this.videoContext.stop()
this.videoitem.watchTime = e.detail.currentTime
},
//
videoshowfalse() {
if (this.videoerroshow) { if (this.videoerroshow) {
if (this.videoitem.watchTime) { if (this.videoitem.watchTime) {
this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime) this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime)
} }
insertTrainingItemWatchRecord(this.videoitem).then(res => { insertTrainingItemWatchRecord(this.videoitem).then(res => {
this.videoitem.watchTime = 0 this.videoitem.watchTime = 0
this.info();
this.videoshow = false this.videoshow = false
this.videoitem = {
watchTime: 0
}
this.info();
}) })
} }
}, },
//
videotimeupdate(e) {
//e.detail.currentTimee.detail.duration
this.videoitem.watchTime = e.detail.currentTime
},
//
videopause() {
// if (this.videoerroshow) {
// if (this.videoitem.watchTime) {
// this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime)
// }
// insertTrainingItemWatchRecord(this.videoitem).then(res => {
// this.videoitem.watchTime = 0
// this.info();
// this.videoshow = false
// })
// }
},
// //
videoerror(e) { videoerror(e) {
this.$refs.uToast.show({ this.$refs.uToast.show({
@ -150,44 +185,76 @@
}); });
}, },
videoplay(item) { videoplay(item) {
if (this.videoContext) {
this.videoshow = false
this.videoContext.stop()
if (this.videoerroshow) {
if (this.videoitem.watchTime) {
this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime)
}
insertTrainingItemWatchRecord(this.videoitem).then(res => {
this.videoitem.watchTime = 0
})
}
}
uni.showLoading({
title: '获取视频中'
});
setTimeout(el => {
this.info();
this.videoerroshow = true this.videoerroshow = true
if (item.itemDirectoryUrl) { if (item.itemDirectoryUrl) {
if (!item.watchTime) { if (!item.watchTime) {
this.videoitem.watchTime = 0 this.videoitem.watchTime = 0
} }
this.videoitem = item this.list.trainingOrderItemDirectoryVOList.forEach(e => {
this.videoitem.trainingOrderId = this.list.trainingOrderId e.videoshow = false
this.videoitem.trainingItemId = this.list.trainingItemId })
this.videoitem.nurseStationPersonId = this.nurseStationPersonId item.trainingOrderId = this.list.trainingOrderId
this.videoitem.trainingItemTitle = this.list.trainingItemTitle item.trainingItemId = this.list.trainingItemId
this.videoitem.nursePersonName = uni.getStorageSync('nursePersonName') item.nurseStationPersonId = this.nurseStationPersonId
item.nursePersonName = uni.getStorageSync('nursePersonName')
item.trainingItemTitle = this.list.trainingItemTitle
if (item.itemDirectoryWatchStatus == 'WATCHED') { if (item.itemDirectoryWatchStatus == 'WATCHED') {
getTrainingItemWatchRecord(this.videoitem.trainingOrderId, this.videoitem.trainingItemId, this getTrainingItemWatchRecord(item.trainingOrderId, item.trainingItemId, item
.videoitem .trainingItemDirectoryId, item.nurseStationPersonId).then(res => {
.trainingItemDirectoryId, this.videoitem.nurseStationPersonId).then(res => {
if (res.code == 200) { if (res.code == 200) {
if (res.data.watchTime) { if (res.data.watchTime) {
this.videoitem.watchTime = res.data.watchTime item.watchTime = res.data.watchTime
this.videoitem.watchTime = this.formatsecond(this.videoitem.watchTime) item.watchTime = this.formatsecond(item.watchTime)
} }
} }
}) })
} }
this.videoitem = item
this.videoitem.videoshow = true
this.videoshow = true this.videoshow = true
this.videoContext = uni.createVideoContext('video', this) this.videoContext = uni.createVideoContext('video', this)
uni.hideLoading();
} else { } else {
this.$refs.uToast.show({ this.$refs.uToast.show({
title: '暂无视频', title: '暂无视频',
type: 'error', type: 'error',
duration: '2000' duration: '2000'
}) })
uni.hideLoading();
} }
}, 500)
}, },
info() { info() {
selectTrainingOrderVideoDetails(this.trainingItemId, this.trainingOrderNo, this.trainingOrderDetailsId) selectTrainingOrderVideoDetails(this.trainingItemId, this.trainingOrderNo, this.trainingOrderDetailsId)
.then( .then(
res => { res => {
this.list = res.data this.list = res.data
if (this.videoitem) {
this.list.trainingOrderItemDirectoryVOList.forEach(e => {
if (e.itemDirectoryCode == this.videoitem.itemDirectoryCode) {
e.videoshow = true
} else {
e.videoshow = false
}
})
}
}) })
}, },
//tabs //tabs

View File

@ -1,6 +1,9 @@
<template> <template>
<view class="app" v-if="list"> <view class="app" v-if="list">
<image class="topimage" :src="baseurl + list.trainingItemPosterUrl" mode=""></image> <image class="topimage" v-if='!videoshow' :src="baseurl + list.trainingItemPosterUrl" mode=""></image>
<video class="topimage" id="video" v-if="videoshow" :src="baseurl+videoitem.itemDirectoryUrl"
@timeupdate='videotimeupdate' :initial-time='videoitem.watchTime' @error='videoerror' :custom-cache="false"
@play='videoplays' @pause='videopause' @ended='videoended'></video>
<view class="title"> <view class="title">
{{list.trainingItemTitle}} {{list.trainingItemTitle}}
</view> </view>
@ -25,27 +28,39 @@
<view class="" v-if="item.trainingOrderStatus=='PAY'"> <view class="" v-if="item.trainingOrderStatus=='PAY'">
<view class="play" @tap='videoplay(item)' <view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='NOT_WATCHED'?'background-color: #3D7DCA;color:#fff':''" :style="item.itemDirectoryWatchStatus=='NOT_WATCHED'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='NOT_WATCHED'"> v-if="item.itemDirectoryWatchStatus=='NOT_WATCHED'&&!item.videoshow">
开始播放 开始播放
</view> </view>
<view class="play"
:style="item.itemDirectoryWatchStatus=='NOT_WATCHED'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='NOT_WATCHED'&&item.videoshow">
播放中
</view>
<view class="play" @tap='videoplay(item)' <view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='WATCHED'?'background-color: #E3EAF5;color:#3D7DCA':''" :style="item.itemDirectoryWatchStatus=='WATCHED'?'background-color: #E3EAF5;color:#3D7DCA':''"
v-if="item.itemDirectoryWatchStatus=='WATCHED'"> v-if="item.itemDirectoryWatchStatus=='WATCHED'&&!item.videoshow">
继续播放 继续播放
</view> </view>
<view class="play"
:style="item.itemDirectoryWatchStatus=='WATCHED'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='WATCHED'&&item.videoshow">
播放中
</view>
<view class="play" @tap='videoplay(item)' <view class="play" @tap='videoplay(item)'
:style="item.itemDirectoryWatchStatus=='FINISHED_READING'?'background-color: #E6E6E6;color:#76777B':''" :style="item.itemDirectoryWatchStatus=='FINISHED_READING'?'background-color: #E6E6E6;color:#76777B':''"
v-if="item.itemDirectoryWatchStatus=='FINISHED_READING'"> v-if="item.itemDirectoryWatchStatus=='FINISHED_READING'&&!item.videoshow">
已看完 已看完
</view> </view>
<view class="play"
:style="item.itemDirectoryWatchStatus=='FINISHED_READING'?'background-color: #3D7DCA;color:#fff':''"
v-if="item.itemDirectoryWatchStatus=='FINISHED_READING'&&item.videoshow">
播放中
</view> </view>
</view> </view>
</view> </view>
<u-popup v-model="videoshow" mode="center" closeable @close='videoshowfalse'> </view>
<video id="video" v-if="videoshow" :src="baseurl+videoitem.itemDirectoryUrl" @timeupdate='videotimeupdate' <!-- <u-popup v-model="videoshow" mode="center" closeable @close='videoshowfalse'>
:initial-time='videoitem.watchTime' @error='videoerror' :custom-cache="false" </u-popup> -->
@play='videoplays'></video>
</u-popup>
<u-toast ref="uToast" /> <u-toast ref="uToast" />
</view> </view>
<view class="" v-else style="padding-top: 100rpx;"> <view class="" v-else style="padding-top: 100rpx;">
@ -76,6 +91,7 @@
videoitem: { videoitem: {
watchTime: 0, watchTime: 0,
}, // }, //
videoContext: null,
videoerroshow: true, videoerroshow: true,
}; };
}, },
@ -96,24 +112,40 @@
plus.screen.lockOrientation("portrait-primary"); plus.screen.lockOrientation("portrait-primary");
}, },
methods: { methods: {
// //
videotimeupdate(e) { videoended(e) {
//e.detail.currentTimee.detail.duration this.videoContext.stop()
this.videoitem.watchTime = e.detail.currentTime
},
//
videoshowfalse() {
if (this.videoerroshow) { if (this.videoerroshow) {
if (this.videoitem.watchTime) { if (this.videoitem.watchTime) {
this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime) this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime)
} }
insertTrainingItemWatchRecord(this.videoitem).then(res => { insertTrainingItemWatchRecord(this.videoitem).then(res => {
this.videoitem.watchTime = 0 this.videoitem.watchTime = 0
this.info();
this.videoshow = false this.videoshow = false
this.videoitem = {
watchTime: 0
}
this.info();
}) })
} }
}, },
//
videotimeupdate(e) {
//e.detail.currentTimee.detail.duration
this.videoitem.watchTime = e.detail.currentTime
},
//
videopause() {
// if (this.videoerroshow) {
// if (this.videoitem.watchTime) {
// this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime)
// }
// insertTrainingItemWatchRecord(this.videoitem).then(res => {
// this.videoitem.watchTime = 0
// this.info();
// })
// }
},
// //
videoerror(e) { videoerror(e) {
this.videoerroshow = false this.videoerroshow = false
@ -139,42 +171,74 @@
}, },
// //
videoplay(item) { videoplay(item) {
if (this.videoContext) {
this.videoshow = false
this.videoContext.stop()
if (this.videoerroshow) {
if (this.videoitem.watchTime) {
this.videoitem.watchTime = this.formatSeconds(this.videoitem.watchTime)
}
insertTrainingItemWatchRecord(this.videoitem).then(res => {
this.videoitem.watchTime = 0
})
}
}
uni.showLoading({
title: '获取视频中'
});
setTimeout(el => {
this.info();
this.videoerroshow = true this.videoerroshow = true
if (item.itemDirectoryUrl) { if (item.itemDirectoryUrl) {
if (!item.watchTime) { if (!item.watchTime) {
this.videoitem.watchTime = 0 this.videoitem.watchTime = 0
} }
this.videoitem = item this.list.trainingItemDirectoryList.forEach(e => {
this.videoitem.trainingItemId = this.list.trainingItemId e.videoshow = false
this.videoitem.nurseStationPersonId = this.nurseStationPersonId })
this.videoitem.nursePersonName = uni.getStorageSync('nursePersonName') item.trainingItemId = this.list.trainingItemId
this.videoitem.trainingItemTitle = this.list.trainingItemTitle item.nurseStationPersonId = this.nurseStationPersonId
item.nursePersonName = uni.getStorageSync('nursePersonName')
item.trainingItemTitle = this.list.trainingItemTitle
if (item.itemDirectoryWatchStatus == 'WATCHED') { if (item.itemDirectoryWatchStatus == 'WATCHED') {
getTrainingItemWatchRecord(this.videoitem.trainingOrderId, this.videoitem.trainingItemId, this getTrainingItemWatchRecord(item.trainingOrderId, item.trainingItemId, item
.videoitem .trainingItemDirectoryId, item.nurseStationPersonId).then(res => {
.trainingItemDirectoryId, this.videoitem.nurseStationPersonId).then(res => {
if (res.code == 200) { if (res.code == 200) {
if (res.data.watchTime) { if (res.data.watchTime) {
this.videoitem.watchTime = res.data.watchTime item.watchTime = res.data.watchTime
this.videoitem.watchTime = this.formatsecond(this.videoitem.watchTime) item.watchTime = this.formatsecond(item.watchTime)
} }
} }
}) })
} }
this.videoitem = item
this.videoitem.videoshow = true
this.videoshow = true this.videoshow = true
this.videoContext = uni.createVideoContext('video', this) this.videoContext = uni.createVideoContext('video', this)
uni.hideLoading();
} else { } else {
this.$refs.uToast.show({ this.$refs.uToast.show({
title: '暂无视频', title: '暂无视频',
type: 'error', type: 'error',
duration: '2000' duration: '2000'
}) })
uni.hideLoading();
} }
}, 500)
}, },
info() { info() {
selectNurseAppletPersonTrainingItemDetailsList(this.trainingItemId, this.nurseStationPersonId).then( selectNurseAppletPersonTrainingItemDetailsList(this.trainingItemId, this.nurseStationPersonId).then(
res => { res => {
this.list = res.data this.list = res.data
if (this.videoitem) {
this.list.trainingItemDirectoryList.forEach(e => {
if (e.itemDirectoryCode == this.videoitem.itemDirectoryCode) {
e.videoshow = true
} else {
e.videoshow = false
}
})
}
}) })
}, },
novideo() { novideo() {

View File

@ -129,6 +129,8 @@
// //
tobuy() { tobuy() {
var that = this var that = this
const nurseStationId = uni.getStorageSync('nurseStationId');
if (nurseStationId) {
var obj = { var obj = {
"trainingItemId": undefined, "trainingItemId": undefined,
"nurseStationId": undefined, "nurseStationId": undefined,
@ -200,6 +202,14 @@
}) })
} }
}) })
} else {
that.$refs.uToast.show({
title: '请您重新登录',
type: 'error',
duration: 1500,
url: "/pages/login/login"
})
}
}, },
// //
buy() { buy() {