index.vue 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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"
  15. :autoplay="autoplay" :circular="circular" :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% " show-center-play-btn show-mute-btn="true" auto-pause-if-navigate :custom-cache="false"></video>
  19. <cover-view class="poster" v-if="controls">
  20. <cover-image class="image" :src="imgUrls[0]"></cover-image>
  21. </cover-view>
  22. <cover-view class="stop" v-if="controls" @tap="bindPause">
  23. <cover-image class="image" src="../../static/images/stop.png"></cover-image>
  24. </cover-view>
  25. </view>
  26. </swiper-item>
  27. <block v-for="(item,index) in imgUrls" :key='index'>
  28. <swiper-item>
  29. <image :src="item" class="slide-image"/>
  30. </swiper-item>
  31. </block>
  32. </swiper>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. props: {
  38. imgUrls: {
  39. type: Array,
  40. default: function(){
  41. return [];
  42. }
  43. },
  44. videoline:
  45. {
  46. type:String,
  47. value:""
  48. }
  49. },
  50. data() {
  51. return {
  52. indicatorDots: true,
  53. circular: true,
  54. autoplay: false,
  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. },
  69. change: function (e) {
  70. this.$set(this,'currents',e.detail.current + 1);
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped lang="scss">
  76. .product-bg{width:100%;height:750rpx;position:relative;}
  77. .product-bg swiper{width:100%;height:100%;position:relative;}
  78. .product-bg .slide-image{width:100%;height:100%;}
  79. .product-bg .pages{position:absolute;background-color:#fff;height:34rpx;padding:0 10rpx;border-radius:3rpx;right:30rpx;bottom:30rpx;line-height:34rpx;font-size:24rpx;color:#050505;}
  80. #myVideo{width: 100%;height: 100%}
  81. .product-bg .item{position:relative;width:100%;height:100%;}
  82. .product-bg .item .poster{position:absolute;top:0;left:0;height:750rpx;width:100%;z-index:9;}
  83. .product-bg .item .poster .image{width:100%;height:100%;}
  84. .product-bg .item .stop{position:absolute;top:50%;left:50%;width:136rpx;height:136rpx;margin-top:-68rpx;margin-left:-68rpx;z-index:9;}
  85. .product-bg .item .stop .image{width:100%;height:100%;}
  86. </style>