NavigationBar.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div>
  3. <div class="page-head" :class="[modelData.style === 1 ? 'style-one' : modelData.style === 2 ? 'style-two' : 'style-three']" :style="style">
  4. <div v-if="modelData.style === 2" :style="{ background: modelData.topBgColor }" class="circular"></div>
  5. </div>
  6. <u-navbar :background="{ background: background }" :title-color="modelData.textColor" :border-bottom="false" :is-back="false" :title="modelData.name">
  7. <div class="address-div ellipsis" @click="openLocation">
  8. <u-icon name="map-fill" color="#9fa8bd" size="30"></u-icon>
  9. <span style="margin-left: 10rpx;">{{ location.districtName || '点击定位' }}</span>
  10. </div>
  11. </u-navbar>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'NavigationBar',
  17. props: {
  18. modelData: {
  19. type: Object,
  20. default: () => {
  21. return {};
  22. }
  23. },
  24. scrollTop: {
  25. type: Number,
  26. default: 0
  27. }
  28. },
  29. computed: {
  30. style() {
  31. if (this.modelData.style === 3) {
  32. return `background-color:${this.modelData.topBgColor};color:${this.modelData.textColor}`;
  33. } else if (this.modelData.style === 1) {
  34. return `background:linear-gradient(360deg,rgba(255, 255, 255, 0) 0%,${this.modelData.topBgColor} 100%,${this.modelData.topBgColor} 100%);color:${
  35. this.modelData.textColor
  36. }`;
  37. } else {
  38. return `color:${this.modelData.textColor}`;
  39. }
  40. },
  41. location() {
  42. return this.$store.state.locationObj;
  43. },
  44. background() {
  45. if (this.modelData.style === 1) {
  46. return this.$u.colorToRgba(this.$_utils.hexify(this.modelData.topBgColor), this.scrollTop/100)
  47. } else {
  48. return this.modelData.topBgColor;
  49. }
  50. }
  51. },
  52. methods: {
  53. openLocation() {
  54. this.$emit('openLocation');
  55. }
  56. }
  57. };
  58. </script>
  59. <style scoped lang="scss">
  60. .page-head {
  61. // height: 226px;
  62. height: 100vh;
  63. width: 750rpx;
  64. position: fixed;
  65. top: 0;
  66. left: 0;
  67. width: 100%;
  68. }
  69. .style-two {
  70. overflow: hidden;
  71. .circular {
  72. width: 140%;
  73. height: 200px;
  74. position: absolute;
  75. left: -20%;
  76. top: 0;
  77. border-radius: 0 0 50% 50%;
  78. background: #ec1c24;
  79. }
  80. }
  81. .address-div {
  82. position: absolute;
  83. top: 50%;
  84. transform: translateY(-50%);
  85. padding: 0 10rpx;
  86. left: 24rpx;
  87. width: 180rpx;
  88. height: 66rpx;
  89. background: #ffffff;
  90. border-radius: 66rpx;
  91. line-height: 66rpx;
  92. text-align: center;
  93. font-size: 26rpx;
  94. font-weight: 500;
  95. border: 1px solid #eeeeee;
  96. color: #111111;
  97. -webkit-line-clamp: 1;
  98. }
  99. .style-one {
  100. background: linear-gradient(360deg, rgba(255, 255, 255, 0) 0%, #ec1c24 100%);
  101. }
  102. .style-three {
  103. background: #ec1c24;
  104. }
  105. </style>