index.vue 2.1 KB

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