top-window.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="top-window-header">
  3. <view class="left-header logo">
  4. <navigator class="logo" open-type="reLaunch" url="/pages/component/view/view">
  5. <image src="../static/logo.png" mode="heightFix" style="width: 30px;"></image>
  6. <text>hello uni-app</text>
  7. </navigator>
  8. </view>
  9. <custom-tab-bar class="tab-bar-flex" direction="horizontal" :show-icon="false" :selected="current"
  10. @onTabItemTap="toSecondMenu" />
  11. <!-- #ifdef H5-DEMO -->
  12. <uni-link class="phone-link" href="/en" text="英文版"></uni-link>
  13. <uni-link class="phone-link" href="https://m3w.cn/uniapp" text="体验手机版"></uni-link>
  14. <!-- #ifdef VUE2 -->
  15. <uni-link class="phone-link" href="http://vue3-hellouniapp.dcloud.net.cn/pages/component/view/view" text="体验 vue 3.0 版"></uni-link>
  16. <svg t="1628163727478" class="new-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
  17. p-id="1334" width="40" height="40">
  18. <path
  19. d="M829.866667 313.6a64 64 0 0 1 64 64v213.333333a64 64 0 0 1-64 64H262.058667L168.32 746.666667v-106.666667h0.213333V377.6a64 64 0 0 1 64-64h597.333334z m-117.333334 78.293333H661.333333l-23.466666 138.56-19.2-136.533333h-51.2l34.133333 174.677333h68.266667l19.2-116.458666 17.066666 116.458666h68.266667l34.133333-174.677333h-51.2l-17.066666 138.538667-27.733334-140.544z m-151.466666 0h-125.866667v174.698667h125.866667v-36.138667h-78.933334v-38.165333h68.266667v-32.106667h-68.266667v-34.133333h78.933334v-34.133333z m-217.6 0h-70.4v174.698667H320v-128.512l32 128.512h70.4V391.893333h-46.933333v134.506667l-32-134.506667z"
  20. p-id="1335" fill="#d81e06"></path>
  21. </svg>
  22. <!-- #endif -->
  23. <!-- #ifdef VUE3 -->
  24. <uni-link class="phone-link" href="http://hellouniapp.dcloud.net.cn/" text="体验 vue 2.x 版"></uni-link>
  25. <!-- #endif -->
  26. <!-- #endif -->
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. selected: {
  34. component: 0,
  35. API: 1,
  36. extUI: 2,
  37. template: 3
  38. },
  39. current: 0,
  40. indexPage: [{
  41. tabBar: '/pages/tabBar/component/component',
  42. index: '/pages/component/view/view'
  43. }, {
  44. tabBar: '/pages/tabBar/API/API',
  45. index: '/pages/API/set-navigation-bar-title/set-navigation-bar-title'
  46. }, {
  47. tabBar: '/pages/tabBar/extUI/extUI',
  48. index: '/pages/extUI/badge/badge'
  49. }, {
  50. tabBar: '/pages/tabBar/template/template',
  51. index: '/pages/template/nav-button/nav-button'
  52. }]
  53. }
  54. },
  55. watch: {
  56. $route: {
  57. immediate: true,
  58. handler(newRoute) {
  59. const width = uni.getSystemInfoSync().screenWidth
  60. if (width >= 768) {
  61. let path = newRoute.path
  62. let comp
  63. if (path === '/') {
  64. comp = 'component'
  65. path = '/pages/tabBar/component/component'
  66. } else {
  67. comp = path.split('/')[2]
  68. }
  69. this.current = this.selected[comp]
  70. for (const item of this.indexPage) {
  71. if (path === item.tabBar) {
  72. uni.redirectTo({
  73. url: item.index
  74. })
  75. }
  76. }
  77. }
  78. }
  79. }
  80. },
  81. mounted() {},
  82. methods: {
  83. toSecondMenu(e) {
  84. const activeTabBar = '/' + e.pagePath
  85. for (const item of this.indexPage) {
  86. if (activeTabBar === item.tabBar) {
  87. uni.redirectTo({
  88. url: item.index
  89. })
  90. }
  91. }
  92. }
  93. }
  94. }
  95. </script>
  96. <style>
  97. .top-window-header {
  98. height: 60px;
  99. padding: 0 15px;
  100. display: flex;
  101. flex-direction: row;
  102. justify-content: space-between;
  103. align-items: center;
  104. box-sizing: border-box;
  105. border-bottom: 1px solid #e1e1e1;
  106. background-color: #FFFFFF;
  107. color: #333;
  108. }
  109. .logo {
  110. display: flex;
  111. flex-direction: row;
  112. align-items: center;
  113. flex: 1;
  114. }
  115. .logo image {
  116. height: 30px;
  117. width: 30px;
  118. }
  119. .logo text {
  120. margin-left: 8px;
  121. }
  122. .right-header {
  123. display: flex;
  124. flex-direction: row;
  125. color: #333;
  126. }
  127. .right-header-item {
  128. line-height: 25px;
  129. margin-left: 40px;
  130. cursor: pointer;
  131. font-size: 16px;
  132. }
  133. .active {
  134. color: #4cd964;
  135. border-bottom: 2px solid;
  136. }
  137. .tab-bar-flex {
  138. width: 360px;
  139. }
  140. .phone-link {
  141. padding-left: 20px;
  142. cursor: pointer;
  143. }
  144. .new-icon {
  145. margin-left: -3px;
  146. /* margin-right: 5px; */
  147. margin-top: -20px;
  148. }
  149. </style>