index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <a-card :title="title" :bordered="false">
  3. <a-carousel class="snowy-right-card-one" autoplay arrows>
  4. <template #prevArrow>
  5. <div class="custom-slick-arrow" style="left: 10px; z-index: 1">
  6. <LeftOutlined />
  7. </div>
  8. </template>
  9. <template #nextArrow>
  10. <div class="custom-slick-arrow" style="right: 10px"><RightOutlined /></div>
  11. </template>
  12. <img
  13. v-for="item in slideshowList"
  14. :key="item.id"
  15. :src="sysConfig.API_URL+item.image"
  16. class="carousel-images"
  17. @click="leaveForOpen(item.pathDetails)"
  18. />
  19. <a-empty v-if="isEmpty(slideshowList)" :image="Empty.PRESENTED_IMAGE_SIMPLE" />
  20. </a-carousel>
  21. </a-card>
  22. </template>
  23. <script setup name="carousel">
  24. import bizIndexApi from '@/api/biz/bizIndexApi'
  25. import sysConfig from "@/config";
  26. import { Empty } from 'ant-design-vue'
  27. import { isEmpty, cloneDeep } from 'lodash-es'
  28. import router from '@/router'
  29. const slideshowList = ref([])
  30. const title = ref('')
  31. // 外部传来的参数
  32. const props = defineProps({
  33. config: {
  34. type: Object,
  35. default: () => {}
  36. }
  37. })
  38. // 界面加载完后异步查询
  39. onMounted(() => {
  40. // 获得业务首页轮播图
  41. const param = {
  42. // 这是字典内维护的该位置
  43. place: props.config.options.place ? props.config.options.place : 'BACK_SYS_INDEX'
  44. }
  45. bizIndexApi
  46. .bizIndexSlideshowList(param)
  47. .then((data) => {
  48. slideshowList.value = data
  49. })
  50. .catch(() => {})
  51. })
  52. // URL跟路由的跳转
  53. const leaveForOpen = (value) => {
  54. if (isEmpty(value)) {
  55. return
  56. }
  57. const detail = cloneDeep(value)
  58. let result = {}
  59. if (typeof detail !== 'object') {
  60. result = JSON.parse(detail)
  61. }
  62. // json内包含且是开启了点击,否则不处理
  63. if (result.whetherToClick && result.whetherToClick === 'ENABLE') {
  64. if (result.skipMode && result.skipMode === 'URL') {
  65. window.open(result.url)
  66. }
  67. if (result.skipMode && result.skipMode === 'ROUTER') {
  68. router.replace({
  69. path: result.url
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped>
  76. .carousel-images {
  77. height: 180px;
  78. width: 100%;
  79. cursor: pointer;
  80. }
  81. .snowy-right-card-one {
  82. height: 180px;
  83. }
  84. .ant-carousel :deep(.slick-slide) {
  85. text-align: center;
  86. height: 180px;
  87. line-height: 150px;
  88. background: #1890ff;
  89. overflow: hidden;
  90. }
  91. .ant-carousel :deep(.slick-arrow.custom-slick-arrow) {
  92. width: 25px;
  93. height: 25px;
  94. font-size: 25px;
  95. color: #fff;
  96. background-color: rgba(31, 45, 61, 0.11);
  97. opacity: 0.3;
  98. z-index: 1;
  99. }
  100. .ant-carousel :deep(.custom-slick-arrow:before) {
  101. display: none;
  102. }
  103. .ant-carousel :deep(.custom-slick-arrow:hover) {
  104. opacity: 0.5;
  105. }
  106. .ant-carousel :deep(.slick-slide h3) {
  107. color: #fff;
  108. }
  109. :deep(.ant-card-body) {
  110. padding: 0 !important;
  111. }
  112. </style>