TuanPageHead.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="page-head" :class="{ fixed: fixed && scrollTop > fiexdHeight }" :style="{
  3. height: height + 'rpx',
  4. background: background,
  5. padding: padding,
  6. color: scrollTop > fiexdHeight ? fixedColor : color
  7. }">
  8. <view class="left">
  9. <slot name="left"></slot>
  10. </view>
  11. <view class="center" :style="{
  12. color: titleColor,
  13. 'font-weight': weight
  14. }">
  15. {{ title }}
  16. </view>
  17. <view class="right">
  18. <slot name="right"></slot>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. props: {
  25. height: {
  26. type: Number,
  27. default: 100
  28. },
  29. background: {
  30. type: String
  31. },
  32. padding: {
  33. type: String,
  34. default: '0 24rpx'
  35. },
  36. title: {
  37. type: String,
  38. default: ''
  39. },
  40. titleColor: {
  41. type: String
  42. },
  43. fixed: {
  44. type: Boolean,
  45. default: false
  46. },
  47. scrollTop: {
  48. type: Number,
  49. default: 0
  50. },
  51. fiexdHeight: {
  52. type: Number,
  53. default: 300
  54. },
  55. color: String,
  56. fixedColor: String,
  57. weight: String
  58. }
  59. };
  60. </script>
  61. <style lang="less" scoped>
  62. @keyframes silder {
  63. 0% {
  64. top: -100upx;
  65. }
  66. 100% {
  67. top: 0upx;
  68. // box-shadow: 0 0 0 #f40;
  69. }
  70. }
  71. .page-head {
  72. display: flex;
  73. align-items: center;
  74. box-sizing: border-box;
  75. &.fixed {
  76. position: fixed;
  77. left: 0;
  78. right: 0;
  79. top: 0;
  80. background-color: #fff;
  81. z-index: 10000000;
  82. animation: silder 200ms ease-in-out;
  83. box-shadow: 0 0 10px 2px #cdcdcd;
  84. }
  85. .left,
  86. .right {
  87. width: 120upx;
  88. height: 100%;
  89. flex-shrink: 0;
  90. }
  91. .left {
  92. display: flex;
  93. align-items: center;
  94. justify-content: flex-start;
  95. }
  96. .right {
  97. display: flex;
  98. align-items: center;
  99. justify-content: flex-end;
  100. }
  101. .center {
  102. flex: 1;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. }
  107. }
  108. </style>