index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class='product-bg'>
  3. <u-swiper :height="h" :list="imgUrls" @change="e => currentNum = e.current" :autoplay="true" :circular="true"
  4. indicatorStyle=" position: absolute;top: 10px !important;left: 10px !important;">
  5. <view slot="indicator" class="indicator-num">
  6. <text class="indicator-num__text">{{ currentNum + 1 }}/{{ imgUrls.length }}</text>
  7. </view>
  8. </u-swiper>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. imgUrls: {
  15. type: Array,
  16. default: function () {
  17. return [];
  18. }
  19. },
  20. videoline: {
  21. type: String,
  22. value: ""
  23. },
  24. h: {
  25. type: Number,
  26. default: function () {
  27. return 180;
  28. }
  29. }
  30. },
  31. data () {
  32. return {
  33. swiperTabList: ['https://yj-bucket-67ff.obs.cn-southwest-2.myhuaweicloud.com/upload/20230515/948f6d74dd7ccbcb3fc4c0d1e1282f9e.jpg', 'https://yj-bucket-67ff.obs.cn-southwest-2.myhuaweicloud.com/upload/20230522/6cf788d4130dd00c7a5ace07f302e99a.jpg'],
  34. indicatorDots: true,
  35. currentNum: 0,
  36. circular: true,
  37. autoplay: true,
  38. interval: 3000,
  39. duration: 500,
  40. currents: "1",
  41. controls: true,
  42. isPlay: true,
  43. videoContext: ''
  44. };
  45. },
  46. mounted () {
  47. console.log(this.imgUrls, 'imgUrls..........');
  48. if (this.videoline) {
  49. this.imgUrls.shift()
  50. }
  51. // #ifndef APP-PLUS
  52. this.videoContext = uni.createVideoContext('myVideo', this);
  53. // #endif
  54. },
  55. methods: {
  56. openImg (index) {
  57. uni.previewImage({
  58. current: index,
  59. urls: this.imgUrls,
  60. indicator: 'number',
  61. loop: true
  62. });
  63. },
  64. videoPause (e) {
  65. // #ifdef APP-PLUS
  66. this.isPlay = true
  67. this.autoplay = true
  68. // #endif
  69. },
  70. bindPause: function () {
  71. // #ifndef APP-PLUS
  72. this.videoContext.play();
  73. this.$set(this, 'controls', false)
  74. this.autoplay = false
  75. // #endif
  76. // #ifdef APP-PLUS
  77. this.isPlay = false
  78. this.videoContext = uni.createVideoContext('myVideo', this);
  79. this.videoContext.play();
  80. // #endif
  81. },
  82. change: function (e) {
  83. this.$set(this, 'currents', e.detail.current + 1);
  84. }
  85. }
  86. }
  87. </script>
  88. <style scoped lang="scss">
  89. .indicator {
  90. @include flex(row);
  91. justify-content: center;
  92. &__dot {
  93. height: 6px;
  94. width: 6px;
  95. border-radius: 100px;
  96. background-color: rgba(255, 255, 255, 0.35);
  97. margin: 0 5px;
  98. transition: background-color 0.3s;
  99. &--active {
  100. background-color: #ffffff;
  101. }
  102. }
  103. }
  104. .indicator-num {
  105. padding: 2px 0;
  106. background-color: rgba(0, 0, 0, 0.35);
  107. border-radius: 100px;
  108. width: 35px;
  109. @include flex;
  110. justify-content: center;
  111. &__text {
  112. color: #FFFFFF;
  113. font-size: 12px;
  114. }
  115. }
  116. </style>