custom-tabbar-admin.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. if (index == this.currentTab) {
  47. // 同页面不刷新
  48. return;
  49. }
  50. uni.reLaunch({
  51. url: path
  52. });
  53. },
  54. },
  55. }
  56. </script>
  57. <style scoped>
  58. .tabbar-item-box {
  59. display: flex;
  60. justify-content: space-around;
  61. align-items: center;
  62. height: 60px;
  63. line-height: 60px;
  64. /* 其他样式 */
  65. }
  66. .tab-item {
  67. flex: 1;
  68. /* 样式 */
  69. }
  70. .tab-icon {
  71. /* 图标样式 */
  72. }
  73. </style>