This commit is contained in:
2024-03-28 17:28:49 +08:00
parent b62cb70255
commit 75ee36d1bc
2 changed files with 48 additions and 1 deletions

View File

@ -79,7 +79,7 @@
}
} else {
uni.navigateTo({
url: `/pagesC/noticedetails/noticedetails?item=${JSON.stringify(item)}&title=${this.title}`
url: `/pagesC/noticedetails/noticedetails?item=${JSON.stringify(item)}&title=${this.title}&videoId=${item.videoId}`
})
}
},

View File

@ -11,6 +11,8 @@
</view>
<view class="" style="height: 2rpx;width: 100%;background-color: #f6f6f6;">
</view>
<video v-if="videoId" id="myVideo" @timeupdate="videoFun" :src="videoId" :initial-time="initial_time"
@ended='ended' />
<view class="text">
<text>{{currentItem.content}}</text>
</view>
@ -18,11 +20,15 @@
</template>
<script>
import baseurl from '@/api/baseurl.js'
export default {
data() {
return {
currentItem: '',
title: '',
videoId: null,
video_real_time: 0, //
nitial_time: '', //
};
},
onReady() { //
@ -31,14 +37,55 @@
});
},
onLoad(options) {
this.initial_time = '0' //
this.title = options.title
this.currentItem = JSON.parse(options.item)
if (options.videoId) {
this.videoId = baseurl + `/applet/message/preview/${options.videoId}`
}
},
methods: {
ended(e) {
console.log(e)
},
videoFun(e) {
var isReady = 1; // 1
// initial-time
let that = this;
//
var duration = e.detail.duration
//
var currentTime = parseInt(e.detail.currentTime)
//
// console.log("" + currentTime + "")//
if (that.video_real_time == 0) {
var jump_time = parseInt(that.initial_time) + parseInt(that.video_real_time)
} else {
var jump_time = parseInt(that.video_real_time)
}
if (isReady == 1) {
if (currentTime > jump_time && currentTime - jump_time > 3) {
let videoContext = wx.createVideoContext('myVideo')
videoContext.seek(that.video_real_time)
wx.showToast({
title: '未完整看完该视频,不能快进',
icon: 'none',
duration: 2000,
})
}
}
that.video_real_time = currentTime //
}
}
}
</script>
<style lang="scss">
.app {
#myVideo {
width: 100%;
}
.text {
font-size: 24rpx;
line-height: 40rpx;