index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <u-navbar :title="title" :bgColor="bgColor" :titleStyle="titleStyle">
  3. <view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">
  4. <u-icon v-if="showback" name="arrow-left" size="44" :color="leftIconColor" @tap="toBack(backUrl)"></u-icon>
  5. </view>
  6. </u-navbar>
  7. </template>
  8. <script>
  9. export default {
  10. options: {
  11. styleIsolation: 'shared'
  12. },
  13. props: {
  14. title: {
  15. typeof: String,
  16. default: ''
  17. },
  18. showback: {
  19. typeof: Boolean,
  20. default: true
  21. },
  22. backUrl: {
  23. typeof: String,
  24. default: ''
  25. },
  26. bgColor: {
  27. typeof: String,
  28. default: '#ffffff'
  29. },
  30. leftIconColor: {
  31. typeof: String,
  32. default: '#111111'
  33. },
  34. titleStyle: {
  35. typeof: Object,
  36. default: {
  37. fontSize: '36rpx',
  38. fontWeight: "bold",
  39. color: '#111111'
  40. }
  41. },
  42. },
  43. data() {
  44. return {
  45. tabUrls: [
  46. '/pages/index/index',
  47. '/pages/touristMap/index',
  48. '/pages/oneCodePass/index',
  49. '/pages/service/index',
  50. '/pages/my/index'
  51. ]
  52. }
  53. },
  54. methods: {
  55. toBack(url) {
  56. if (!url) {
  57. if (uni.getStorageSync('options')) {
  58. uni.redirectTo(JSON.parse(decodeURIComponent(uni.getStorageSync('options'))));
  59. return uni.removeStorageSync('options');
  60. }
  61. let canNavBack = getCurrentPages();
  62. if (canNavBack && canNavBack.length > 1) uni.navigateBack();
  63. else uni.reLaunch({
  64. url: '/pages/index/index'
  65. })
  66. } else {
  67. if (this.tabUrls.find(u => u == url)) uni.reLaunch({
  68. url
  69. });
  70. else uni.redirectTo({
  71. url
  72. });
  73. }
  74. },
  75. toHome() {
  76. uni.reLaunch({
  77. url: '/pages/index/index'
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="less" scoped>
  84. .u-navbar--fixed {
  85. z-index: 99999 !important;
  86. }
  87. </style>