tabber.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!-- 自定义底部导航栏 -->
  2. <template >
  3. <view class="cu-bar tabbar bg-white shadow foot solid-top " style="padding: 0 10px;">
  4. <view v-for="(item,index) in tabber" :key="item.text" v-if="index!=2" class="action " @click="navTo(item)">
  5. <view v-if="pagePath==item.pagePath">
  6. <view>
  7. <image :src="item.selectedIconPath" class="imagetype"></image>
  8. </view>
  9. <view v-if="index==1 && item.num!=0 || index==3 && item.num!=0" class="cu-tag badge text-yellow" :class="item.num > 99 ?'text_yuangs':'text_yuang'">
  10. <text v-if="item.num > 99">99+</text>
  11. <text v-else>{{item.num}}</text>
  12. </view>
  13. <view v-if="item.red" class="cu-tag badge bg-red" style="left: 112rpx;">
  14. </view>
  15. <text class="text-red">{{item.text}}</text>
  16. </view>
  17. <view v-else>
  18. <view>
  19. <image :src="item.iconPath" class="imagetype"></image>
  20. </view>
  21. <view v-if="index==1 && item.num!=0 || index==3 && item.num!=0" class="cu-tag badge text-yellow" :class="item.num > 99 ?'text_yuangs':'text_yuang'">
  22. <text v-if="item.num > 99">99+</text>
  23. <text v-else>{{item.num}}</text>
  24. </view>
  25. <view v-if="item.red" class="cu-tag badge bg-red" style="left: 112rpx;">
  26. </view>
  27. <text class="text-black">{{item.text}}</text>
  28. </view>
  29. </view>
  30. <!-- <view v-else style="padding: 0 15px;">
  31. <button class="cu-btn cuIcon-voicefill text-blue" style="border-radius: 50%;width: 82rpx;height: 82rpx;background-color: #fff;border: 2rpx solid #e3e1e1;font-size: 42rpx;"></button>
  32. </view> -->
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. props: {
  38. pagePath: ""
  39. },
  40. data() {
  41. return {
  42. tabber:[
  43. {
  44. "pagePath": "/pages/index/index",
  45. "iconPath": "/static/menu/index-gray.png",
  46. "selectedIconPath": "/static/menu/index.png",
  47. "text": "首页"
  48. },
  49. {
  50. "pagePath": "/pages/task/task",
  51. "iconPath": "/static/menu/task-gray.png",
  52. "selectedIconPath": "/static/menu/task.png",
  53. "text": "任务",
  54. "num":this.tabberData.taskNum
  55. },
  56. {
  57. "pagePath": "/pages/voice/voice",
  58. "iconPath": "/static/img/tabbar/yuyin.png",
  59. "selectedIconPath": "/static/img/tabbar/yuyin.png"
  60. },
  61. {
  62. "pagePath": "/pages/information/information",
  63. "iconPath": "/static/menu/information-gray.png",
  64. "selectedIconPath": "/static/menu/information.png",
  65. "text": "消息",
  66. "num":this.tabberData.newsNum
  67. },
  68. {
  69. "pagePath": "/pages/user/user",
  70. "iconPath": "/static/menu/my-gray.png",
  71. "selectedIconPath": "/static/menu/my.png",
  72. "text": "我的",
  73. "red":this.tabberData.newVersion
  74. }
  75. ]
  76. };
  77. },
  78. mounted() {
  79. },
  80. methods:{
  81. navTo(item){
  82. uni.reLaunch({
  83. url:item.pagePath
  84. })
  85. }
  86. },
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .imagetype{
  91. width:50rpx;
  92. height: 50rpx;
  93. margin-bottom: 8rpx;
  94. }
  95. .cu-tag.badge:not([class*="bg-"]) {
  96. background-color: #EF9D1E;
  97. }
  98. .text_yuangs{width: 54rpx;height: 38rpx;line-height: 38rpx;text-align: center;border-radius: 50rpx;font-size: 20rpx;}
  99. .text_yuang{width: 38rpx;height: 38rpx;line-height: 38rpx;text-align: center;border-radius: 50%;font-size: 20rpx;}
  100. </style>