s-title-block.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 '@/sheep';
  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}px`,
  57. };
  58. // 标题样式
  59. const titleStyles = {
  60. color: props.data.titleColor,
  61. fontSize: `${props.data.titleSize}px`,
  62. textAlign: props.data.textAlign,
  63. };
  64. // 副标题
  65. const descStyles = {
  66. color: props.data.descriptionColor,
  67. textAlign: props.data.textAlign,
  68. fontSize: `${props.data.descriptionSize}px`,
  69. fontWeight: `${props.data.descriptionWeight}px`,
  70. };
  71. </script>
  72. <style lang="scss" scoped>
  73. .ss-title-wrap {
  74. height: 80rpx;
  75. position: relative;
  76. .title-content {
  77. .title-text {
  78. font-size: 30rpx;
  79. color: #333;
  80. }
  81. .sub-title-text {
  82. font-size: 22rpx;
  83. color: #999;
  84. }
  85. }
  86. .more-box {
  87. white-space: nowrap;
  88. font-size: 22rpx;
  89. color: #999;
  90. position: absolute;
  91. top: 50%;
  92. transform: translateY(-50%);
  93. right: 20rpx;
  94. }
  95. }
  96. </style>