123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <template>
- <view class="swiperContent">
- <swiper
- @change="change"
- @animationfinish="animationfinish"
- :indicator-dots="indicatorDots"
- :indicator-active-color="indicatorActiveColor"
- :indicator-color="indicatorColor"
- :autoplay="(autoplay && flag)"
- :current="current"
- :interval="interval"
- :duration="duration"
- :circular="circular"
- :vertical="vertical"
- :previous-margin="previousMargin"
- :next-margin="nextMargin"
- :display-multiple-items="displayMultipleItems"
- :skip-hidden-item-layout="skipHiddenItemLayout"
- :style="{'height':swiperHeight+'rpx'}"
- :class="(swiperType && displayMultipleItems ==1 && !vertical && !fullScreen)?'cardSwiper':'' "
- class="screen-swiper"
- >
- <swiper-item class="swiper-item"
- v-for="(item,index) in swiperList" :key="index"
- :class="(cardCur==index && displayMultipleItems ==1 && !vertical && !fullScreen)?'cur':''"
- >
- <view v-if="item[imageKey] && !item[videoKey]" @click.stop="clickItem(index)">
- <image :mode="mode" :src="item[imageKey]" :style="{'height':swiperHeight+'rpx'}"></image>
- </view>
- <view v-if="item[videoKey]" @click.stop="clickItem(index)">
- <video :src="item[videoKey]" @play="play" @pause="pause" :style="{'height':swiperHeight+'rpx'}" autoplay loop muted :autoplay="videoAutoplay" objectFit="cover"></video>
- </view>
- </swiper-item>
- </swiper>
- </view>
- </template>
- <script>
-
- import jump from '../../../core/routeJump.js';
-
- export default {
- name:'bw-swiper',
- props: {
- mode: {
- type: String,
- default: 'scaleToFill',
- },
- swiperHeight: {
- type: Number,
- default: 350
- },
- fullScreen:{ // 是否全屏
- type:Boolean,
- default:false
- },
- swiperList:{ // 滑块视图容器数据
- type:Array,
- default:function(){
- return []
- }
- },
- swiperType:{
- type:Boolean,
- default: false
- },
- videoAutoplay:{
- type:Boolean,
- default:false
- },
- videoKey:{
- type:String,
- default:'src'
- },
- imageKey:{
- type:String,
- default:'img'
- },
- skipHiddenItemLayout:{
- type:Boolean,
- default:false
- },
- displayMultipleItems:{
- type:Number,
- default:1
- },
- nextMargin:{
- type:String,
- default:'0px'
- },
- previousMargin:{
- type:String,
- default:'0px'
- },
- vertical:{
- type:Boolean,
- default:false
- },
- circular:{
- type:Boolean,
- default:true
- },
- duration:{
- type:Number,
- default:400
- },
- interval:{
- type:Number,
- default:2500
- },
- current:{
- type:Number,
- default:0
- },
- autoplay:{
- type:Boolean,
- default:true
- },
- indicatorColor:{
- type:String,
- default:'#CCCCCC'
- },
- indicatorActiveColor: {
- type: String,
- default: '#ffffff'
- },
- indicatorDots: {
- type: Boolean,
- default: true
- }
- },
- data() {
- return {
- flag:true,
- cardCur:0,
- }
- },
-
- methods: {
- play:function(){
- this.flag = false
- },
- pause:function(){
- this.flag = true
- },
- clickItem:function(index){
- console.log(index);
- if(this.swiperList.length>0){
- jump({open_type : this.swiperList[index].open_type, params: this.swiperList[index].params, page_url: this.swiperList[index].page_url});
- this.$emit('clickItem',this.swiperList[index]);
- }
- },
- change:function(e){
- this.$emit('change',e)
- },
- animationfinish:function(e){
- this.cardCur = e.detail.current;
- this.$emit('animationfinish',e)
- }
- },
-
- }
- </script>
- <style lang="scss">
- .cardSwiper .swiper-item{
- width:86%!important;
- overflow: initial;
- }
-
- .cardSwiper .swiper-item view{
- width: 100%;
- display: block;
- height: 100%;
- border-radius: 10upx;
- transform: scale(0.93,0.8);
- opacity: 0.7;
- transition: all 0.4s ease-in 0s;
- overflow: hidden;
- box-sizing: border-box;
- margin-left:8.1%;
- }
-
- .cardSwiper .cur view{
- transform: initial;
- opacity: 1;
- transition: all 0.4s ease-in 0s;
- }
- .swiper-item view{
- height:100%;
- width:100%;
- position: relative;
- }
- .swiperText{
- position: absolute;
- color:#ffffff;
- z-index:2;
- border-radius: 4upx;
- padding:0 4upx;
- }
- .screen-swiper image{
- width:100%;
- }
- .screen-swiper video,
- .swiper-item video {
- width: 100%;
- display: block;
- height: 100%;
- }
- .swiperContent{
- width:100%;
- }
- </style>
|