绿满眶商城微信小程序-uniapp
xiangpei
6 天以前 70738d032bd80f5b13075f8a13045ff4de57c2c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
  <!-- 轮播图 -->
  <view class="carousel">
 
    <swiper circular="true" duration="400" @change="swiperChange">
      <swiper-item v-if='video'>
        <!-- #ifndef APP-PLUS -->
        <video class="video" show-mute-btn style="width:100%; height:100%;" muted autoplay :src='video' loop
          object-fit="cover"></video>
        <!-- #endif -->
        <!-- #ifdef APP-PLUS -->
        <view style="width:100%; height:100%;">
          <!-- <video class="video" show-mute-btn style="width:100%; height:100%;" muted autoplay :src='video' loop
              object-fit="cover"></video> -->
          <view v-html="html" style="width:100%; height:100%;"></view>
        </view>
        <!-- #endif -->
 
      </swiper-item>
      <swiper-item class="swiper-item" v-for="(item, index) in res" :key="index">
 
        <view class="image-wrapper">
          <u-image :src="item" mode="aspectFit" class="loaded" width="100%" height="100%">
            <u-loading slot="loading"></u-loading>
          </u-image>
        </view>
      </swiper-item>
    </swiper>
    <view class="swiper-dots">{{ current }}/{{ video ? res.length + 1 : res.length }}</view>
  </view>
</template>
<script>
import '@/components/uview-components/uview-ui';
    
export default {
  data() {
    return {
      current: 1,
      html: ""
    };
  },
  props: ["res", 'video'],
  watch: {
    video(val) {
      this.html = '<video muted="muted"   ref="videoPlay" style="width:100%; height:100%;" src=' + val + '  page-gesture show-mute-btn   autoplay  webkit-playsinline="" playsinline="" ></video>'
    }
  },
  methods: {
    // 轮播图对应的dot
    swiperChange(e) {
      this.current = e.detail.current + 1;
    },
  },
  mounted() {
    console.log(this.video)
  }
};
</script>
<style lang="scss" scoped>
.carousel {
  // #ifdef MP-WEIXIN
  margin-top: 44px;
  // #endif
  width: 750rpx;
  height: 750rpx;
  position: relative;
 
  swiper {
    height: 100%;
  }
 
  .image-wrapper {
    width: 100%;
    height: 100%;
  }
 
  .swiper-item {
    display: flex;
    justify-content: center;
    align-content: center;
    height: 750rpx;
    overflow: hidden;
 
    image {
      width: 100%;
      height: 100%;
    }
  }
 
  position: relative;
 
  .swiper-dots {
    position: absolute;
    right: 0rpx;
    bottom: 40rpx;
    font-size: 32rpx;
    width: 107rpx;
    height: 44rpx;
    line-height: 44rpx;
    text-align: center;
    border-radius: 30rpx 0rpx 0rpx 30rpx;
    background: #333333;
    opacity: 0.4;
    font-weight: 400;
    color: #fff;
  }
}
 
/deep/ .image-wrapper image {
  opacity: 1 !important;
}
 
.video {
  width: 100%;
  height: 100%;
}
</style>