tabBar.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view>
  3. <u-tabbar :value="selectedIndex" @change="name=>change(name)" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true">
  4. <u-tabbar-item name='home' :text="this.$t('tabbar.home')" icon="home"></u-tabbar-item>
  5. <u-tabbar-item name='info' :text="this.$t('tabbar.my')" icon="account"></u-tabbar-item>
  6. </u-tabbar>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. selectedIndex: getApp().globalData.tabIndex,
  14. isAuditUser:uni.getStorageSync('isAuditUser'),
  15. isDealerUser:uni.getStorageSync('isDealerUser'),
  16. }
  17. },
  18. computed: {
  19. },
  20. onReady() {
  21. console.log("golbalData.tabIndex",getApp().globalData.tabIndex);
  22. },
  23. methods: {
  24. change(e) {
  25. console.log(e,'----------------');
  26. getApp().globalData.tabIndex=e;
  27. var address= "";
  28. if(e=='home'){
  29. address= "/pages/home/home";
  30. }
  31. else if(e=='report'){
  32. address= "/pages/report/report";
  33. }
  34. else if(e=='info'){
  35. address= "/pages/info/info";
  36. }
  37. else if(e=='approval'){
  38. address= "/pages/approval/approvallist";
  39. }
  40. if(!address){
  41. uni.showToast({
  42. title: '不支持该功能,请核实',
  43. icon: 'none',
  44. duration: 3000,
  45. })
  46. return;
  47. }
  48. console.log("当前索引,", e)
  49. console.log(address);
  50. uni.switchTab({
  51. url: address
  52. })
  53. }
  54. }
  55. }
  56. </script>
  57. <style>
  58. </style>