index.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="component-wrapper u000242" :style="wrapper_style">
  3. <view v-if="datas.show_title" :style="title_style" class="title">{{ title }}</view>
  4. <view v-if="datas.show_second_title" :style="second_title_style" class="second-title">{{ second_title }}</view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. props: ['styles', 'datas'],
  10. computed: {
  11. /** 样式 */
  12. wrapper_style() {
  13. if(this.datas.preview_color) {
  14. const {
  15. preview_color,
  16. padding_top,
  17. padding_bottom,
  18. padding_left,
  19. padding_right,
  20. } = this.datas;
  21. return `
  22. padding-top: ${padding_top}px;
  23. padding-bottom: ${padding_bottom}px;
  24. padding-left: ${padding_left}px;
  25. padding-right: ${padding_right}px;
  26. background-color: ${preview_color.color};
  27. background-image: url(${preview_color.isColor == 2? preview_color.image: ''});
  28. background-size: 100% auto;
  29. bakcground-position: center;
  30. `;
  31. }
  32. },
  33. /** 标题样式 */
  34. title_style() {
  35. const {
  36. text_style,
  37. text_align,
  38. text_size,
  39. text_color
  40. } = this.datas;
  41. return `
  42. font-weight: ${text_style.includes('1')?'bold':''};
  43. font-style: ${text_style.includes('2')?'italic':''};
  44. text-align: ${text_align};
  45. font-size: ${text_size}px;
  46. color: ${text_color};
  47. `;
  48. },
  49. /** 副标题样式 */
  50. second_title_style() {
  51. const {
  52. second_text_style,
  53. second_text_align,
  54. second_text_size,
  55. second_text_color
  56. } = this.datas;
  57. return `
  58. font-weight: ${second_text_style.includes('1')?'bold':''};
  59. font-style: ${second_text_style.includes('2')?'italic':''};
  60. text-align: ${second_text_align};
  61. font-size: ${second_text_size}px;
  62. color: ${second_text_color};
  63. `;
  64. },
  65. /** 标题 */
  66. title() {
  67. return this.datas.title || '标题';
  68. },
  69. second_title() {
  70. return this.datas.second_title || '副标题';
  71. },
  72. },
  73. mounted() {
  74. this.$emit('loaded');
  75. }
  76. };
  77. </script>
  78. <style lang="less" scoped>
  79. .component-wrapper {
  80. display: block;
  81. max-width: 100%;
  82. line-height: 40rpx;
  83. text-align: center;
  84. margin-left: auto;
  85. margin-right: auto;
  86. overflow: hidden;
  87. text-decoration: none;
  88. }
  89. </style>