deming/pageB/video/video.nvue
2020-08-09 11:31:47 +08:00

208 lines
5.6 KiB
Plaintext

<template>
<view>
<video id="videoId" :style="videoSize" :src="src" autoplay="true" :loop="true" :show-fullscreen-btn="false" @play="playing"
:show-play-btn="false" controls="false" @click="stoping" :enable-progress-gesture="false"></video>
<cover-image class="close" @click="goBack" src="../../static/close.png">
</cover-image>
<cover-view class="" src="../../static/videoPlay.png">
</cover-view>
<cover-view class="info-box">
<view class="video-info-box">
<image class="image-play" src="../../static/videoPlay.png" mode=""></image>
<text class="video-slip">视频</text>
<text class="time">{{ time_count }}s</text>
</view>
<view>
<text class="name">@{{ list.member_nickname }}</text>
</view>
<view>
<text class="title">{{ list.article_title }}</text>
</view>
<view>
<text class="centent">{{ list.article_content }}</text>
</view>
<view class="label-box">
<block v-for="(item,index) in list.label" :key="index">
<text class="label" :style="{ width: item.name.length * 40 + 'rpx' }">{{ item.name }}</text>
</block>
</view>
</cover-view>
</view>
</template>
<script>
export default {
data() {
return {
videoSize: {},
list: {},
src: "",
is_play: true,
timer: null,
alltime: 7,
time_count: 7,
};
},
onLoad(option) {
this.getVideoInfo(option.id);
this.getInfo();
this.aaa();
},
onReady() {
this.videoBox = uni.createVideoContext("videoId", this);
},
methods: {
// 获取信息
getVideoInfo(article_id) {
uni.request({
url: "https://dmmall.sdbairui.com/api/article/articleInfo",
method: "POST",
data: {
article_id: article_id
},
success: (res) => {
this.list = res.data.data.info;
this.src = res.data.data.info.video_path;
}
})
},
// 获取手机信息
getInfo() {
uni.getSystemInfo({
success: (res) => {
this.videoSize = {
width: "750rpx",
height: res.screenHeight + "px"
}
}
})
},
// 播放
playing(e) {
console.log(e);
if (e.type == "play") {
this.alltime = 7;
this.time_count = 7;
this.aaa();
}
},
// 暂停
stoping() {
this.is_play = !this.is_play;
if (this.is_play) {
this.videoBox.play();
this.aaa();
} else {
this.videoBox.pause();
clearInterval(this.timer);
this.temp_time = this.time_count;
console.log(this.temp_time);
}
},
// 倒计时
aaa() {
this.timer = setInterval(() => {
if (this.time_count > 0 && this.time_count <= this.alltime) {
this.time_count--;
} else {
clearInterval(this.timer);
this.timer = null;
}
}, 1000);
},
goBack() {
uni.navigateBack({
delta: 1
})
}
}
}
</script>
<style>
/* 关闭 */
.close {
position: fixed;
top: 80rpx;
right: 60rpx;
width: 30rpx;
height: 30rpx;
}
/* 底部信息 */
.info-box {
position: fixed;
bottom: 0;
left: 0;
padding: 30rpx;
}
.video-info-box {
flex-direction: row;
align-items: center;
width: 160rpx;
height: 40rpx;
padding: 4rpx 10rpx;
margin-bottom: 20rpx;
color: #666666;
border-radius: 10rpx;
background-color: rgba(255, 255, 255, .6);
}
.image-play {
width: 22rpx;
height: 20rpx;
margin-right: 10rpx;
}
.video-slip {
color: #666;
font-size: 24rpx;
margin-right: 20rpx;
}
.time {
color: #666;
font-size: 24rpx;
}
.name {
color: #fff;
font-size: 36rpx;
margin-bottom: 20rpx;
}
.title {
color: #fff;
font-size: 26rpx;
margin-bottom: 20rpx;
}
.centent {
width: 500rpx;
color: #fff;
font-size: 28rpx;
margin-bottom: 20rpx;
lines: 2;
text-overflow: ellipsis;
}
.label-box {
flex-direction: row;
}
.label {
lines: 3;
width: 100rpx;
height: 40rpx;
padding: 4rpx 10rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
font-size: 26rpx;
text-align: center;
color: #666666;
border-radius: 10rpx;
background-color: rgba(255, 255, 255, .6);
}
</style>