floor.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="pcPages" :style="warpCss">
  3. <div class="floor-bos" :style="boxCss">
  4. <el-image
  5. @click="onPath(componentData.url)"
  6. class="floor-one"
  7. :src="componentData.imageUrl ? componentData.imageUrl : figure"
  8. :fit="componentData.imageUrl ? (componentData.imgType == 1 ? 'fill' : componentData.imgType == 2 ? 'contain' : 'cover') : 'cover'"
  9. :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
  10. />
  11. <div class="floor-box">
  12. <div
  13. v-for="(item, index) in componentData.goodsDefault ? componentData.goodsList : dataList"
  14. :key="index"
  15. class="goods-list flex-column-between hover-color"
  16. @click="onPath('/item?id=' + item.id + '&productNo=' + item.productNo)"
  17. >
  18. <img
  19. class="goods-img"
  20. :src="item.productImage ? item.productImage : figure"
  21. alt=""
  22. :style="componentData.imageRadius ? { borderRadius: componentData.imageRadius + 'px' } : {}"
  23. />
  24. <div v-if="componentData.goodsShow.includes(1)" class="itemName zi-hover">{{ item.itemName || '商品名称' }}</div>
  25. <div class="flex-row-between">
  26. <div>
  27. <span v-if="componentData.goodsShow.includes(2)" class="memberPrice" :style="{ color: componentData.btnbackgroundColor }"
  28. >¥{{ item.memberPrice || '0.00' }}</span
  29. >
  30. <span v-if="componentData.goodsShow.includes(3)" class="marketPrice">¥{{ item.marketPrice || '0.00' }}</span>
  31. </div>
  32. <template v-if="componentData.btnShow">
  33. <div v-if="componentData.btnStyle == 1" :style="btnCss1" class="btn1 ellipsis">{{ componentData.btnText }}</div>
  34. <div v-if="componentData.btnStyle == 2" :style="btnCss2" class="btn2 flex-row-center">
  35. <el-icon size="14"><Plus /></el-icon>
  36. </div>
  37. <div v-if="componentData.btnStyle == 3" :style="btnCss2" class="btn2 flex-row-center">
  38. <icon name="iconfont icongouwuche" size="14px" />
  39. </div>
  40. </template>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="goods-brand flex-column-between" v-if="componentData.styleType == 2">
  45. <div class="brand-bos">
  46. <template v-for="(item, index) in componentData.brandList" :key="index">
  47. <el-image
  48. v-if="Number(index) < 6"
  49. class="brand-img"
  50. :src="item.imageUrl ? item.imageUrl : figure"
  51. :fit="item.imgType == 1 ? 'fill' : item.imgType == 2 ? 'contain' : 'cover'"
  52. @click="onPath(item.url)"
  53. />
  54. </template>
  55. </div>
  56. <div
  57. @click="onPath(componentData.moreUrl)"
  58. class="brand-more flex-row-center"
  59. v-if="componentData.moreShow"
  60. :style="{ color: componentData.moreColor }"
  61. >
  62. <div>{{ componentData.moreTitle }}</div>
  63. <el-icon><ArrowRight /></el-icon>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script setup lang="ts">
  70. import { onPath } from '@/utils/siteConfig';
  71. import figure from '@/assets/images/figure.png';
  72. import { getDiyProductPage, getCustomerProductPage } from '@/api/home/diy';
  73. interface Props {
  74. row?: any;
  75. }
  76. const props = defineProps<Props>();
  77. const componentData = props.row || {};
  78. const dataList = ref<any>([{}, {}, {}, {}, {}, {}, {}, {}]);
  79. onMounted(() => {
  80. getDataList();
  81. });
  82. const getDataList = () => {
  83. dataList.value = [{}, {}, {}, {}, {}, {}, {}, {}];
  84. //手动选择
  85. if (componentData.goodsIds.length > 0) {
  86. const apiFunc = componentData.clientId && componentData.clientId !== 'undefined' ? getCustomerProductPage : getDiyProductPage;
  87. const queryParams = {
  88. pageNum: 1,
  89. pageSize: 10,
  90. ids: componentData.goodsIds.join(','),
  91. customerId: ''
  92. };
  93. if (componentData.clientId && componentData.clientId != 'undefined') {
  94. queryParams.customerId = componentData.clientId;
  95. } else {
  96. delete queryParams.customerId;
  97. }
  98. apiFunc(queryParams).then((res) => {
  99. if (res.code == 200) {
  100. dataList.value = res.rows;
  101. }
  102. });
  103. }
  104. };
  105. const warpCss = computed(() => {
  106. let style = '';
  107. style += 'position:relative;';
  108. //背景颜色
  109. if (componentData.pageStartBgColor) {
  110. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  111. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  112. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  113. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  114. }
  115. //背景图片
  116. if (componentData.componentBgUrl) {
  117. style += `background-image:url('${componentData.componentBgUrl}');`;
  118. style += 'background-size: cover;background-repeat: no-repeat;';
  119. }
  120. //边距
  121. if (componentData.padding) {
  122. if (componentData.padding.top > 0) {
  123. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  124. }
  125. if (componentData.padding.bottom > 0) {
  126. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  127. }
  128. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  129. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  130. }
  131. //圆角
  132. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  133. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  134. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  135. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  136. //间距
  137. if (componentData.margin) {
  138. if (componentData.margin.top > 0) {
  139. style += 'margin-top:' + componentData.margin.top + 'px' + ';';
  140. }
  141. if (componentData.margin.bottom > 0) {
  142. style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
  143. }
  144. }
  145. return style;
  146. });
  147. //组件样式
  148. const boxCss = computed(() => {
  149. let style = '';
  150. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  151. style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
  152. else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
  153. else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
  154. if (componentData.number) style += 'flex:' + `0 0 calc((100% - ${(componentData.number - 1) * 10}px) / ${componentData.number})` + ';';
  155. return style;
  156. });
  157. const btnCss1 = computed(() => {
  158. let style = '';
  159. if (componentData.btnbackgroundColor) style += 'background-color:' + componentData.btnbackgroundColor + ';';
  160. if (componentData.btnColor) style += 'color:' + componentData.btnColor + ';';
  161. return style;
  162. });
  163. const btnCss2 = computed(() => {
  164. let style = '';
  165. if (componentData.btnbackgroundColor) style += 'color:' + componentData.btnbackgroundColor + ';';
  166. if (componentData.btnbackgroundColor) style += 'border-color:' + componentData.btnbackgroundColor + ';';
  167. return style;
  168. });
  169. </script>
  170. <style lang="scss" scoped>
  171. .pcPages {
  172. width: 100%;
  173. max-width: 1500px;
  174. min-width: 1200px;
  175. margin: 0 auto;
  176. .floor-bos {
  177. height: 560px;
  178. display: flex;
  179. gap: 10px;
  180. width: 100%;
  181. .floor-one {
  182. width: 230px;
  183. height: 560px;
  184. cursor: pointer;
  185. }
  186. .floor-box {
  187. flex: 1;
  188. display: flex;
  189. flex-wrap: wrap;
  190. gap: 10px;
  191. overflow: hidden;
  192. &:hover {
  193. overflow: auto;
  194. }
  195. .goods-list {
  196. padding: 15px 10px;
  197. height: 275px;
  198. width: 0;
  199. flex: 0 0 calc((100% - 30px) / 4);
  200. background-color: #ffffff;
  201. overflow: hidden;
  202. border-radius: 5px;
  203. .goods-img {
  204. width: 140px;
  205. height: 140px;
  206. margin: 0 auto;
  207. }
  208. .itemName {
  209. width: 100%;
  210. font-size: 14px;
  211. color: #101828;
  212. display: -webkit-box;
  213. -webkit-line-clamp: 2;
  214. line-clamp: 2;
  215. /* 添加标准属性 */
  216. -webkit-box-orient: vertical;
  217. overflow: hidden;
  218. text-overflow: ellipsis;
  219. }
  220. .memberPrice {
  221. font-size: 16px;
  222. font-weight: bold;
  223. }
  224. .marketPrice {
  225. font-size: 12px;
  226. color: #99a1af;
  227. line-height: 20px;
  228. text-decoration-line: line-through;
  229. text-transform: none;
  230. margin-left: 6px;
  231. color: #99a1af;
  232. }
  233. .btn1 {
  234. padding: 5px 15px;
  235. font-size: 12px;
  236. border-radius: 15px;
  237. }
  238. .btn2 {
  239. color: var(--el-color-primary);
  240. border: 1px solid var(--el-color-primary);
  241. height: 26px;
  242. width: 26px;
  243. border-radius: 50%;
  244. }
  245. }
  246. }
  247. .goods-brand {
  248. width: 140px;
  249. height: 560px;
  250. border-radius: 5px;
  251. background: #ffffff;
  252. padding: 15px 10px;
  253. .brand-bos {
  254. width: 100%;
  255. display: flex;
  256. flex-direction: column;
  257. gap: 10px 0;
  258. .brand-img {
  259. width: 100%;
  260. height: 74px;
  261. border-radius: 4px;
  262. border: 1px solid #e5e7eb;
  263. cursor: pointer;
  264. }
  265. }
  266. .brand-more {
  267. color: var(--el-color-primary);
  268. font-size: 14px;
  269. cursor: pointer;
  270. }
  271. }
  272. }
  273. }
  274. </style>