swiper-baner.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <view class="uni-padding-wrap">
  3. <view class="page-section swiper">
  4. <view class="page-section-spacing">
  5. <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="time" :duration="duration">
  6. <swiper-item v-for="(item, index) in imgList" :key="index" @click="itemClick(item)">
  7. <img :src="`http://192.168.3.45:9002${item.url}`" alt="" srcset="" />
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import { mapActions, mapState } from 'vuex'
  16. export default {
  17. props: {
  18. // 自动播放间隔
  19. time: { type: Number, default: 2000 }
  20. },
  21. computed: {
  22. ...mapState(['imgList'])
  23. },
  24. data() {
  25. return {
  26. // 指示点
  27. indicatorDots: true,
  28. // 自动播放
  29. autoplay: true,
  30. // 幻灯片切换时长(动画时长)
  31. duration: 500,
  32. };
  33. },
  34. async mounted() {
  35. console.log(123);
  36. await this.imgQuery();
  37. },
  38. methods: {
  39. ...mapActions(['imgQuery']),
  40. async itemClick(e) {
  41. let path;
  42. // 栏目
  43. if (e.type == 0) path = `pages/list/index?column=${e.column}`;
  44. // 单页
  45. if (e.type == 1) path = `pages/details/index?id=${e._id}`;
  46. // 链接
  47. if (e.type == 2) {
  48. location.href = e.url;
  49. return;
  50. }
  51. uni.navigateTo({ url: path });
  52. }
  53. },
  54. };
  55. </script>