提交 faa9b92c 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 示例项目swiper-vertical-video的样式为全屏

上级 3a1ae1ea
<template> <template>
<view class="page"> <view class="page">
<view class="header-tips" style="padding: 10px;">
<text class="tip-text">当前示例为无限滚动、加载、浏览视频的短视频模板的演示,提供了组件复用的方式。为提高性能可见的视频项只有 3 个</text>
<view class="tip-status-box">
<text class="status-text">播放状态:</text>
<text class="status-text" v-for="(value,index) in state">第{{index+1}}个:{{value?'播放中':'已暂停'}}</text>
</view>
</view>
<swiper class="swiper" :current="current" :circular="index != 0" :vertical="true" @change="onSwiperChange" @transition="onTransition"> <swiper class="swiper" :current="current" :circular="index != 0" :vertical="true" @change="onSwiperChange" @transition="onTransition">
<swiper-item class="swiper-item" v-for="(item,i) in visibleList" :key="i"> <swiper-item class="swiper-item" v-for="(item,i) in visibleList" :key="i">
<video :ref="'video-'+i" class="video" :id="item._id" :src="item.src" :poster="item.poster_src" :show-center-play-btn="false" :autoplay="false" :controls="false" :loop="true" @play="onPlay(i)" @pause="onPause(i)"></video> <video :ref="'video-'+i" class="video-box" :id="item._id" :src="item.src" :poster="item.poster_src" :show-center-play-btn="false" :autoplay="false" :controls="false" :loop="true" @play="onPlay(i)" @pause="onPause(i)"></video>
<view class="video-top-view" @click="changeState(i)"> <view class="video-cover" @click="changeState(i)">
<image v-if="!state[i]" class="play-btn" src="/static/template/swiper-vertical-video/play.png" mode="widthFix"></image> <image v-if="!state[i]" class="play-btn" src="/static/template/swiper-vertical-video/play.png" mode="widthFix"></image>
</view> </view>
<view class="video-info"> <view class="video-info">
<text class="video-info-text">容器:第 {{i}} 个</text> <text class="video-info-text">容器:第 {{i}} 个</text>
<text class="video-info-text">内容:{{item.content}}</text> <text class="video-info-text">内容:{{item.content}}</text>
</view> </view>
<view class="swiper-item-info">
<text class="info-text">向上滑动查看下一个视频</text>
</view>
</swiper-item> </swiper-item>
</swiper> </swiper>
<view class="debug-info">
<text class="status-text">debug-info 播放状态:</text>
<text class="status-text" v-for="(value,index) in state">第{{index+1}}个:{{value?'播放中':'已暂停'}}</text>
</view>
</view> </view>
</template> </template>
<script> <script>
...@@ -32,12 +25,6 @@ ...@@ -32,12 +25,6 @@
export default { export default {
components: {}, components: {},
computed: {
currentVideo() : VideoNode {
console.log('"video-"+this.current', "video-" + this.current);
return this.$refs["video-" + this.current] as VideoNode
}
},
data() { data() {
return { return {
list: [] as ListItem[], list: [] as ListItem[],
...@@ -103,8 +90,8 @@ ...@@ -103,8 +90,8 @@
} }
}, },
doPlay(index : number) { doPlay(index : number) {
console.log("doPlay video-" + index,this.$refs["video-" + index]);
(this.$refs["video-" + index] as VideoNode).play() (this.$refs["video-" + index] as VideoNode).play()
console.log("doPlay video-" + index);
}, },
doPause(index : number) { doPause(index : number) {
(this.$refs["video-" + index] as VideoNode).pause() (this.$refs["video-" + index] as VideoNode).pause()
...@@ -126,9 +113,9 @@ ...@@ -126,9 +113,9 @@
});*/ });*/
let videoUrlList = [ let videoUrlList = [
'https://web-assets.dcloud.net.cn/unidoc/zh/video/uts.mp4', 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/video/uts.mp4',
'https://web-assets.dcloud.net.cn/unidoc/zh/video/uni-ai.mp4', 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/video/uni-ai.mp4',
'https://web-assets.dcloud.net.cn/unidoc/zh/video/uni-verify.mp4' 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/video/uni-verify.mp4'
] as string[] ] as string[]
let posterSrcList = [ let posterSrcList = [
...@@ -163,107 +150,59 @@ ...@@ -163,107 +150,59 @@
<style> <style>
.page { .page {
width: 750rpx;
flex: 1; flex: 1;
/* width: 750rpx; */
}
.header-tips {
margin: 10px;
padding: 10px;
background-color: #fff;
border-radius: 5px;
}
.tip-text {
font-size: 14px;
color: #666;
line-height: 18px;
}
.tip-status-box {
margin-top: 10px;
}
.status-text {
font-size: 14px;
color: #666;
} }
.swiper, .swiper,
.swiper-item, .swiper-item,
.video, .video-box,
.video-top-view,
.video-cover { .video-cover {
height: 750rpx; width:750rpx;
}
.swiper {
flex: 1; flex: 1;
margin: 0 10px; height: 100%;
margin-bottom: 15px;
background-color: #fff;
border-radius: 5px;
/* border: 1px solid #000; */
} }
.swiper-item { .swiper-item {
flex: 1;
/* border: 1px solid red; */
padding: 10px;
position: relative; position: relative;
} }
.video {} .video-box {
width: 750rpx;
}
.video-top-view { .video-cover {
position: absolute; position: absolute;
top: 0;
left: 0;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
align-content: center; align-content: center;
/* border: 1px solid red; */
flex: 1;
width: 750rpx;
} }
.video-info { .play-btn {
margin-top: 10px; width: 30px;
height: 30px;
color: #FFF;
} }
.swiper-item-info { .video-info {
position: absolute; position: absolute;
bottom: 15px; bottom: 0;
left: 0; padding: 15px;
right: 0;
flex-direction: row;
justify-content: center;
} }
.info-text {
font-size: 12px;
color: #999;
}
.video-info-text { .video-info-text {
font-size: 14px; font-size: 14px;
color: #666; color: red;
line-height: 20px; line-height: 20px;
} }
.play-btn { .debug-info{
width: 30px; position: fixed;
height: 30px; top:15px;
color: #FFF;
}
.video-cover {
position: absolute;
width: 750rpx; width: 750rpx;
top: 0; }
left: 0; .status-text{
color:red;
padding: 15px;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册