tabbar.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view>
  3. <block v-if="style === 'glass'">
  4. <view class="tabbar footerfixed dd-glass" style="border-radius: 100rpx;">
  5. <view class="action">
  6. <navigator url="/pages/index/index" hover-class="none" open-type="reLaunch" :class="[clickClass('/pages/index/index')]">
  7. <view class="bar-icon">
  8. <view class="tn-icon-home ">
  9. </view>
  10. </view>
  11. <view class="">首页</view>
  12. </navigator>
  13. </view>
  14. <view class="action">
  15. <navigator url="/pages/paper/index" hover-class="none" open-type="reLaunch" :class="[clickClass('/pages/paper/index')]">
  16. <view class="bar-icon">
  17. <view class="tn-icon-edit-form ">
  18. </view>
  19. </view>
  20. <view class="">模拟考试</view>
  21. </navigator>
  22. </view>
  23. <view class="action">
  24. <navigator url="/pages/search/index" hover-class="none" open-type="reLaunch" :class="[clickClass('/pages/search/index')]">
  25. <view class="bar-icon">
  26. <view class="tn-icon-search ">
  27. </view>
  28. </view>
  29. <view class="">试题查询</view>
  30. </navigator>
  31. </view>
  32. <view class="action">
  33. <navigator url="/pages/room/index" hover-class="none" open-type="reLaunch" :class="[clickClass('/pages/room/index')]">
  34. <view class="bar-icon">
  35. <view class="tn-icon-menu-list ">
  36. </view>
  37. </view>
  38. <view class="">考场列表</view>
  39. </navigator>
  40. </view>
  41. <view class="action">
  42. <navigator url="/pages/user/user" hover-class="none" open-type="reLaunch" :class="[clickClass('/pages/user/user')]">
  43. <view class="bar-icon">
  44. <view class="tn-icon-my">
  45. </view>
  46. </view>
  47. <view class="">我的</view>
  48. </navigator>
  49. </view>
  50. </view>
  51. </block>
  52. <block v-if="style === 'simple'">
  53. <view style="height: 120rpx;"></view>
  54. <view class="disFix index-bottom radius20">
  55. <navigator url="/pages/index/index" hover-class="none" open-type="reLaunch">
  56. <image :src="route == '/pages/index/index' ? '/static/tabbar/index1.png' : '/static/tabbar/index.png'">
  57. </image>
  58. <text :style="'color:' + (route == '/pages/index/index' ? '#5677fc' : '#9b9b9b')">首页</text>
  59. </navigator>
  60. <navigator url="/pages/paper/index" hover-class="none" open-type="reLaunch">
  61. <image
  62. :src="route == '/pages/paper/index' ? '/static/tabbar/kaoshi1.png' : '/static/tabbar/kaoshi.png'">
  63. </image>
  64. <text :style="'color:' + (route == '/pages/paper/index' ? '#5677fc' : '#9b9b9b')">模拟考试</text>
  65. </navigator>
  66. <navigator class="index-b-center" url="/pages/search/index" hover-class="none" open-type="reLaunch">
  67. <image
  68. :src="route == '/pages/search/index' ? '/static/tabbar/chaxun1.png' : '/static/tabbar/chaxun.png'">
  69. </image>
  70. <text :style="'color:' + (route == '/pages/search/index' ? '#5677fc' : '#9b9b9b')">试题查询</text>
  71. </navigator>
  72. <!-- <navigator url="/pagesSignUp/submit/submit" hover-class="none" open-type="reLaunch">
  73. <image :src="route == '/pagesSignUp/submit/submit' ? '/static/tabbar/tiku1.png' : '/static/tabbar/tiku.png'">
  74. </image>
  75. <text :style="'color:' + (route == '/pagesSignUp/submit/submit' ? '#5677fc' : '#9b9b9b')">报名</text>
  76. </navigator>
  77. <navigator url="/pagesSignUp/list/list" hover-class="none" open-type="reLaunch">
  78. <image :src="route == '/pagesSignUp/list/list' ? '/static/tabbar/tiku1.png' : '/static/tabbar/tiku.png'">
  79. </image>
  80. <text :style="'color:' + (route == '/pagesSignUp/list/list' ? '#5677fc' : '#9b9b9b')">报名列表</text>
  81. </navigator> -->
  82. <navigator url="/pages/room/index" hover-class="none" open-type="reLaunch">
  83. <image :src="route == '/pages/room/index' ? '/static/tabbar/tiku1.png' : '/static/tabbar/tiku.png'">
  84. </image>
  85. <text :style="'color:' + (route == '/pages/room/index' ? '#5677fc' : '#9b9b9b')">考场列表</text>
  86. </navigator>
  87. <navigator url="/pages/user/user" hover-class="none" open-type="reLaunch">
  88. <image :src="route == '/pages/user/user' ? '/static/tabbar/user1.png' : '/static/tabbar/user.png'">
  89. </image>
  90. <text :style="'color:' + (route == '/pages/user/user' ? '#5677fc' : '#9b9b9b')">我的</text>
  91. </navigator>
  92. </view>
  93. </block>
  94. </view>
  95. </template>
  96. <script>
  97. export default {
  98. name: 'tabbar',
  99. props: {
  100. // 样式风格
  101. theme: {
  102. type: String,
  103. default: 'simple'
  104. },
  105. },
  106. data() {
  107. return {
  108. navbar: false,
  109. route: '',
  110. style: 'simple',
  111. page: null,
  112. };
  113. },
  114. watch: {
  115. /**
  116. * 监听user
  117. * @param value
  118. */
  119. theme(value) {
  120. if (value && value != undefined) {
  121. this.style = value
  122. }
  123. },
  124. },
  125. mounted() {
  126. var that = this;
  127. var pages = getCurrentPages();
  128. var currentPage = pages[pages.length - 1];
  129. const url = currentPage.route;
  130. const options = currentPage.options;
  131. let urlWithArgs = `/${url}?`;
  132. for (let key in options) {
  133. const value = options[key];
  134. urlWithArgs += `${key}=${value}&`;
  135. }
  136. that.route = urlWithArgs.substring(0, urlWithArgs.length - 1);
  137. // tabbar风格
  138. this.page = uni.getStorageSync('page')
  139. if (this.page?.page_tabbar_style) {
  140. this.style = this.page.page_tabbar_style
  141. }
  142. // console.log('tabbar style', this.style)
  143. },
  144. methods: {
  145. // 选中样式
  146. clickClass(url) {
  147. return this.route == url ? 'text-primary' : 'tn-color-grey'
  148. // return this.route == url ? 'tn-color-grey--dark' : 'tn-color-grey'
  149. },
  150. }
  151. };
  152. </script>
  153. <style>
  154. .page {
  155. background: transparent;
  156. }
  157. button {
  158. overflow: inherit;
  159. }
  160. .disFix {
  161. display: flex;
  162. justify-content: space-between;
  163. z-index: 999;
  164. }
  165. .index-bottom {
  166. position: fixed;
  167. /* left: 0;
  168. bottom: 1;
  169. width: 100%; */
  170. height: 90rpx;
  171. background: #ffffff;
  172. box-shadow: 0 0 2px 0 rgba(134, 133, 133, 0.5);
  173. font-size: 0;
  174. box-sizing: border-box;
  175. /* padding-bottom: 0;
  176. padding-bottom: constant(safe-area-inset-bottom);
  177. padding-bottom: env(safe-area-inset-bottom); */
  178. bottom: 30rpx;
  179. width: 95%;
  180. position: fixed;
  181. margin: 0 auto;
  182. left: 0;
  183. right: 0;
  184. }
  185. .index-bottom>navigator,
  186. .index-bottom>view,
  187. .index-bottom>button {
  188. /* width: 20%; */
  189. flex: 1;
  190. display: inline-block;
  191. text-align: center;
  192. }
  193. .index-bottom>button image {
  194. display: block;
  195. }
  196. .index-bottom>button {
  197. border-radius: 0px;
  198. padding: 0px;
  199. line-height: 15px;
  200. background: transparent;
  201. font-size: 20rpx;
  202. margin: 0 auto;
  203. }
  204. .index-bottom>button::after {
  205. border: none;
  206. }
  207. .index-bottom text {
  208. font-size: 20rpx;
  209. }
  210. .index-bottom image {
  211. display: block;
  212. width: 38rpx;
  213. height: 38rpx;
  214. margin: 14rpx auto 6rpx;
  215. }
  216. .index-b-center {
  217. position: relative;
  218. width: 90rpx;
  219. height: 90rpx;
  220. margin: -40rpx 0 0;
  221. }
  222. .index-bottom .index-b-center image {
  223. width: 76rpx;
  224. height: 76rpx;
  225. }
  226. /* 底部tabbar 毛玻璃风格 start*/
  227. .footerfixed {
  228. position: fixed;
  229. // margin: 20rpx;
  230. margin: 40rpx 30rpx;
  231. width: 690rpx;
  232. bottom: calc(env(safe-area-inset-bottom) / 2);
  233. z-index: 999;
  234. background-color: rgba(255, 255, 255, 0.5);
  235. box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
  236. }
  237. .tabbar {
  238. display: flex;
  239. align-items: center;
  240. min-height: 110rpx;
  241. justify-content: space-between;
  242. padding: 0;
  243. height: calc(110rpx + env(safe-area-inset-bottom) / 2);
  244. // padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  245. }
  246. .tabbar .action {
  247. font-size: 22rpx;
  248. position: relative;
  249. flex: 1;
  250. text-align: center;
  251. padding: 0;
  252. display: block;
  253. height: auto;
  254. line-height: 1;
  255. margin: 0;
  256. overflow: initial;
  257. }
  258. .tabbar .action .bar-icon {
  259. width: 100rpx;
  260. position: relative;
  261. display: block;
  262. height: auto;
  263. margin: 0 auto 10rpx;
  264. text-align: center;
  265. font-size: 42rpx;
  266. }
  267. .tabbar .action .bar-icon image {
  268. width: 50rpx;
  269. height: 50rpx;
  270. display: inline-block;
  271. }
  272. /* 毛玻璃*/
  273. .dd-glass {
  274. width: 690rpx;
  275. backdrop-filter: blur(20rpx);
  276. -webkit-backdrop-filter: blur(20rpx);
  277. }
  278. </style>