TabBar.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <cover-view id="tabbar" class="tabbar" >
  3. <cover-view class="tabs flex-between" :style="{'padding-bottom':`${safeArea?'68rpx':'20rpx'}`}">
  4. <cover-view class="item flex-center" @click="switchTab(0)">
  5. <cover-image :src="`${assetsUrl}tabbar-friends-${tabIndex===0?'on':'off'}.png`" mode="aspectFill" class="tab-img"></cover-image>
  6. <cover-view class="tab-text font22 fw400" :class="tabIndex===0?'tab-text-active':''">
  7. 交友
  8. </cover-view>
  9. </cover-view>
  10. <cover-view class="item flex-center" @click="switchTab(1)">
  11. <cover-image :src="`${assetsUrl}tabbar-message-${tabIndex===1?'on':'off'}.png`" mode="aspectFill" class="tab-img"></cover-image>
  12. <cover-view class="tab-text font22 fw400" :class="tabIndex===1?'tab-text-active':''">
  13. 消息
  14. </cover-view>
  15. </cover-view>
  16. <cover-view class="item flex-center" @click="switchTab(2)">
  17. <cover-image :src="`${assetsUrl}tabbar-mine-${tabIndex===2?'on':'off'}.png`" mode="aspectFill" class="tab-img"></cover-image>
  18. <cover-view class="tab-text font22 fw400" :class="tabIndex===2?'tab-text-active':''">
  19. 我的
  20. </cover-view>
  21. </cover-view>
  22. </cover-view>
  23. </cover-view>
  24. </template>
  25. <script>
  26. import {hasSafeArea} from '../../util/index.js'
  27. export default {
  28. name:"TabBar",
  29. props:{
  30. tabIndex:{
  31. type:Number,
  32. default:0
  33. }
  34. },
  35. data() {
  36. return {
  37. assetsUrl:this.$util.assetsUrl,
  38. safeArea:this.$util.hasSafeArea(),
  39. list:[
  40. {
  41. pagePath: "/pages/friends/friends",
  42. text: "交友"
  43. },
  44. {
  45. pagePath: "/pages/messages/messages",
  46. text: "消息"
  47. },
  48. {
  49. pagePath: "/pages/mine/mine",
  50. text: "我的"
  51. }
  52. ],
  53. };
  54. },
  55. mounted() {
  56. },
  57. methods:{
  58. switchTab(index){
  59. console.log(index)
  60. uni.switchTab({
  61. url:this.list[index].pagePath
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .tabbar{
  69. width: 100vw;
  70. position: fixed;
  71. bottom: 0;
  72. left: 0;
  73. padding: 0 44rpx;
  74. box-sizing: border-box;
  75. background-color: $bgcolor1;
  76. z-index: 1000;
  77. .tabs{
  78. .item{
  79. flex: 1;
  80. flex-direction: column;
  81. .tab-img{
  82. width: 72rpx;
  83. height: 72rpx;
  84. }
  85. .tab-text{
  86. color: $fontcolor2;
  87. text-align: center;
  88. }
  89. .tab-text-active{
  90. color: $fontcolor5 !important;
  91. }
  92. }
  93. .add{
  94. width: 96rpx;
  95. height: 72rpx;
  96. background: linear-gradient(133deg, #7F5CFA 0%, #654AFE 100%);
  97. border-radius: 32rpx;
  98. .add-img{
  99. width: 96rpx;
  100. height: 72rpx;
  101. }
  102. }
  103. }
  104. }
  105. </style>