index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <!-- <view class='product-bg'>
  3. <swiper :indicator-dots="indicatorDots"
  4. :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration" @change="change">
  5. <block v-for="(item,index) in imgUrls" :key="index">
  6. <swiper-item>
  7. <image :src="item" class="slide-image"/>
  8. </swiper-item>
  9. </block>
  10. </swiper>
  11. <view class='pages'>{{currents}}/{{imgUrls.length || 1}}</view>
  12. </view> -->
  13. <view class='product-bg'>
  14. <swiper :indicator-dots="indicatorDots" indicator-active-color="#e93323" :autoplay="autoplay" :circular="circular"
  15. :interval="interval" :duration="duration" @change="change">
  16. <swiper-item v-if="videoline">
  17. <view class="item">
  18. <video id="myVideo" :src='videoline' objectFit="cover" controls style="width:100%;height:100% "
  19. show-center-play-btn show-mute-btn="true" auto-pause-if-navigate :custom-cache="false"></video>
  20. <view class="poster" v-if="controls">
  21. <image class="image" :src="imgUrls[0]"></image>
  22. </view>
  23. <view class="stop" v-if="controls" @tap="bindPause">
  24. <image class="image" src="../../static/images/stop.png"></image>
  25. </view>
  26. </view>
  27. </swiper-item>
  28. <block v-for="(item,index) in imgUrls" :key='index'>
  29. <swiper-item>
  30. <image :src="item" class="slide-image" />
  31. </swiper-item>
  32. </block>
  33. </swiper>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. props: {
  39. imgUrls: {
  40. type: Array,
  41. default: function() {
  42. return [];
  43. }
  44. },
  45. videoline: {
  46. type: String,
  47. value: ""
  48. }
  49. },
  50. data() {
  51. return {
  52. indicatorDots: true,
  53. circular: true,
  54. autoplay: true,
  55. interval: 3000,
  56. duration: 500,
  57. currents: "1",
  58. controls: true
  59. };
  60. },
  61. mounted() {
  62. this.videoContext = uni.createVideoContext('myVideo', this);
  63. },
  64. methods: {
  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: 750rpx;
  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>