custom-tabbar-admin.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="phone-custom-tabbar">
  3. <view class="tabbar-item" v-for="(item, index) in tabList" :key="index" @click="switchTab(item.path,index)">
  4. <icon class="tabbar-item-icon" :style="{ backgroundImage: 'url(' + (currentTab == index ? item.activePath : item.iconPath) + ')' }"></icon>
  5. <text class="tabbar-item-text" :class="{active: currentTab == index}">{{item.text}}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import {getStaticUrl} from '@/utils/common.js';
  11. import {
  12. useTabBarHistory
  13. } from '@/utils/emitEvents.js';
  14. import cacheManager from "@/utils/cacheManager.js";
  15. export default {
  16. props: {
  17. currentTab: {
  18. type: Number
  19. }
  20. },
  21. data() {
  22. return {
  23. tabList: [{
  24. text: '首页',
  25. path: `/pages/admin/ShouYe/shouye`,
  26. iconPath: getStaticUrl('static/images/tabbar/unselect/index-icon.png'),
  27. activePath: getStaticUrl('static/images/tabbar/select/index-icon.png'),
  28. },
  29. {
  30. text: '家政',
  31. path: '/pages/admin/Jiazheng/index',
  32. iconPath: getStaticUrl('static/images/tabbar/unselect/jz-icon.png'),
  33. activePath: getStaticUrl('static/images/tabbar/select/jz-icon.png'),
  34. },
  35. {
  36. text: '我的',
  37. path: `/pages/admin/my/index`,
  38. iconPath: getStaticUrl('static/images/tabbar/unselect/my-icon.png'),
  39. activePath: getStaticUrl('static/images/tabbar/select/my-icon.png'),
  40. },
  41. ],
  42. };
  43. },
  44. methods: {
  45. switchTab(path, index) {
  46. uni.reLaunch({
  47. url: path
  48. });
  49. },
  50. },
  51. }
  52. </script>
  53. <style scoped>
  54. .tabbar-item-box {
  55. display: flex;
  56. justify-content: space-around;
  57. align-items: center;
  58. height: 60px;
  59. line-height: 60px;
  60. /* 其他样式 */
  61. }
  62. .tab-item {
  63. flex: 1;
  64. /* 样式 */
  65. }
  66. .tab-icon {
  67. /* 图标样式 */
  68. }
  69. </style>