index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="nav-bar" :style="{ paddingTop: 12 + BarHeight + 'px' }">
  3. <view class="go-back">
  4. <u-icon name="arrow-leftward" :color="color" size="32" @click="goBack"></u-icon>
  5. </view>
  6. <view class="nav-title" :style="{color:color}">
  7. {{ title }}
  8. </view>
  9. <view class="go-back">
  10. <slot name="right"></slot>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. props: {
  17. title: "",
  18. color: '',
  19. backUrl: {
  20. type: String,
  21. default: ''
  22. }
  23. },
  24. data() {
  25. return {
  26. BarHeight: '',
  27. };
  28. },
  29. mounted() {
  30. // #ifdef APP-PLUS
  31. let systemInfo = uni.getSystemInfoSync();
  32. this.BarHeight = systemInfo.statusBarHeight;
  33. // #endif
  34. },
  35. methods:{
  36. goBack() {
  37. if (this.backUrl) {
  38. const isTabPage = [
  39. '/pages/index/index',
  40. '/pages/index/game/gameList',
  41. '/pages/msg/index',
  42. '/pages/my/index'
  43. ].includes(this.backUrl)
  44. if (isTabPage) {
  45. uni.switchTab({
  46. url: this.backUrl
  47. })
  48. } else {
  49. uni.redirectTo({
  50. url: this.backUrl
  51. })
  52. }
  53. } else {
  54. uni.navigateBack()
  55. }
  56. }
  57. }
  58. };
  59. </script>
  60. <style lang="scss" scoped>
  61. .nav-bar {
  62. width: 100%;
  63. padding: 24rpx 32rpx 20rpx 32rpx;
  64. box-sizing: border-box;
  65. color: rgba(255, 255, 255, 1);
  66. font-family: DM Sans;
  67. font-size: 30rpx;
  68. font-weight: 700;
  69. line-height: 26px;
  70. display: flex;
  71. // justify-content: center;
  72. align-items: center;
  73. position: relative;
  74. z-index: 9999;
  75. .go-back {
  76. width: 32.61px;
  77. height: 26px;
  78. }
  79. .nav-title {
  80. flex: 1;
  81. text-align: center;
  82. }
  83. }
  84. </style>