s-title-block.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!-- 装修商品组件:标题栏 -->
  2. <template>
  3. <view
  4. class="ss-title-wrap ss-flex ss-col-center"
  5. :class="[state.typeMap[data.textAlign]]"
  6. :style="[elStyles]"
  7. >
  8. <view class="title-content">
  9. <!-- 主标题 -->
  10. <view v-if="data.title" class="title-text" :style="[titleStyles]">{{ data.title }}</view>
  11. <!-- 副标题 -->
  12. <view v-if="data.description" :style="[descStyles]" class="sub-title-text">
  13. {{ data.description }}
  14. </view>
  15. </view>
  16. <!-- 查看更多 -->
  17. <view
  18. v-if="data.more?.show"
  19. class="more-box ss-flex ss-col-center"
  20. @tap="sheep.$router.go(data.more.url)"
  21. :style="{ color: data.descriptionColor }"
  22. >
  23. <view class="more-text" v-if="data.more.type !== 'icon'">{{ data.more.text }} </view>
  24. <text class="_icon-forward" v-if="data.more.type !== 'text'"></text>
  25. </view>
  26. </view>
  27. </template>
  28. <script setup>
  29. /**
  30. * 标题栏
  31. */
  32. import { reactive } from 'vue';
  33. import sheep from '@/common';
  34. // 数据
  35. const state = reactive({
  36. typeMap: {
  37. left: 'ss-row-left',
  38. center: 'ss-row-center',
  39. },
  40. });
  41. // 接收参数
  42. const props = defineProps({
  43. data: {
  44. type: Object,
  45. default() {},
  46. },
  47. styles: {
  48. type: Object,
  49. default() {},
  50. },
  51. });
  52. // 组件样式
  53. const elStyles = {
  54. background: `url(${sheep.$url.cdn(props.data.bgImgUrl)}) no-repeat top center / 100% auto`,
  55. fontSize: `${props.data.titleSize}px`,
  56. fontWeight: `${props.data.titleWeight}`,
  57. height: `${props.data.height || 40}px`,
  58. };
  59. // 标题样式
  60. const titleStyles = {
  61. color: props.data.titleColor,
  62. fontSize: `${props.data.titleSize}px`,
  63. textAlign: props.data.textAlign,
  64. marginLeft: `${props.data.marginLeft || 0}px`,
  65. };
  66. // 副标题
  67. const descStyles = {
  68. color: props.data.descriptionColor,
  69. textAlign: props.data.textAlign,
  70. fontSize: `${props.data.descriptionSize}px`,
  71. fontWeight: `${props.data.descriptionWeight}px`,
  72. marginLeft: `${props.data.marginLeft || 0}px`,
  73. };
  74. </script>
  75. <style lang="scss" scoped>
  76. .ss-title-wrap {
  77. height: 80rpx;
  78. position: relative;
  79. .title-content {
  80. .title-text {
  81. font-size: 30rpx;
  82. color: #333;
  83. }
  84. .sub-title-text {
  85. font-size: 22rpx;
  86. color: #999;
  87. }
  88. }
  89. .more-box {
  90. white-space: nowrap;
  91. font-size: 22rpx;
  92. color: #999;
  93. position: absolute;
  94. top: 50%;
  95. transform: translateY(-50%);
  96. right: 20rpx;
  97. }
  98. }
  99. </style>