tabBar.vue 1.6 KB

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