123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <template>
- <view class="swiperContent">
- <swiper
- @change="change"
- @animationfinish="animationfinish"
- :current="current"
- :interval="interval"
- :duration="duration"
- :circular="circular"
- :vertical="vertical"
- :previous-margin="previousMargin"
- :next-margin="nextMargin"
- :autoplay="(autoplay && flag)"
- :style="{'height':swiperHeight+'px'}"
- :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 class="swiper-box" v-if="item[imageKey] && !item[videoKey]">
- <image :src="item[imageKey]"></image>
- <view class="swiperText">
- <view class="swiperText_name">{{item.name}}</view>
- <view>可享受商品折扣: {{item.discount}}%</view>
- <view class="flex disdiscount_box" v-if="item.is_clear == false && item.task_list.length > 1">
- <view class="" v-for="ls in item.task_list">
- <view class="task_name">{{ls.number}}</view>
- <view v-if="">{{ls.real_name}}</view>
- </view>
- </view>
- <view class="disdiscount_box" v-if="item.is_clear == false && item.task_list.length == 1">
- <view class="" v-for="ls in item.task_list">
- <view class="task_name">{{ls.number}}</view>
- <view v-if="">{{ls.name}}</view>
- </view>
- </view>
- <view class="is_clear" v-if="item.is_clear == true">该会员等级尚未解锁</view>
- </view>
- </view>
- <view v-if="item[videoKey]">
- <video :src="item[videoKey]" @play="play" @pause="pause" :style="{'height':swiperHeight+'px'}" autoplay loop muted :autoplay="videoAutoplay" objectFit="cover"></video>
- </view>
- </swiper-item>
- <swiper-item class="swiper-item" v-if="swiperList.length==0" >
- <text></text>
- </swiper-item>
- </swiper>
- </view>
- </template>
- <script>
- export default {
- name:'bw-swiper',
- created:function(){
- var that = this;
- if(this.fullScreen){
- uni.getSystemInfo({
- success:function(e){
- that.swiperHeight = e.screenHeight -44
- }})
- }
- },
- mounted:function(){
- if(!this.fullScreen){
- const query = uni.createSelectorQuery().in(this);
- query.select('.swiper-item').boundingClientRect(data => {
- this.swiperHeight = data.width/this.w_h;
- }).exec();
- }
- },
- props: {
- fullScreen:{
- type:Boolean,
- default:false
- },
- swiperList:{
- type:Array,
- required: true,
- default:function(){
- return []
- }
- },
- swiperType:{
- type:Boolean,
- default:true
- },
- videoAutoplay:{
- type:Boolean,
- default:false
- },
- videoKey:{
- type:String,
- default:'src'
- },
- imageKey:{
- type:String,
- default:'image'
- },
- textKey:{
- type:String,
- default:'name'
- },
- displayMultipleItems:{
- type:Number,
- default:1
- },
- textTip:{
- type:Boolean,
- default:true
- },
- textStyleSize:{
- type:Number,
- default:45
- },
- textStyleTop:{
- type:Number,
- default:2
- },
- textStyleLeft:{
- type:Number,
- default:5
- },
- textStyleColor:{
- type:String,
- default:'#ffffff'
- },
- textStyleBgcolor:{
- type:String,
- default:'transparent'
- },
- w_h:{
- type:Number,
- default:2
- },
- 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:false
- },
- indicatorDots: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- flag:true,
- cardCur:0,
- swiperHeight:300
- }
- },
- computed:{
-
- },
- methods: {
- play:function(){
- this.flag = false
- },
- pause:function(){
- this.flag = true
- },
-
-
-
-
-
-
-
- change:function(e){
- this.$emit('change',e.detail.current)
-
- },
- animationfinish:function(e){
- this.cardCur = e.detail.current;
- this.$emit('animationfinish',e)
- }
- }
- }
- </script>
- <style lang="scss">
- .swiperContent{
- background-color: #232323;
- }
- .cardSwiper .swiper-item{
- .swiper-box{
- display: block;
- transform: scale(0.93,0.8);
- opacity: 0.7;
- transition: all 0.1s ease-in 0s;
- overflow: hidden;
- box-sizing: border-box;
- height:100%;
- position: relative;
- width:86%!important;
- overflow: initial;
- padding: 25rpx 0rpx;
- margin-left: 8%;
- transform: initial;
- opacity: 1;
- transition: all 0.1s ease-in 0s;
- image{
- width: 100%;
- height: 100%;
- border-radius: 10upx;
- }
- }
- }
- .swiperText{
- width: 100%;
- height: 100%;
- position: absolute;
- color:#ffffff;
- z-index:2;
- padding: 45rpx 25rpx;
- top:0;
- color: rgb(255, 255, 255);
- font-size: 28rpx;
- .swiperText_name{
- font-size: 45rpx;
- font-weight: bold;
- padding-bottom: 10rpx;
- }
- .disdiscount_box{
- padding: 45rpx 45rpx;
- text-align: center;
- }
- }
- .task_name{
- font-size: 45rpx;
- }
- .is_clear{
- padding-top: 65rpx;
- }
- .swiperContent{
- width:100%;
- }
- </style>
|