textTitle.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <div class="pcPages">
  3. <div :style="warpCss">
  4. <!-- 风格1 -->
  5. <div :style="boxCss" v-if="componentData.styleType == 1">
  6. <div :style="titleCss">{{ componentData.title }}{{ componentData.titleUrl }}</div>
  7. </div>
  8. <!-- 风格2 -->
  9. <div :style="boxCss" class="style2 flex-row-center" v-else-if="componentData.styleType == 2">
  10. <div class="style2-border" :style="{ backgroundColor: componentData.titleColor }"></div>
  11. <div class="style2-text" :style="titleCss">{{ componentData.title }}</div>
  12. <div class="style2-border" :style="{ backgroundColor: componentData.titleColor }"></div>
  13. </div>
  14. <!-- 风格3 -->
  15. <div :style="boxCss" class="style3 flex-column-center" v-else-if="componentData.styleType == 3">
  16. <div :style="titleCss" class="mb-[4px]">{{ componentData.title }}</div>
  17. <div class="style3-border" :style="{ backgroundColor: componentData.titleColor }"></div>
  18. <div class="style3-jiao" :style="{ borderColor: componentData.titleColor }"></div>
  19. </div>
  20. <!-- 风格4 -->
  21. <div :style="boxCss" class="style4 flex-column-center" v-else-if="componentData.styleType == 4">
  22. <div :style="titleCss" class="mb-[4px]">{{ componentData.title }}</div>
  23. <div class="style4-border1" :style="{ backgroundColor: componentData.titleColor }"></div>
  24. <div class="style4-border2" :style="{ backgroundColor: componentData.titleColor }"></div>
  25. </div>
  26. <!-- 风格5 -->
  27. <div :style="boxCss" class="style5 flex-column-center" v-else-if="componentData.styleType == 5">
  28. <div :style="titleCss" class="mb-[4px]">{{ componentData.title }}</div>
  29. <div class="flex-row-center">
  30. <div class="style5-border" :style="{ backgroundColor: componentData.titleColor }"></div>
  31. <div class="style5-box" :style="{ borderColor: componentData.titleColor }"></div>
  32. <div class="style5-border" :style="{ backgroundColor: componentData.titleColor }"></div>
  33. </div>
  34. </div>
  35. <!-- 风格6 -->
  36. <div :style="boxCss" class="style6 flex-column-center" v-else-if="componentData.styleType == 6">
  37. <div class="style6-bos flex-row-center" :style="{ borderColor: componentData.titleColor }">
  38. <div class="style6-border style6-border1" :style="{ backgroundColor: componentData.titleColor }"></div>
  39. <div :style="titleCss" class="style6-box">{{ componentData.title }}</div>
  40. <div class="style6-border style6-border2" :style="{ backgroundColor: componentData.titleColor }"></div>
  41. </div>
  42. </div>
  43. <!-- 风格7 -->
  44. <div :style="boxCss" class="style7 flex-column-center" v-else-if="componentData.styleType == 7">
  45. <div class="style7-bos">
  46. <div class="style7-text" :style="titleCss">{{ componentData.title }}</div>
  47. <div class="style7-line" :style="{ borderColor: componentData.titleColor }"></div>
  48. </div>
  49. </div>
  50. <!-- 风格8 -->
  51. <div :style="boxCss" class="style8 flex-column-center" v-else-if="componentData.styleType == 8">
  52. <div class="style8-bos">
  53. <div class="style8-text" :style="titleCss">{{ componentData.title }}</div>
  54. <div class="style8-line" :style="{ borderColor: componentData.titleColor }"></div>
  55. </div>
  56. </div>
  57. <!-- 风格9 -->
  58. <div :style="boxCss" class="style9 flex-row-start" v-else-if="componentData.styleType == 9">
  59. <div class="style9-border" :style="{ backgroundColor: componentData.titleColor }"></div>
  60. <div class="pl-[10px]" :style="titleCss">{{ componentData.title }}</div>
  61. </div>
  62. <!-- 风格10 -->
  63. <div :style="boxCss" class="style10 flex-column-center" v-else-if="componentData.styleType == 10">
  64. <div class="style10-bos flex-row-start">
  65. <img class="style10-img1" src="@/assets/images/pcdiy/style10-1.png" alt="" />
  66. <div :style="titleCss">{{ componentData.title }}</div>
  67. <img class="style10-img2" src="@/assets/images/pcdiy/style10-2.png" alt="" />
  68. </div>
  69. <div class="mt-[2px]" :style="subtitleCss">
  70. {{ componentData.subtitle }}
  71. </div>
  72. </div>
  73. <!-- 风格11 -->
  74. <div :style="boxCss" class="style11 flex-column-center" v-else-if="componentData.styleType == 11">
  75. <div class="style11-bos flex-row-start">
  76. <img class="style11-img style11-img1" src="@/assets/images/pcdiy/style11-1.png" alt="" />
  77. <div :style="titleCss" class="style11-text">{{ componentData.title }}</div>
  78. <img class="style11-img style11-img2" src="@/assets/images/pcdiy/style11-2.png" alt="" />
  79. <img class="style11-img3" src="@/assets/images/pcdiy/style11-3.png" alt="" />
  80. </div>
  81. <div class="mt-[2px]" :style="subtitleCss">
  82. {{ componentData.subtitle }}
  83. </div>
  84. </div>
  85. <!-- 风格12 -->
  86. <div :style="boxCss" class="style12 flex-row-between" v-else-if="componentData.styleType == 12">
  87. <div class="flex-row-start">
  88. <div :style="titleCss">{{ componentData.title }}</div>
  89. <div :style="subtitleCss" class="ml-[5px]">{{ componentData.subtitle }}</div>
  90. </div>
  91. <div v-if="componentData.moreShow" class="flex-row-start" :style="moreCss">
  92. <div>{{ componentData.more }}</div>
  93. <el-icon><ArrowRight /></el-icon>
  94. </div>
  95. </div>
  96. <!-- 风格13 -->
  97. <div :style="boxCss" class="style13 flex-column-center" v-else-if="componentData.styleType == 13">
  98. <div class="style13-bos flex-row-start">
  99. <img class="style13-img1" src="@/assets/images/pcdiy/style13-1.png" alt="" />
  100. <div :style="titleCss">{{ componentData.title }}</div>
  101. <img class="style13-img2" src="@/assets/images/pcdiy/style13-2.png" alt="" />
  102. </div>
  103. </div>
  104. <!-- 风格14 -->
  105. <div :style="boxCss" class="style14 flex-row-between" v-else-if="componentData.styleType == 14">
  106. <div>
  107. <div :style="titleCss">{{ componentData.title }}</div>
  108. <div :style="subtitleCss">{{ componentData.subtitle }}</div>
  109. </div>
  110. <div v-if="componentData.moreShow" class="flex-row-start" :style="moreCss">
  111. <div>{{ componentData.more }}</div>
  112. <el-icon><ArrowRight /></el-icon>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. <script setup name="Index" lang="ts">
  119. import usePcdiyStore from '@/store/modules/pcdiy';
  120. const diyStore = usePcdiyStore();
  121. const props = defineProps<{
  122. index: number; // 确保声明 index 为可选属性
  123. }>();
  124. const componentData = diyStore.componentList[props.index];
  125. const warpCss = computed(() => {
  126. let style = '';
  127. style += 'position:relative;';
  128. //背景颜色
  129. if (componentData.pageStartBgColor) {
  130. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  131. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  132. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  133. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  134. }
  135. //背景图片
  136. if (componentData.componentBgUrl) {
  137. style += `background-image:url('${componentData.componentBgUrl}');`;
  138. style += 'background-size: cover;background-repeat: no-repeat;';
  139. }
  140. //边距
  141. if (componentData.padding) {
  142. if (componentData.padding.top > 0) {
  143. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  144. }
  145. if (componentData.padding.bottom > 0) {
  146. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  147. }
  148. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  149. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  150. }
  151. //圆角
  152. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  153. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  154. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  155. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  156. return style;
  157. });
  158. //组件样式
  159. const boxCss = computed(() => {
  160. let style = '';
  161. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  162. style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
  163. else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
  164. else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
  165. return style;
  166. });
  167. // 标题样式
  168. const titleCss = computed(() => {
  169. let style = '';
  170. if (componentData.titleColor) style += 'color:' + componentData.titleColor + ';';
  171. if (componentData.titleSize) style += 'font-size:' + componentData.titleSize + 'px;';
  172. if (componentData.titleWeight) style += 'font-weight:' + componentData.titleWeight + ';';
  173. if (componentData.titleAlign && componentData.styleType == 1) style += 'text-align:' + componentData.titleAlign;
  174. if (componentData.titleColor && (componentData.styleType == 6 || componentData.styleType == 7)) {
  175. style += 'border-color:' + componentData.titleColor;
  176. }
  177. if (componentData.titleColor && componentData.styleType == 8) {
  178. style += 'background-color:' + componentData.titleColor;
  179. }
  180. return style;
  181. });
  182. // 副标题样式
  183. const subtitleCss = computed(() => {
  184. let style = '';
  185. if (componentData.subtitleColor) style += 'color:' + componentData.subtitleColor + ';';
  186. if (componentData.subtitleSize) style += 'font-size:' + componentData.subtitleSize + 'px;';
  187. return style;
  188. });
  189. // 更多样式
  190. const moreCss = computed(() => {
  191. let style = '';
  192. if (componentData.moreColor) style += 'color:' + componentData.moreColor + ';';
  193. if (componentData.moreSize) style += 'font-size:' + componentData.moreSize + 'px;';
  194. return style;
  195. });
  196. // 背景图加遮罩层
  197. const maskLayer = computed(() => {
  198. let style = '';
  199. //背景颜色
  200. if (componentData.componentStartBgColor) {
  201. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  202. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.componentStartBgColor},${componentData.pageEndBgColor});`;
  203. else if (componentData.componentStartBgColor) style += `background: ${componentData.componentStartBgColor};`;
  204. else if (componentData.componentEndBgColor) style += `background: ${componentData.componentEndBgColor};`;
  205. }
  206. return style;
  207. });
  208. </script>
  209. <style lang="scss" scoped>
  210. .pcPages {
  211. width: 1200px;
  212. margin: 0 auto;
  213. .style2 {
  214. .style2-text {
  215. margin: 0 30px;
  216. }
  217. .style2-border {
  218. width: 160px;
  219. height: 1px;
  220. }
  221. }
  222. .style3 {
  223. position: relative;
  224. .style3-border {
  225. width: 260px;
  226. height: 1px;
  227. }
  228. .style3-jiao {
  229. background: transparent !important;
  230. display: inline-block;
  231. border: 6px solid #cccccc;
  232. border-top-color: transparent !important;
  233. border-left-color: transparent !important;
  234. -webkit-transform: rotate(45deg);
  235. transform: rotate(45deg);
  236. margin-top: -6px;
  237. }
  238. }
  239. .style4 {
  240. .style4-border1 {
  241. width: 160px;
  242. height: 2px;
  243. }
  244. .style4-border2 {
  245. width: 260px;
  246. height: 1px;
  247. }
  248. }
  249. .style5 {
  250. .style5-box {
  251. width: 10px;
  252. height: 10px;
  253. border: 1px solid #000;
  254. display: inline-block;
  255. -webkit-transform: rotate(45deg);
  256. transform: rotate(45deg);
  257. margin: 0 10px;
  258. }
  259. .style5-border {
  260. width: 160px;
  261. height: 1px;
  262. }
  263. }
  264. .style6 {
  265. .style6-bos {
  266. border: 1px solid #ccc;
  267. padding: 4px 4px;
  268. position: relative;
  269. .style6-box {
  270. border: 1px solid #ccc;
  271. padding: 2px 14px;
  272. }
  273. .style6-border {
  274. width: 50px;
  275. height: 4px;
  276. position: absolute;
  277. top: 50%;
  278. &.style6-border1 {
  279. left: -40px;
  280. }
  281. &.style6-border2 {
  282. right: -40px;
  283. }
  284. }
  285. }
  286. }
  287. .style7 {
  288. .style7-bos {
  289. position: relative;
  290. margin-bottom: 6px;
  291. .style7-text {
  292. padding: 2px 14px;
  293. position: relative;
  294. z-index: 2;
  295. background-color: #ffffff;
  296. border: 1px solid #ccc;
  297. }
  298. .style7-line {
  299. position: absolute;
  300. width: 100%;
  301. height: 100%;
  302. border: 1px solid #ccc;
  303. top: 6px;
  304. left: 6px;
  305. z-index: 0;
  306. }
  307. }
  308. }
  309. .style8 {
  310. .style8-bos {
  311. position: relative;
  312. margin-bottom: 6px;
  313. .style8-text {
  314. padding: 2px 14px;
  315. position: relative;
  316. z-index: 2;
  317. color: #ffffff !important;
  318. }
  319. .style8-line {
  320. position: absolute;
  321. width: 100%;
  322. height: 100%;
  323. border: 1px solid #ccc;
  324. top: 6px;
  325. left: 6px;
  326. z-index: 0;
  327. }
  328. }
  329. }
  330. .style9 {
  331. position: relative;
  332. .style9-border {
  333. height: 80%;
  334. width: 3px;
  335. position: absolute;
  336. }
  337. }
  338. .style10 {
  339. .style10-bos {
  340. height: 100%;
  341. position: relative;
  342. img {
  343. height: 100%;
  344. position: absolute;
  345. &.style10-img1 {
  346. left: -70%;
  347. }
  348. &.style10-img2 {
  349. right: -70%;
  350. }
  351. }
  352. }
  353. }
  354. .style11 {
  355. .style11-bos {
  356. height: 100%;
  357. position: relative;
  358. .style11-img {
  359. height: 100%;
  360. position: absolute;
  361. &.style11-img1 {
  362. left: -60%;
  363. }
  364. &.style11-img2 {
  365. right: -60%;
  366. }
  367. }
  368. .style11-text {
  369. position: relative;
  370. z-index: 2;
  371. }
  372. .style11-img3 {
  373. position: absolute;
  374. width: 120%;
  375. bottom: 0px;
  376. left: -10%;
  377. }
  378. }
  379. }
  380. .style13 {
  381. .style13-bos {
  382. height: 100%;
  383. position: relative;
  384. img {
  385. height: 100%;
  386. position: absolute;
  387. &.style13-img1 {
  388. left: -80%;
  389. }
  390. &.style13-img2 {
  391. right: -80%;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. .textTitle-pages {
  398. width: 100%;
  399. .textTitle-bos {
  400. background-color: #ffffff;
  401. line-height: 45px;
  402. padding-left: 20px;
  403. font-size: 18px;
  404. color: #333333;
  405. font-weight: bold;
  406. }
  407. }
  408. </style>