navigation.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="pcPages">
  3. <div class="carousel-bos" :style="warpCss" v-if="componentData.styleType == 3">
  4. <el-carousel :height="170 * componentData.count + (componentData.count == 2 ? 10 : 0) + 'px'" :autoplay="false" arrow="always">
  5. <el-carousel-item v-for="(item1, index1) in dataList" :key="index1" class="w100% h100%">
  6. <div class="carousel-list">
  7. <div
  8. v-for="(item, index) in item1"
  9. :key="index"
  10. class="data-list flex-column-center hover-color"
  11. :style="boxCss"
  12. @click="onPath(item.url)"
  13. >
  14. <div :style="titleCss" class="zi-hover">{{ item.title || '' }}</div>
  15. <div :style="subtitleCss" class="mt-[2px] mb-[12px]">{{ item.subtitle || '' }}</div>
  16. <el-image
  17. class="img"
  18. :src="item.imageUrl ? item.imageUrl : figure"
  19. :fit="item.imgType == 1 ? 'fill' : item.imgType == 2 ? 'contain' : 'cover'"
  20. :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
  21. />
  22. </div>
  23. </div>
  24. </el-carousel-item>
  25. </el-carousel>
  26. </div>
  27. <div v-else :style="warpCss" class="data-bos">
  28. <div
  29. v-for="(item, index) in componentData.navlList"
  30. :key="index"
  31. class="data-list flex-column-center hover-color"
  32. :style="boxCss"
  33. @click="onPath(item.url)"
  34. >
  35. <div :style="titleCss" class="zi-hover">{{ item.title || '' }}</div>
  36. <div :style="subtitleCss" class="mt-[2px] mb-[12px]">{{ item.subtitle || '' }}</div>
  37. <el-image
  38. class="img"
  39. :src="item.imageUrl ? item.imageUrl : figure"
  40. :fit="item.imgType == 1 ? 'fill' : item.imgType == 2 ? 'contain' : 'cover'"
  41. :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
  42. />
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script lang="ts" setup>
  48. import { onPath } from '@/utils/siteConfig';
  49. import figure from '@/assets/images/figure.png';
  50. interface Props {
  51. row?: any;
  52. }
  53. const props = defineProps<Props>();
  54. const componentData = props.row || {};
  55. const dataList = computed(() => {
  56. const chunkSize = componentData.number * componentData.count;
  57. const result = [];
  58. for (let i = 0; i < componentData.navlList.length; i += chunkSize) {
  59. const chunk = componentData.navlList.slice(i, i + chunkSize);
  60. result.push(chunk);
  61. }
  62. return result;
  63. });
  64. const warpCss = computed(() => {
  65. let style = '';
  66. style += 'position:relative;';
  67. //背景颜色
  68. if (componentData.pageStartBgColor) {
  69. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  70. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  71. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  72. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  73. }
  74. //边距
  75. if (componentData.padding) {
  76. if (componentData.padding.top > 0) {
  77. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  78. }
  79. if (componentData.padding.bottom > 0) {
  80. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  81. }
  82. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  83. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  84. if (componentData.styleType == 1) style += 'flex-wrap:wrap' + ';';
  85. }
  86. //间距
  87. if (componentData.margin) {
  88. if (componentData.margin.top > 0) {
  89. style += 'margin-top:' + componentData.margin.top + 'px' + ';';
  90. }
  91. if (componentData.margin.bottom > 0) {
  92. style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
  93. }
  94. }
  95. return style;
  96. });
  97. //组件样式
  98. const boxCss = computed(() => {
  99. let style = '';
  100. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  101. style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
  102. else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
  103. else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
  104. if (componentData.number) style += 'flex:' + `0 0 calc((100% - ${(componentData.number - 1) * 10}px) / ${componentData.number})` + ';';
  105. //圆角
  106. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  107. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  108. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  109. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  110. return style;
  111. });
  112. // 标题样式
  113. const titleCss = computed(() => {
  114. let style = '';
  115. if (componentData.titleColor) style += 'color:' + componentData.titleColor + ';';
  116. if (componentData.titleSize) style += 'font-size:' + componentData.titleSize + 'px;';
  117. if (componentData.titleWeight) style += 'font-weight:' + componentData.titleWeight + ';';
  118. return style;
  119. });
  120. // 副标题样式
  121. const subtitleCss = computed(() => {
  122. let style = '';
  123. if (componentData.subtitleColor) style += 'color:' + componentData.subtitleColor + ';';
  124. if (componentData.subtitleSize) style += 'font-size:' + componentData.subtitleSize + 'px;';
  125. return style;
  126. });
  127. </script>
  128. <style lang="scss" scoped>
  129. .pcPages {
  130. width: 1200px;
  131. margin: 0 auto;
  132. .data-bos {
  133. display: flex;
  134. gap: 10px;
  135. width: 100%;
  136. overflow-x: auto;
  137. .data-list {
  138. min-height: 170px;
  139. cursor: pointer;
  140. .img {
  141. height: 80px;
  142. width: 80px;
  143. }
  144. }
  145. }
  146. .carousel-bos {
  147. .carousel-list {
  148. width: 100%;
  149. height: 100%;
  150. display: flex;
  151. gap: 10px;
  152. flex-wrap: wrap;
  153. .data-list {
  154. height: 170px;
  155. .img {
  156. height: 80px;
  157. width: 80px;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. </style>