index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class='product-bg'>
  3. <swiper :indicator-dots="indicatorDots" indicator-active-color="#e93323" :autoplay="autoplay"
  4. :circular="circular" :interval="interval" :duration="duration" @change="change">
  5. <!-- 视频 -->
  6. <swiper-item v-if="videoline">
  7. <view class="item">
  8. <view v-show="!controls" style="width:100%;height:100% ">
  9. <video id="myVideo" :src='videoline' objectFit="cover" controls style="width:100%;height:100% "
  10. show-center-play-btn show-mute-btn="true" auto-pause-if-navigate :custom-cache="false"
  11. :enable-progress-gesture="false" :poster="imgUrls[0]" @pause="videoPause"></video>
  12. </view>
  13. <view class="poster" v-show="controls">
  14. <image class="image" :src="imgUrls[0]"></image>
  15. </view>
  16. <view class="stop" v-show="controls" @tap="bindPause">
  17. <image class="image" src="../../static/images/stop.png"></image>
  18. </view>
  19. </view>
  20. </swiper-item>
  21. <!-- 图片 -->
  22. <block v-for="(item,index) in imgUrls" :key='index'>
  23. <swiper-item>
  24. <image :src="item" class="slide-image" />
  25. </swiper-item>
  26. </block>
  27. </swiper>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. props: {
  33. imgUrls: {
  34. type: Array,
  35. default: function() {
  36. return [];
  37. }
  38. },
  39. videoline: {
  40. type: String,
  41. value: ""
  42. }
  43. },
  44. data() {
  45. return {
  46. indicatorDots: true,
  47. circular: true,
  48. autoplay: true,
  49. interval: 3000,
  50. duration: 500,
  51. currents: "1",
  52. controls: true,
  53. isPlay:true,
  54. videoContext:''
  55. };
  56. },
  57. mounted() {
  58. if (this.videoline) {
  59. this.imgUrls.shift()
  60. }
  61. },
  62. methods: {
  63. videoPause(e){
  64. },
  65. bindPause: function() {
  66. this.videoContext.play();
  67. this.$set(this, 'controls', false)
  68. this.autoplay = false
  69. },
  70. change: function(e) {
  71. this.$set(this, 'currents', e.detail.current + 1);
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. .product-bg {
  78. width: 100%;
  79. height: 975rpx;
  80. position: relative;
  81. }
  82. .product-bg swiper {
  83. width: 100%;
  84. height: 100%;
  85. position: relative;
  86. }
  87. .product-bg .slide-image {
  88. width: 100%;
  89. height: 100%;
  90. }
  91. .product-bg .pages {
  92. position: absolute;
  93. background-color: #fff;
  94. height: 34rpx;
  95. padding: 0 10rpx;
  96. border-radius: 3rpx;
  97. right: 30rpx;
  98. bottom: 30rpx;
  99. line-height: 34rpx;
  100. font-size: 24rpx;
  101. color: #050505;
  102. }
  103. #myVideo {
  104. width: 100%;
  105. height: 100%
  106. }
  107. .product-bg .item {
  108. position: relative;
  109. width: 100%;
  110. height: 100%;
  111. }
  112. .product-bg .item .poster {
  113. position: absolute;
  114. top: 0;
  115. left: 0;
  116. height: 750rpx;
  117. width: 100%;
  118. z-index: 9;
  119. }
  120. .product-bg .item .poster .image {
  121. width: 100%;
  122. height: 100%;
  123. }
  124. .product-bg .item .stop {
  125. position: absolute;
  126. top: 50%;
  127. left: 50%;
  128. width: 136rpx;
  129. height: 136rpx;
  130. margin-top: -68rpx;
  131. margin-left: -68rpx;
  132. z-index: 9;
  133. }
  134. .product-bg .item .stop .image {
  135. width: 100%;
  136. height: 100%;
  137. }
  138. </style>