navigation.vue 6.1 KB

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