Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

nav-bar2.vue 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="nav-bar" :class="scrollTop>navHeight?'nav-bg':''" :style="{height:navHeight+'px'}">
  3. <view class="title"
  4. :style="{paddingTop:searchMarginTop+'px',height:searchHeight+'px',lineHeight:searchHeight+'px'}">
  5. <block v-if="isBack && !isAlipay">
  6. <image :src="`/static/image/icon-back.png`" :style="{height:searchHeight+'px',width:searchHeight+'px'}"
  7. class="back" @click="back(title,type)"></image>
  8. </block>
  9. <text>{{title}}</text>
  10. </view>
  11. </view>
  12. <view class="blank" :style="{height:navHeight+'px'}"></view>
  13. </template>
  14. <script setup lang="ts">
  15. import { msg } from "@/utils/utils";
  16. import {
  17. onMounted,
  18. ref
  19. } from "vue";
  20. const navHeight = ref(0)
  21. const searchMarginTop = ref(0)
  22. const searchHeight = ref(0)
  23. const searchWidth = ref(0)
  24. const isAlipay = ref(false)
  25. onMounted(() => {
  26. const type = uni.getSystemInfoSync().uniPlatform
  27. isAlipay.value = type === 'mp-alipay'
  28. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  29. const {
  30. top,
  31. width,
  32. height,
  33. right
  34. } = menuButtonInfo
  35. uni.getSystemInfo({
  36. success: (res) => {
  37. const {
  38. statusBarHeight
  39. } = res
  40. const margin = top - statusBarHeight
  41. navHeight.value = (height + statusBarHeight + (margin * 2)) //导航栏总高
  42. searchMarginTop.value = statusBarHeight + margin // 状态栏 + 胶囊按钮边距
  43. searchHeight.value = height // 与胶囊按钮同高
  44. searchWidth.value = right - width // 胶囊按钮右边坐标 - 胶囊按钮宽度 = 按钮左边可使用宽度
  45. },
  46. })
  47. })
  48. const props = defineProps({
  49. title: {
  50. type: String,
  51. default: ''
  52. },
  53. type: {
  54. type: String,
  55. default: ''
  56. },
  57. isBack: {
  58. type: Boolean,
  59. default: true
  60. },
  61. scrollTop: {
  62. type: Number,
  63. default: 0
  64. }
  65. })
  66. const back = (title, type) => {
  67. console.log("555555555", title, type)
  68. if (title == "九州ETC" && type) {
  69. uni.redirectTo({
  70. url: `/subpackage/orders/choice-product?type=${type}`
  71. })
  72. } else if (title == "ETC开户新办申请-个人" || title == "ETC开户新办申请-单位" || title == "行驶证信息上传" || title == "微信车主服务" || title == "加购权益产品" || title == "产品详情") {
  73. uni.showToast({
  74. title: '当前ETC正在办理中,终端后续可在订单管理继续办理。',
  75. icon: 'none',
  76. duration: 2000
  77. })
  78. setTimeout(function () {
  79. uni.switchTab({
  80. url: "/pages/order/order"
  81. })
  82. }, 2000)
  83. } else {
  84. uni.navigateBack({
  85. delta: 1
  86. })
  87. }
  88. }
  89. </script>
  90. <style scoped>
  91. .nav-bg {
  92. background: linear-gradient(to right, #13E7C1, #43A1E0);
  93. }
  94. .blank {
  95. width: 100%;
  96. display: none;
  97. }
  98. .nav-bar {
  99. /* background: linear-gradient(to left, #43A1E0 0%, #13E7C1 100%); */
  100. position: fixed;
  101. width: 100%;
  102. z-index: 999;
  103. }
  104. .nav-bar .title {
  105. text-align: center;
  106. width: 100%;
  107. font-size: 28rpx;
  108. font-weight: bold;
  109. position: relative;
  110. }
  111. .back {
  112. position: absolute;
  113. left: 10rpx;
  114. }
  115. </style>