tab-bar.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="tab-bar">
  3. <view class="footer">
  4. <view class="index" @click="swithTab(1)">
  5. <view>
  6. <image
  7. :src="currentPage === 1?'../../static/images/home/tab_home_on.png':'../../static/images/home/tab_home.png'">
  8. </image>
  9. </view>
  10. <view :class="[currentPage === 1?'current':'']">首页</view>
  11. </view>
  12. <view class="index" @click="swithTab(2)">
  13. <view>
  14. <image
  15. :src="currentPage === 2?'../../static/images/home/tab_service_on.png':'../../static/images/home/tab_service.png'">
  16. </image>
  17. </view>
  18. <view :class="[currentPage === 2?'current':'']">商标服务</view>
  19. </view>
  20. <view class="index" @click="swithTab(3)">
  21. <view>
  22. <image
  23. :src="currentPage === 3?'../../static/images/home/tab_mine_on.png':'../../static/images/home/tab_mine.png'">
  24. </image>
  25. </view>
  26. <view :class="[currentPage === 3?'current':'']">我的</view>
  27. </view>
  28. </view>
  29. <view class="bottom" v-if="plat.startsWith('iPhone')"></view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. name: "tab-bar",
  35. data() {
  36. return {
  37. currentPage: 0,
  38. stationCode: null,
  39. plat: uni.getSystemInfoSync().model
  40. };
  41. },
  42. mounted() {
  43. this.getRoute()
  44. },
  45. methods: {
  46. swithTab(num) {
  47. if (num === 1) {
  48. uni.switchTab({
  49. url: '/pages/index/index',
  50. });
  51. } else if (num === 2) {
  52. uni.switchTab({
  53. url: '/pages/service/index',
  54. });
  55. } else if (num === 3) {
  56. if (this.$storage.getJson("token")) {
  57. uni.switchTab({
  58. url: '/pages/ucenter/index',
  59. });
  60. } else {
  61. uni.navigateTo({
  62. url: '/pages/public/login',
  63. });
  64. }
  65. // uni.switchTab({
  66. // url: '/pages/ucenter/index',
  67. // });
  68. }
  69. },
  70. getRoute() {
  71. let curPage = getCurrentPages();
  72. let route = curPage[curPage.length - 1].route
  73. if (route === 'pages/index/index') {
  74. this.currentPage = 1
  75. } else if (route === 'pages/service/index') {
  76. this.currentPage = 2
  77. } else if (route === 'pages/ucenter/index') {
  78. this.currentPage = 3
  79. }
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. // ::v-deep .amap-logo {
  86. // opacity: 0 !important;
  87. // }
  88. // ::v-deep .amap-copyright {
  89. // opacity: 0 !important;
  90. // }
  91. .tab-bar {
  92. display: flex;
  93. flex-direction: column;
  94. position: fixed;
  95. left: 0;
  96. right: 0;
  97. bottom: 0rpx;
  98. .bottom {
  99. background-color: #fff;
  100. height: 68rpx;
  101. display: block;
  102. }
  103. .footer {
  104. width: 100%;
  105. height: 106rpx;
  106. // background-image: url(~@/static/bbg.png);
  107. // background-size: 100% 100%;
  108. background: #FFFFFF;
  109. display: flex;
  110. justify-content: space-around;
  111. padding-top: 15rpx;
  112. font-size: 26rpx;
  113. box-sizing: border-box;
  114. image {
  115. width: 39rpx;
  116. height: 39rpx;
  117. }
  118. .index {
  119. width: 240rpx;
  120. text-align: center;
  121. }
  122. .scan {
  123. position: relative;
  124. display: flex;
  125. flex: 1;
  126. text-align: center;
  127. view:first-child {
  128. position: absolute;
  129. bottom: 30rpx;
  130. width: 100%;
  131. }
  132. view:last-child {
  133. position: absolute;
  134. bottom: 6rpx;
  135. width: 100%;
  136. }
  137. image {
  138. width: 100rpx;
  139. height: 100rpx;
  140. }
  141. }
  142. .hover {
  143. color: #58be6b;
  144. }
  145. .current {
  146. color: #959ea8;
  147. }
  148. }
  149. }
  150. </style>