page-title.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view :style="`width:100%;height:${statusHeigth + 50}px;`">
  3. <view class="back-btn" :style="`height: ${statusHeigth + 50}px;`">
  4. <view class="back-box">
  5. <u-icon name="arrow-left" color="#fff" size="20" customStyle="margin:0 auto" class="arrow-left"
  6. @click="backToBefore()"></u-icon>
  7. <text class="back-text">
  8. <slot></slot>
  9. </text>
  10. <slot name="search"></slot>
  11. </view>
  12. <view class="search-box">
  13. <u-icon v-if="showSearch" name="search" color="#fff" size="30" @click="goToSearch()"></u-icon>
  14. <view v-if="rightText" @click="rightTextClick()" class="">
  15. {{rightText}}
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import {
  23. ref,
  24. defineEmits,
  25. defineProps,
  26. } from "vue";
  27. import {
  28. onLoad,
  29. onLaunch
  30. } from "@dcloudio/uni-app";
  31. /**
  32. * 标题名 插槽形式录入
  33. * @showSearch 是否展示搜索按钮
  34. * @url 搜索按钮跳转的页面
  35. * 搜索及搜索插槽功能暂不可用
  36. */
  37. const props = defineProps({
  38. showSearch: {
  39. type: Boolean,
  40. default: false
  41. },
  42. rightText: {
  43. type: String,
  44. default: null
  45. },
  46. url: {
  47. type: String,
  48. default: null
  49. }
  50. })
  51. const emit = defineEmits(['searchClick', 'rightTextClick'])
  52. let statusHeigth = ref(null)
  53. // 返回上一级
  54. function backToBefore() {
  55. uni.navigateBack({
  56. delta: 1,
  57. })
  58. };
  59. // 去到搜索页
  60. function goToSearch() {
  61. emit("searchClick")
  62. }
  63. function rightTextClick() {
  64. emit("rightTextClick")
  65. }
  66. onLoad(() => {
  67. uni.getSystemInfo({
  68. success(res) {
  69. statusHeigth.value = res.statusBarHeight
  70. }
  71. })
  72. })
  73. </script>
  74. <style lang="scss">
  75. .back-btn {
  76. position: fixed;
  77. top: 0;
  78. display: flex;
  79. width: 100%;
  80. z-index: 10000;
  81. background-color: #002F69;
  82. // box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(12, 69, 167, 0.35);
  83. font-size: 36rpx;
  84. font-weight: 500;
  85. color: #FFF;
  86. display: flex;
  87. align-items: flex-end;
  88. justify-content: space-between;
  89. .back-box {
  90. height: 50px;
  91. display: flex;
  92. align-items: center;
  93. justify-content: flex-start;
  94. .arrow-left {
  95. margin-left: 28rpx;
  96. }
  97. .back-text {
  98. margin-left: 28rpx;
  99. }
  100. }
  101. .search-box {
  102. height: 50px;
  103. display: flex;
  104. align-items: center;
  105. justify-content: flex-start;
  106. margin-right: 28rpx;
  107. color: #fff;
  108. }
  109. }
  110. </style>