s-title-block.vue 2.7 KB

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