custom-tabbar-client.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <view class="phone-client-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">{{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/client/ShouYe/shouye`,
  26. iconPath: getStaticUrl('static/images/tabbar/unselect/client-jz-icon.png'),
  27. activePath: getStaticUrl('static/images/tabbar/select/client-jz-icon.png'),
  28. },
  29. {
  30. text: '我的',
  31. path: `/pages/client/my/index`,
  32. iconPath: getStaticUrl('static/images/tabbar/unselect/client-my-icon.png'),
  33. activePath: getStaticUrl('static/images/tabbar/select/client-my-icon.png'),
  34. },
  35. ],
  36. };
  37. },
  38. methods: {
  39. switchTab(path, index) {
  40. if (index == this.currentTab) {
  41. // 同页面不刷新
  42. return;
  43. }
  44. uni.navigateTo({url: path});
  45. },
  46. },
  47. }
  48. </script>