You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nav-bar2.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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,userType,orderId)"></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. orderId: {
  54. type: String,
  55. default: ''
  56. },
  57. type: {
  58. type: String,
  59. default: ''
  60. },
  61. userType: {
  62. type: String,
  63. default: ''
  64. },
  65. isBack: {
  66. type: Boolean,
  67. default: true
  68. },
  69. scrollTop: {
  70. type: Number,
  71. default: 0
  72. }
  73. })
  74. const back = (title, type, userType, orderId) => {
  75. console.log("555555555", title, type, userType, orderId)
  76. if (title == "九州ETC" && type) {
  77. uni.redirectTo({
  78. url: `/subpackage/orders/choice-product?type=${type}&&userType=${userType}`
  79. })
  80. } else if (title == "ETC开户新办申请-个人" || title == "ETC开户新办申请-单位" || title == "行驶证信息上传" || title == "微信车主服务" || title == "加购权益产品" || title == "产品详情" || title == "支付账户签约") {
  81. uni.showModal({
  82. content: '当前ETC正在办理中,中断后续可在订单管理中继续办理。',
  83. success: function (res) {
  84. if (res.confirm) {
  85. uni.switchTab({
  86. url: "/pages/order/order"
  87. })
  88. } else if (res.cancel) {
  89. console.log('用户点击取消');
  90. }
  91. }
  92. });
  93. } else {
  94. uni.navigateBack({
  95. delta: 1
  96. })
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. .nav-bg {
  102. background: linear-gradient(to right, #13E7C1, #43A1E0);
  103. }
  104. .blank {
  105. width: 100%;
  106. display: none;
  107. }
  108. .nav-bar {
  109. position: fixed;
  110. width: 100%;
  111. z-index: 999;
  112. }
  113. .nav-bar .title {
  114. text-align: center;
  115. width: 100%;
  116. font-size: 28rpx;
  117. font-weight: bold;
  118. position: relative;
  119. }
  120. .back {
  121. position: absolute;
  122. left: 10rpx;
  123. }
  124. </style>