index2.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <u-navbar class="nav" :title="title" :leftIconSize="36" bgColor="#111" leftIconColor="#111"
  3. :titleStyle="titleStyle">
  4. <view class="u-nav-slot" slot="left">
  5. <u-icon name="arrow-left" size="44" color='#111' @tap="toBack(backUrl)"></u-icon>
  6. <u-line v-if="showHome" direction="column" color='#111' :hairline="false" length="0"
  7. margin="0 15rpx"></u-line>
  8. <u-icon v-if="showHome" name="home" color='#111' size="48" @tap="toHome"></u-icon>
  9. </view>
  10. </u-navbar>
  11. </template>
  12. <script>
  13. export default {
  14. options: {
  15. styleIsolation: 'shared'
  16. },
  17. props: {
  18. title: {
  19. typeof: String,
  20. default: ''
  21. },
  22. showHome: {
  23. typeof: Boolean,
  24. default: true
  25. },
  26. backUrl: {
  27. typeof: String,
  28. default: ''
  29. }
  30. },
  31. data() {
  32. return {
  33. titleStyle: {
  34. fontSize: '36rpx',
  35. fontWeight: "bold",
  36. color: "#111111"
  37. },
  38. tabUrls: [
  39. '/pages/index/index',
  40. '/pages/touristMap/index',
  41. '/pages/oneCodePass/index',
  42. '/pages/service/index',
  43. '/pages/my/index'
  44. ]
  45. }
  46. },
  47. methods: {
  48. toBack(url) {
  49. console.log(url, 'url');
  50. if (!url) {
  51. let canNavBack = getCurrentPages();
  52. if (canNavBack && canNavBack.length > 1) uni.navigateBack();
  53. else uni.navigateBack({
  54. url
  55. });
  56. } else {
  57. if (this.tabUrls.find(u => u == url)) uni.navigateBack({
  58. url
  59. });
  60. else uni.navigateBack({
  61. url
  62. });
  63. }
  64. },
  65. toHome() {
  66. uni.reLaunch({
  67. url: '/pages/index/index'
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss">
  74. ::v-deep .u-nav-slot {
  75. display: flex;
  76. padding: 8rpx 16rpx;
  77. width: 150rpx;
  78. background-color: rgba(0, 0, 0, 0.2);
  79. border-radius: 30rpx;
  80. color: #111 !important;
  81. }
  82. .nav {
  83. color: #111;
  84. background-color: transparent;
  85. }
  86. .u-navbar__content {
  87. color: #111 !important;
  88. background-color: transparent !important;
  89. }
  90. .u-status-bar {
  91. color: #111 !important;
  92. background-color: transparent !important;
  93. }
  94. .u-navbar__content__title {
  95. color: #111 !important;
  96. }
  97. </style>