custom-tabbar-admin.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/Kecheng/list',
  38. iconPath: getStaticUrl('static/images/tabbar/unselect/kc-icon.png'),
  39. activePath: getStaticUrl('static/images/tabbar/select/kc-icon.png'),
  40. },
  41. {
  42. text: '我的',
  43. path: `/pages/admin/my/index`,
  44. iconPath: getStaticUrl('static/images/tabbar/unselect/my-icon.png'),
  45. activePath: getStaticUrl('static/images/tabbar/select/my-icon.png'),
  46. },
  47. ],
  48. };
  49. },
  50. methods: {
  51. switchTab(path, index) {
  52. // if (index == this.currentTab) {
  53. // // 同页面不刷新
  54. // return;
  55. // }
  56. uni.reLaunch({
  57. url: path
  58. });
  59. },
  60. },
  61. }
  62. </script>
  63. <style scoped>
  64. .tabbar-item-box {
  65. display: flex;
  66. justify-content: space-around;
  67. align-items: center;
  68. height: 60px;
  69. line-height: 60px;
  70. /* 其他样式 */
  71. }
  72. .tab-item {
  73. flex: 1;
  74. /* 样式 */
  75. }
  76. .tab-icon {
  77. /* 图标样式 */
  78. }
  79. </style>