brand.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div class="pcPages" :style="warpCss">
  3. <div class="big-brand" :style="boxCss">
  4. <el-image
  5. class="bigBrand-one"
  6. :src="componentData.imageUrl ? componentData.imageUrl : figure"
  7. :fit="componentData.imageUrl ? (componentData.imgType == 1 ? 'fill' : componentData.imgType == 2 ? 'contain' : 'cover') : 'cover'"
  8. :style="componentData.boxRadius ? { borderRadius: componentData.boxRadius + 'px' } : {}"
  9. />
  10. <div class="bigBrand-bos">
  11. <template v-for="(item, index) in componentData.brandList" :key="index">
  12. <div
  13. class="bigBrand-list hover-color"
  14. v-if="Number(index) < 10"
  15. :style="componentData.boxRadius ? { borderRadius: componentData.boxRadius + 'px' } : {}"
  16. >
  17. <el-image
  18. class="img"
  19. :src="item.imageUrl ? item.imageUrl : brand1"
  20. :fit="item.imgType == 1 ? 'fill' : item.imgType == 2 ? 'contain' : 'cover'"
  21. :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
  22. />
  23. <div :style="titleCss" class="bigBrand1 zi-hover">{{ item.title || '' }}</div>
  24. <div :style="subtitleCss" class="bigBrand2">
  25. {{ item.subtitle || '' }}
  26. </div>
  27. </div>
  28. </template>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script lang="ts" setup>
  34. import figure from '@/assets/images/figure.png';
  35. import brand1 from '@/assets/images/pcdiy/brand1.png';
  36. import usePcdiyStore from '@/store/modules/pcdiy';
  37. const diyStore = usePcdiyStore();
  38. const props = defineProps<{
  39. index: number; // 确保声明 index 为可选属性
  40. row?: any;
  41. }>();
  42. const componentData = props.row ? props.row : diyStore.componentList[props.index];
  43. const warpCss = computed(() => {
  44. let style = '';
  45. style += 'position:relative;';
  46. //背景颜色
  47. if (componentData.pageStartBgColor) {
  48. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  49. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  50. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  51. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  52. }
  53. //背景图片
  54. if (componentData.componentBgUrl) {
  55. style += `background-image:url('${componentData.componentBgUrl}');`;
  56. style += 'background-size: cover;background-repeat: no-repeat;';
  57. }
  58. //边距
  59. if (componentData.padding) {
  60. if (componentData.padding.top > 0) {
  61. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  62. }
  63. if (componentData.padding.bottom > 0) {
  64. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  65. }
  66. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  67. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  68. }
  69. //圆角
  70. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  71. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  72. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  73. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  74. //间距
  75. if (componentData.margin) {
  76. if (componentData.margin.top > 0) {
  77. style += 'margin-top:' + componentData.margin.top + 'px' + ';';
  78. }
  79. if (componentData.margin.bottom > 0) {
  80. style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
  81. }
  82. }
  83. return style;
  84. });
  85. //组件样式
  86. const boxCss = computed(() => {
  87. let style = '';
  88. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  89. style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
  90. else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
  91. else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
  92. if (componentData.number) style += 'flex:' + `0 0 calc((100% - ${(componentData.number - 1) * 10}px) / ${componentData.number})` + ';';
  93. return style;
  94. });
  95. // 标题样式
  96. const titleCss = computed(() => {
  97. let style = '';
  98. if (componentData.titleColor) style += 'color:' + componentData.titleColor + ';';
  99. if (componentData.titleSize) style += 'font-size:' + componentData.titleSize + 'px;';
  100. if (componentData.titleWeight) style += 'font-weight:' + componentData.titleWeight + ';';
  101. return style;
  102. });
  103. // 副标题样式
  104. const subtitleCss = computed(() => {
  105. let style = '';
  106. if (componentData.subtitleColor) style += 'color:' + componentData.subtitleColor + ';';
  107. if (componentData.subtitleSize) style += 'font-size:' + componentData.subtitleSize + 'px;';
  108. return style;
  109. });
  110. </script>
  111. <style lang="scss" scoped>
  112. .pcPages {
  113. width: 1200px;
  114. margin: 0 auto;
  115. // 大牌推荐
  116. .big-brand {
  117. height: 340px;
  118. display: flex;
  119. gap: 10px;
  120. width: 100%;
  121. .bigBrand-one {
  122. width: 230px;
  123. height: 340px;
  124. }
  125. .bigBrand-bos {
  126. flex: 1;
  127. display: flex;
  128. flex-wrap: wrap;
  129. gap: 10px;
  130. overflow: hidden;
  131. height: 340px;
  132. .bigBrand-list {
  133. flex: 0 0 calc((100% - 40px) / 5);
  134. height: 165px;
  135. background: #ffffff;
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. padding: 20px 20px 0 20px;
  140. width: 0;
  141. .img {
  142. width: 120px;
  143. height: 50px;
  144. }
  145. .bigBrand1 {
  146. font-weight: 600;
  147. font-size: 14px;
  148. color: #101828;
  149. margin: 5px 0 4px 0;
  150. }
  151. .bigBrand2 {
  152. font-weight: 400;
  153. font-size: 12px;
  154. color: #364153;
  155. display: -webkit-box;
  156. -webkit-line-clamp: 2;
  157. line-clamp: 2;
  158. -webkit-box-orient: vertical;
  159. overflow: hidden;
  160. text-overflow: ellipsis;
  161. text-align: left;
  162. width: 100%;
  163. }
  164. }
  165. }
  166. }
  167. }
  168. </style>