imageCube.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="pcPages" :style="warpCss">
  3. <div class="imageCube-bos" :style="{ gap: componentData.gap + 'px' }">
  4. <template v-for="(item, index) in componentData.imagelList" :key="index">
  5. <div v-if="index < componentData.number" class="imageCube-list" :style="boxCss" @click="onPath(item.url)">
  6. <el-image
  7. class="img"
  8. :src="item.imageUrl ? item.imageUrl : figure"
  9. :fit="item.imageUrl ? (item.imgType == 1 ? 'fill' : item.imgType == 2 ? 'contain' : 'cover') : 'cover'"
  10. :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
  11. />
  12. </div>
  13. </template>
  14. </div>
  15. </div>
  16. </template>
  17. <script lang="ts" setup>
  18. import { onPath } from '@/utils/siteConfig';
  19. import figure from '@/assets/images/figure.png';
  20. interface Props {
  21. row?: any;
  22. }
  23. const props = defineProps<Props>();
  24. const componentData = props.row || {};
  25. const warpCss = computed(() => {
  26. let style = '';
  27. style += 'position:relative;';
  28. //背景颜色
  29. if (componentData.pageStartBgColor) {
  30. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  31. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  32. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  33. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  34. }
  35. //边距
  36. if (componentData.padding) {
  37. if (componentData.padding.top > 0) {
  38. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  39. }
  40. if (componentData.padding.bottom > 0) {
  41. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  42. }
  43. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  44. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  45. }
  46. //圆角
  47. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  48. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  49. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  50. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  51. //间距
  52. if (componentData.margin) {
  53. if (componentData.margin.top > 0) {
  54. style += 'margin-top:' + componentData.margin.top + 'px' + ';';
  55. }
  56. if (componentData.margin.bottom > 0) {
  57. style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
  58. }
  59. }
  60. return style;
  61. });
  62. //组件样式
  63. const boxCss = computed(() => {
  64. let style = '';
  65. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  66. style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
  67. else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
  68. else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
  69. // 宽度
  70. if (componentData.number)
  71. style += 'flex:' + `0 0 calc((100% - ${(componentData.number - 1) * componentData.gap}px) / ${componentData.number})` + ';';
  72. //圆角
  73. if (componentData.imageTopRounded) style += 'border-top-left-radius:' + componentData.imageTopRounded + 'px;';
  74. if (componentData.imageTopRounded) style += 'border-top-right-radius:' + componentData.imageTopRounded + 'px;';
  75. if (componentData.imageBottomRoundedRounded) style += 'border-bottom-left-radius:' + componentData.imageBottomRoundedRounded + 'px;';
  76. if (componentData.imageBottomRoundedRounded) style += 'border-bottom-right-radius:' + componentData.imageBottomRoundedRounded + 'px;';
  77. //高度
  78. if (componentData.imageHeight) style += 'height:' + componentData.imageHeight + 'px;';
  79. return style;
  80. });
  81. </script>
  82. <style lang="scss" scoped>
  83. .pcPages {
  84. width: 1200px;
  85. margin: 0 auto;
  86. .imageCube-bos {
  87. display: flex;
  88. .imageCube-list {
  89. overflow: hidden;
  90. .img {
  91. width: 100%;
  92. height: 100%;
  93. cursor: pointer;
  94. }
  95. }
  96. }
  97. }
  98. </style>