s-image-banner.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!-- 装修图文组件:图片轮播 -->
  2. <template>
  3. <su-swiper
  4. :list="imgList"
  5. :dotStyle="data.indicator === 'dot' ? 'long' : 'tag'"
  6. imageMode="scaleToFill"
  7. dotCur="bg-mask-40"
  8. :seizeHeight="300"
  9. :autoplay="data.autoplay"
  10. :interval="data.interval * 1000"
  11. :mode="data.type"
  12. :height="px2rpx(data.height)"
  13. />
  14. </template>
  15. <script setup>
  16. import { computed } from 'vue';
  17. import sheep from '@/common';
  18. // 轮播图
  19. const props = defineProps({
  20. data: {
  21. type: Object,
  22. default: () => ({}),
  23. },
  24. styles: {
  25. type: Object,
  26. default: () => ({}),
  27. },
  28. });
  29. function px2rpx(px) {
  30. //计算比例
  31. let scale = uni.upx2px(100)/100;
  32. return px/scale
  33. }
  34. const imgList = computed(() =>
  35. props.data.items.map((item) => {
  36. const src = item.type === 'img' ? item.imgUrl : item.videoUrl;
  37. return {
  38. ...item,
  39. type: item.type === 'img' ? 'image' : 'video',
  40. src: sheep.$url.cdn(src),
  41. poster: sheep.$url.cdn(item.imgUrl),
  42. };
  43. }),
  44. );
  45. </script>
  46. <style></style>