Front-end Vue custom carousel video playback component imitates Jingdong product details carousel video video playback effect can be previewed

The front-end Vue custom carousel video playback component imitates Jingdong product details carousel video video playback, and can preview pictures. To download the complete code, please visit the uni-app plug-in market address: https://ext.dcloud.net.cn/plugin ?id=13325

The renderings are as follows:

 

format,png

format,png

format,png

format,png

format,png

 

# cc-videoSwiper

#### Instructions

```How to use

<!-- goodsData: carousel video data @setShowVideo: video button click event -->

<cc-videoSwiper :goodsData="goodsData" @setShowVideo="setShowVideo"></cc-videoSwiper>

```

#### HTML code implementation part

```html

<template>

<view class="content">

<!-- goodsData: carousel video data @setShowVideo: video button click event -->

<cc-videoSwiper :goodsData="goodsData" @setShowVideo="setShowVideo"></cc-videoSwiper>

<!-- Preview video pop-up window -->

<view class="mask" v-if="showVideo == true" @touchmove.stop.prevent="ondefault" @click="hideShow">

<view class="close">

<image src="/static/images/goods/close.png"></image>

</view>

</view>

<view class="previewvideo" v-if="showVideo == true">

<view class="videos">

<video class="nowvideos" id="nowVideo" v-if="showVideo == true" :src="goodsData.videos"

:autoplay="showVideo" :show-center-play-btn="true" :show-mute-btn="true"

:show-fullscreen-btn="false"></video>

</view>

</view>

<!-- used to carry the H5 preview video -->

<view style="position: absolute;top: -999upx;left: -999upx;">

<video ref="newVideo" id="newVideo" :src="goodsData.videos" :autoplay="showVideo"

:show-center-play-btn="false" :show-mute-btn="true" :show-fullscreen-btn="false"

@fullscreenchange="hideShow"></video>

</view>

</view>

</template>

<script>

export default {

data() {

return {

goodsData: {

videos: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',

imgList: [

"https://cdn.pixabay.com/photo/2016/08/11/23/48/mountains-1587287_1280.jpg",

'https://cdn.pixabay.com/photo/2016/11/14/04/45/elephant-1822636_1280.jpg',

'https://cdn.pixabay.com/photo/2018/08/12/15/29/hintersee-3601004_1280.jpg',

'https://cdn.pixabay.com/photo/2017/05/09/03/46/alberta-2297204_1280.jpg'

],

},

showVideo: false,

newVideo: null

}

},

onLoad() {

this.newVideo = uni.createVideoContext('newVideo');

},

methods: {

//operation video

setShowVideo(showVideo, isH5) {

this.showVideo = showVideo

if (isH5 == true) {

this.newVideo.play()

}

console.log('Video click to play');

},

// close the video

hideShow() {

this.showVideo = false

},

}

}

</script>

<style lang="scss" scoped>

.content {

display: flex;

flex-direction: column;

}

/* preview video popup window */

.mask {

width: 100%;

height: 100vh;

position: fixed;

top: 0;

left: 0;

background-color: rgba(0, 0, 0, .8);

z-index: 200;

}

.previewvideo {

width: 100vw;

height: 100vw;

position: fixed;

top: 50%;

left: 0;

transform: translateY(-50%);

background-color: #000;

z-index: 900;

opacity: 1;

}

.close {

display: flex;

align-content: center;

align-items: flex-end;

position: absolute;

top: 140upx;

right: 20upx;

z-index: 900;

image {

width: 50upx;

height: 50upx;

display: block;

justify-content: center;

margin-left: 30upx;

margin-bottom: 20upx;

border-radius: 50%;

padding: 10upx;

background-color: rgba(0, 0, 0, 0.2);

}

}

.videos {

height: 100vw;

width: 100vw;

z-index: 10;

position: relative;

video {

width: 100%;

height: 100%;

}

}

.nowvideos {

width: 100%;

height: 100%;

margin: 0 auto;

}

</style>

```

 

 

 

Guess you like

Origin blog.csdn.net/chenchuang0128/article/details/131548402