hot.vue 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="pcPages" :style="warpCss">
  3. <el-image class="hot-image" :src="componentData.imageUrl ? componentData.imageUrl : figure" fit="fill" />
  4. <div
  5. @click="onClick(mapItem)"
  6. class="absolute hot-aaaaaa"
  7. v-for="(mapItem, mapIndex) in componentData.heatMapData"
  8. :key="mapIndex"
  9. :style="{ width: mapItem.width + '%', height: mapItem.height + '%', left: mapItem.left + '%', top: mapItem.top + '%' }"
  10. ></div>
  11. </div>
  12. </template>
  13. <script lang="ts" setup>
  14. import usePcdiyStore from '@/store/modules/pcdiy';
  15. import figure from '@/assets/images/figure.png';
  16. const diyStore = usePcdiyStore();
  17. const props = defineProps<{
  18. index: number; // 确保声明 index 为可选属性
  19. row?: any;
  20. }>();
  21. const onClick = (mapItem: any) => {};
  22. const componentData = props.row ? props.row : diyStore.componentList[props.index];
  23. const warpCss = computed(() => {
  24. let style = '';
  25. style += 'position:relative;';
  26. //背景颜色
  27. if (componentData.pageStartBgColor) {
  28. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  29. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  30. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  31. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  32. }
  33. //背景图片
  34. if (componentData.componentBgUrl) {
  35. style += `background-image:url('${componentData.componentBgUrl}');`;
  36. style += 'background-size: cover;background-repeat: no-repeat;';
  37. }
  38. //边距
  39. if (componentData.padding) {
  40. if (componentData.padding.top > 0) {
  41. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  42. }
  43. if (componentData.padding.bottom > 0) {
  44. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  45. }
  46. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  47. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  48. }
  49. //圆角
  50. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  51. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  52. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  53. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  54. //间距
  55. if (componentData.margin) {
  56. if (componentData.margin.top > 0) {
  57. style += 'margin-top:' + componentData.margin.top + 'px' + ';';
  58. }
  59. if (componentData.margin.bottom > 0) {
  60. style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
  61. }
  62. }
  63. return style;
  64. });
  65. </script>
  66. <style lang="scss" scoped>
  67. .pcPages {
  68. width: 1200px;
  69. margin: 0 auto;
  70. position: relative;
  71. .hot-image {
  72. width: 100%;
  73. }
  74. .hot-aaaaaa {
  75. border: 1px red solid;
  76. z-index: 10;
  77. }
  78. }
  79. </style>