s-title-block.vue 2.3 KB

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