【前端】印包客app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.8 KiB

<template>
<view class="group_1">
<swiper :current="swiperCurrent" @change="changeSwiper" class="swiper">
<swiper-item v-for="(item, index) in list" :key="index">
<image mode="aspectFit" v-if="item.type == 'image'" :src="item.url" class="image" @click="preview(item.url)" />
<view v-if="item.type == 'video'" class="video-area">
<image mode="aspectFit" @click="playVideo(index)" v-show="showIndex != index" :src="item.imageUrl" class="image" />
<view>
<video v-if="showIndex == index" autoplay :src="item.url" class="video"></video>
</view>
</view>
</swiper-item>
</swiper>
<!-- <image @click="shareFactory" src="/static/imgs/general/share-gray-icon.png" class="image_1" /> -->
<view class="flex-col items-center text-wrapper">
<text>{{ swiperCurrent + 1 }}/{{ list.length }}</text>
</view>
<image v-if="showClose" @click="closeVideo()" class="video-close" src="/static/imgs/promotion/video-close.png"></image>
</view>
</template>
<script>
export default {
props: {
/**
* @property {Array<Object>} list - banner列表
* @property {String} list.type - banner类型, image:图片,video:视频
* @property {String} list.url - banner图片地址
* @property {String} list.imageUrl - banner视频封面地址
*/
list: {
type: Array,
default: () => []
}
},
data() {
return {
swiperCurrent: 0,
showIndex: null,
showClose: false
}
},
methods: {
changeSwiper(e) {
this.swiperCurrent = e.detail.current
},
playVideo(index) {
this.showClose = true
this.showIndex = index
},
closeVideo() {
this.showIndex = null
this.showClose = false
},
preview(url) {
let urls = []
for (let item of this.list) {
if (item.type == 'image') {
urls.push(item.url)
}
}
uni.previewImage({
current: url,
urls: urls
})
},
shareFactory() {
this.$emit('share')
}
}
}
</script>
<style lang="scss" scoped>
.group_1 {
color: rgb(255, 255, 255);
font-size: 28rpx;
line-height: 40rpx;
white-space: nowrap;
position: relative;
height: 440rpx;
width: 750rpx;
.swiper {
height: 440rpx;
width: 750rpx;
}
.image {
width: 750rpx;
height: 440rpx;
background-color: rgb(0, 0, 0);
}
.video-area {
width: 100%;
height: 100%;
position: relative;
.video {
width: 750rpx;
height: 440rpx;
}
}
.text-wrapper {
position: absolute;
right: 20rpx;
bottom: 62rpx;
background-color: rgba(0, 0, 0, 0.4);
border-radius: 20rpx;
width: 64rpx;
}
}
/** 定制关闭 */
.video-close {
position: fixed;
bottom: 260rpx;
right: 32rpx;
width: 66rpx;
height: 66rpx;
z-index: 9999;
}
</style>