|
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 |
| - |
12 |
| - <!-- #ifdef H5-DEMO --> |
13 |
| - |
14 |
| - <uni-link class="phone-link" href="/en" text="英文版"></uni-link> |
15 |
| - <uni-link class="phone-link" href="https://m3w.cn/uniapp" text="体验手机版"></uni-link> |
16 |
| - <!-- #ifdef VUE2 --> |
17 |
| - <uni-link class="phone-link" href="http://vue3-hellouniapp.dcloud.net.cn/pages/component/view/view" text="体验 vue 3.0 版"></uni-link> |
18 |
| - <svg t="1628163727478" class="new-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" |
19 |
| - p-id="1334" width="40" height="40"> |
20 |
| - <path |
21 |
| - 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" |
22 |
| - p-id="1335" fill="#d81e06"></path> |
23 |
| - </svg> |
24 |
| - <!-- #endif --> |
25 |
| - <!-- #ifdef VUE3 --> |
26 |
| - <uni-link class="phone-link" href="http://hellouniapp.dcloud.net.cn/" text="体验 vue 2.x 版"></uni-link> |
27 |
| - <!-- #endif --> |
28 |
| - |
29 |
| - <!-- #endif --> |
30 |
| - </view> |
31 |
| -</template> |
32 |
| - |
33 |
| -<script> |
34 |
| - export default { |
35 |
| - data() { |
36 |
| - return { |
37 |
| - selected: { |
38 |
| - component: 0, |
39 |
| - API: 1, |
40 |
| - extUI: 2, |
41 |
| - template: 3 |
42 |
| - }, |
43 |
| - current: 0, |
44 |
| - indexPage: [{ |
45 |
| - tabBar: '/pages/tabBar/component/component', |
46 |
| - index: '/pages/component/view/view' |
47 |
| - }, { |
48 |
| - tabBar: '/pages/tabBar/API/API', |
49 |
| - index: '/pages/API/set-navigation-bar-title/set-navigation-bar-title' |
50 |
| - }, { |
51 |
| - tabBar: '/pages/tabBar/extUI/extUI', |
52 |
| - index: '/pages/extUI/badge/badge' |
53 |
| - }, { |
54 |
| - tabBar: '/pages/tabBar/template/template', |
55 |
| - index: '/pages/template/nav-button/nav-button' |
56 |
| - }] |
57 |
| - } |
58 |
| - }, |
59 |
| - watch: { |
60 |
| - $route: { |
61 |
| - immediate: true, |
62 |
| - handler(newRoute) { |
63 |
| - const width = uni.getSystemInfoSync().screenWidth |
64 |
| - if (width >= 768) { |
65 |
| - let path = newRoute.path |
66 |
| - let comp |
67 |
| - if (path === '/') { |
68 |
| - comp = 'component' |
69 |
| - path = '/pages/tabBar/component/component' |
70 |
| - } else { |
71 |
| - comp = path.split('/')[2] |
72 |
| - } |
73 |
| - this.current = this.selected[comp] |
74 |
| - for (const item of this.indexPage) { |
75 |
| - if (path === item.tabBar) { |
76 |
| - uni.redirectTo({ |
77 |
| - url: item.index |
78 |
| - }) |
79 |
| - } |
80 |
| - } |
81 |
| - } |
82 |
| - } |
83 |
| - } |
84 |
| - }, |
85 |
| - mounted() {}, |
86 |
| - methods: { |
87 |
| - toSecondMenu(e) { |
88 |
| - const activeTabBar = '/' + e.pagePath |
89 |
| - for (const item of this.indexPage) { |
90 |
| - if (activeTabBar === item.tabBar) { |
91 |
| - uni.redirectTo({ |
92 |
| - url: item.index |
93 |
| - }) |
94 |
| - } |
95 |
| - } |
96 |
| - } |
97 |
| - } |
98 |
| - } |
99 |
| -</script> |
100 |
| - |
101 |
| -<style> |
102 |
| - .top-window-header { |
103 |
| - height: 60px; |
104 |
| - padding: 0 15px; |
105 |
| - display: flex; |
106 |
| - flex-direction: row; |
107 |
| - justify-content: space-between; |
108 |
| - align-items: center; |
109 |
| - box-sizing: border-box; |
110 |
| - border-bottom: 1px solid #e1e1e1; |
111 |
| - background-color: #FFFFFF; |
112 |
| - color: #333; |
113 |
| - } |
114 |
| -
|
115 |
| - .logo { |
116 |
| - display: flex; |
117 |
| - flex-direction: row; |
118 |
| - align-items: center; |
119 |
| - flex: 1; |
120 |
| - } |
121 |
| -
|
122 |
| - .logo image { |
123 |
| - height: 30px; |
124 |
| - width: 30px; |
125 |
| - } |
126 |
| -
|
127 |
| - .logo text { |
128 |
| - margin-left: 8px; |
129 |
| - } |
130 |
| -
|
131 |
| - .right-header { |
132 |
| - display: flex; |
133 |
| - flex-direction: row; |
134 |
| - color: #333; |
135 |
| - } |
136 |
| -
|
137 |
| - .right-header-item { |
138 |
| - line-height: 25px; |
139 |
| - margin-left: 40px; |
140 |
| - cursor: pointer; |
141 |
| - font-size: 16px; |
142 |
| - } |
143 |
| -
|
144 |
| - .active { |
145 |
| - color: #4cd964; |
146 |
| - border-bottom: 2px solid; |
147 |
| - } |
148 |
| -
|
149 |
| - .tab-bar-flex { |
150 |
| - width: 360px; |
151 |
| - } |
152 |
| -
|
153 |
| - .phone-link { |
154 |
| - padding-left: 20px; |
155 |
| - cursor: pointer; |
156 |
| - } |
157 |
| -
|
158 |
| - .new-icon { |
159 |
| - margin-left: -3px; |
160 |
| - /* margin-right: 5px; */ |
161 |
| - margin-top: -20px; |
162 |
| - } |
| 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 | + |
| 12 | + <!-- #ifdef H5 --> |
| 13 | + <uni-link class="phone-link" href="/en" text="英文版"></uni-link> |
| 14 | + <uni-link class="phone-link" href="https://m3w.cn/uniapp" text="体验手机版"></uni-link> |
| 15 | + |
| 16 | + <!-- #ifdef VUE2 --> |
| 17 | + <uni-link class="phone-link" href="http://vue3-hellouniapp.dcloud.net.cn/pages/component/view/view" text="体验 vue 3.0 版"></uni-link> |
| 18 | + <svg t="1628163727478" class="new-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" |
| 19 | + p-id="1334" width="40" height="40"> |
| 20 | + <path |
| 21 | + 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" |
| 22 | + p-id="1335" fill="#d81e06"></path> |
| 23 | + </svg> |
| 24 | + <!-- #endif --> |
| 25 | + <!-- #ifdef VUE3 --> |
| 26 | + <uni-link class="phone-link" href="http://hellouniapp.dcloud.net.cn/" text="体验 vue 2.x 版"></uni-link> |
| 27 | + <!-- #endif --> |
| 28 | + |
| 29 | + <!-- #endif --> |
| 30 | + </view> |
| 31 | +</template> |
| 32 | + |
| 33 | +<script> |
| 34 | + export default { |
| 35 | + data() { |
| 36 | + return { |
| 37 | + selected: { |
| 38 | + component: 0, |
| 39 | + API: 1, |
| 40 | + extUI: 2, |
| 41 | + template: 3 |
| 42 | + }, |
| 43 | + current: 0, |
| 44 | + indexPage: [{ |
| 45 | + tabBar: '/pages/tabBar/component/component', |
| 46 | + index: '/pages/component/view/view' |
| 47 | + }, { |
| 48 | + tabBar: '/pages/tabBar/API/API', |
| 49 | + index: '/pages/API/set-navigation-bar-title/set-navigation-bar-title' |
| 50 | + }, { |
| 51 | + tabBar: '/pages/tabBar/extUI/extUI', |
| 52 | + index: '/pages/extUI/badge/badge' |
| 53 | + }, { |
| 54 | + tabBar: '/pages/tabBar/template/template', |
| 55 | + index: '/pages/template/nav-button/nav-button' |
| 56 | + }] |
| 57 | + } |
| 58 | + }, |
| 59 | + watch: { |
| 60 | + $route: { |
| 61 | + immediate: true, |
| 62 | + handler(newRoute) { |
| 63 | + const width = uni.getSystemInfoSync().screenWidth |
| 64 | + if (width >= 768) { |
| 65 | + let path = newRoute.path |
| 66 | + let comp |
| 67 | + if (path === '/') { |
| 68 | + comp = 'component' |
| 69 | + path = '/pages/tabBar/component/component' |
| 70 | + } else { |
| 71 | + comp = path.split('/')[2] |
| 72 | + } |
| 73 | + this.current = this.selected[comp] |
| 74 | + for (const item of this.indexPage) { |
| 75 | + if (path === item.tabBar) { |
| 76 | + uni.redirectTo({ |
| 77 | + url: item.index |
| 78 | + }) |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + }, |
| 85 | + mounted() {}, |
| 86 | + methods: { |
| 87 | + toSecondMenu(e) { |
| 88 | + const activeTabBar = '/' + e.pagePath |
| 89 | + for (const item of this.indexPage) { |
| 90 | + if (activeTabBar === item.tabBar) { |
| 91 | + uni.redirectTo({ |
| 92 | + url: item.index |
| 93 | + }) |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | +</script> |
| 100 | + |
| 101 | +<style> |
| 102 | + .top-window-header { |
| 103 | + height: 60px; |
| 104 | + padding: 0 15px; |
| 105 | + display: flex; |
| 106 | + flex-direction: row; |
| 107 | + justify-content: space-between; |
| 108 | + align-items: center; |
| 109 | + box-sizing: border-box; |
| 110 | + border-bottom: 1px solid #e1e1e1; |
| 111 | + background-color: #FFFFFF; |
| 112 | + color: #333; |
| 113 | + } |
| 114 | +
|
| 115 | + .logo { |
| 116 | + display: flex; |
| 117 | + flex-direction: row; |
| 118 | + align-items: center; |
| 119 | + flex: 1; |
| 120 | + } |
| 121 | +
|
| 122 | + .logo image { |
| 123 | + height: 30px; |
| 124 | + width: 30px; |
| 125 | + } |
| 126 | +
|
| 127 | + .logo text { |
| 128 | + margin-left: 8px; |
| 129 | + } |
| 130 | +
|
| 131 | + .right-header { |
| 132 | + display: flex; |
| 133 | + flex-direction: row; |
| 134 | + color: #333; |
| 135 | + } |
| 136 | +
|
| 137 | + .right-header-item { |
| 138 | + line-height: 25px; |
| 139 | + margin-left: 40px; |
| 140 | + cursor: pointer; |
| 141 | + font-size: 16px; |
| 142 | + } |
| 143 | +
|
| 144 | + .active { |
| 145 | + color: #4cd964; |
| 146 | + border-bottom: 2px solid; |
| 147 | + } |
| 148 | +
|
| 149 | + .tab-bar-flex { |
| 150 | + width: 360px; |
| 151 | + } |
| 152 | +
|
| 153 | + .phone-link { |
| 154 | + padding-left: 20px; |
| 155 | + cursor: pointer; |
| 156 | + } |
| 157 | +
|
| 158 | + .new-icon { |
| 159 | + margin-left: -3px; |
| 160 | + /* margin-right: 5px; */ |
| 161 | + margin-top: -20px; |
| 162 | + } |
163 | 163 | </style>
|
0 commit comments