tab-bar.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="footer">
  3. <view class="index" @click="swithTab(1)">
  4. <view><image src="../../static/tabbar/menu-1.png"></image></view>
  5. <view :class="[currentPage === 1?'current':'']">首页</view>
  6. </view>
  7. <view class="scan" @click="swithTab(2)">
  8. <view><image src="../../static/tabbar/menu-2.png"></image></view>
  9. <view class="hover">扫码换电</view>
  10. </view>
  11. <view class="index" @click="swithTab(3)">
  12. <view><image src="../../static/tabbar/menu-3.png"></image></view>
  13. <view :class="[currentPage === 3?'current':'']">我的</view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name:"tab-bar",
  20. data() {
  21. return {
  22. currentPage:0,
  23. };
  24. },
  25. mounted() {
  26. this.getRoute()
  27. },
  28. onLoad() {
  29. },
  30. methods:{
  31. swithTab(num){
  32. if(num === 1){
  33. uni.switchTab({
  34. url: '/pages/index/index',
  35. });
  36. }else if(num === 2){
  37. if(this.$store.state.users){
  38. uni.scanCode({
  39. success: function (res) {
  40. console.log('条码内容:' + res.result.split("=")[1]);
  41. }
  42. });
  43. }else{
  44. uni.navigateTo({
  45. url: '/pages/public/login?item=sancode',
  46. });
  47. }
  48. }else{
  49. if(this.$store.state.users){
  50. uni.switchTab({
  51. url: '/pages/ucenter/index',
  52. });
  53. }else{
  54. uni.navigateTo({
  55. url: '/pages/public/login?item=ucenter',
  56. });
  57. }
  58. }
  59. },
  60. getRoute(){
  61. let curPage = getCurrentPages();
  62. let route = curPage[curPage.length - 1].route
  63. if(route === 'pages/index/index'){
  64. this.currentPage=1
  65. }else if(route === 'pages/ucenter/index'){
  66. this.currentPage=3
  67. }
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .footer{
  74. width: 100%;
  75. height: 106rpx;
  76. background-image: url('https://xcx.xnymzx.com/zkstation/bbg.png');
  77. background-size: 100% 100%;
  78. position: fixed;
  79. left: 0;
  80. right: 0;
  81. bottom: 0;
  82. display: flex;
  83. justify-content: space-around;
  84. padding-top: 15rpx;
  85. box-sizing: border-box;
  86. font-size: 26rpx;
  87. image{
  88. width: 39rpx;
  89. height: 39rpx;
  90. }
  91. .index{
  92. width: 300rpx;
  93. text-align: center;
  94. }
  95. .scan{
  96. position: relative;
  97. display: flex;
  98. flex: 1;
  99. text-align: center;
  100. view:first-child{
  101. position: absolute;
  102. bottom: 30rpx;
  103. width: 100%;
  104. }
  105. view:last-child{
  106. position: absolute;
  107. bottom: 6rpx;
  108. width: 100%;
  109. }
  110. image{
  111. width: 106rpx;
  112. height: 106rpx;
  113. }
  114. }
  115. .hover{
  116. color: #58be6b;
  117. }
  118. .current{
  119. color: #959ea8;
  120. }
  121. }
  122. </style>