index.vue 2.8 KB

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