custom-tabbar-admin.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. :style="{ backgroundImage: 'url(' + (currentTab == index ? item.activePath : item.iconPath) + ')' }">
  5. </view> -->
  6. <view class="tabbar-item" v-for="(item, index) in tabList" :key="index" @click="switchTab(item.path,index)">
  7. <icon class="tabbar-item-icon" :style="{ backgroundImage: 'url(' + (currentTab == index ? item.activePath : item.iconPath) + ')' }"></icon>
  8. <text class="tabbar-item-text">{{item.text}}</text>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import {getStaticUrl} from '@/utils/common.js';
  14. import {
  15. useTabBarHistory
  16. } from '@/utils/emitEvents.js';
  17. import cacheManager from "@/utils/cacheManager.js";
  18. export default {
  19. data() {
  20. return {
  21. /* tabList: [{
  22. iconPath: 'static/images/tabbar/unselect/plan-sj.png',
  23. activePath: 'static/images/tabbar/select/plan-sj.png',
  24. path: `/pages/study/index`
  25. },
  26. {
  27. iconPath: 'static/images/tabbar/unselect/partner-sj.png',
  28. activePath: 'static/images/tabbar/select/partner-sj.png',
  29. path: '/pages/game/index'
  30. },
  31. {
  32. iconPath: 'static/images/tabbar/unselect/my-sj.png',
  33. activePath: 'static/images/tabbar/select/my-sj.png',
  34. path: `/pages/my/index`
  35. },
  36. ], */
  37. tabList: [{
  38. text: '首页',
  39. path: `/pages/study/index`,
  40. iconPath: getStaticUrl('static/images/tabbar/unselect/index-icon.png'),
  41. activePath: getStaticUrl('static/images/tabbar/select/index-icon.png'),
  42. },
  43. {
  44. text: '家政',
  45. path: '/pages/game/index',
  46. iconPath: getStaticUrl('static/images/tabbar/unselect/jz-icon.png'),
  47. activePath: getStaticUrl('static/images/tabbar/select/jz-icon.png'),
  48. },
  49. {
  50. text: '我的',
  51. path: `/pages/my/index`,
  52. iconPath: getStaticUrl('static/images/tabbar/unselect/my-icon.png'),
  53. activePath: getStaticUrl('static/images/tabbar/select/my-icon.png'),
  54. },
  55. ],
  56. currentTab: 0,
  57. };
  58. },
  59. methods: {
  60. switchTab(path, index) {
  61. uni.redirectTo({
  62. url: path
  63. });
  64. /* uni.navigateTo({
  65. url: path,
  66. "animationType": "fade-in",
  67. "animationDuration":0
  68. }); */
  69. },
  70. },
  71. created() {
  72. this.currentTab = this.currentTabNumber
  73. }
  74. }
  75. </script>
  76. <style scoped>
  77. .tabbar-item-box {
  78. display: flex;
  79. justify-content: space-around;
  80. align-items: center;
  81. height: 60px;
  82. line-height: 60px;
  83. /* 其他样式 */
  84. }
  85. .tab-item {
  86. flex: 1;
  87. /* 样式 */
  88. }
  89. .tab-icon {
  90. /* 图标样式 */
  91. }
  92. </style>