useSetTabbar.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { useLoginUserStore } from '@/stores/loginUser'
  2. const loginUserStore = useLoginUserStore();
  3. export function useSetTabbar() {
  4. /**
  5. * 设置tabbar
  6. */
  7. const setTabbar = (index) => {
  8. let flag = false;
  9. let loginType = uni.getStorageSync('loginType'); //1:处理 2:报修
  10. switch(index){
  11. case 0:
  12. // 故障
  13. if(loginUserStore.loginUser.user.engineer == 1){
  14. if(loginType==1){
  15. flag = true;
  16. }else{
  17. flag = false;
  18. }
  19. }
  20. break;
  21. case 1:
  22. // 巡检
  23. if(loginUserStore.loginUser.user.engineer == 0){
  24. flag = false;
  25. }else if(loginUserStore.loginUser.menu.some(v => v.link === 'inspectionExecute')){
  26. if(loginType==1){
  27. flag = true;
  28. }else{
  29. flag = false;
  30. }
  31. }
  32. break;
  33. case 2:
  34. // 知识库
  35. if(loginUserStore.loginUser.user.engineer == 1){
  36. if(loginType==1){
  37. flag = true;
  38. }else{
  39. flag = false;
  40. }
  41. }else{
  42. flag = false;
  43. }
  44. break;
  45. case 3:
  46. // 首页
  47. if(loginUserStore.loginUser.user.engineer == 0){
  48. flag = true;
  49. }else{
  50. if(loginType==1){
  51. flag = false;
  52. }else{
  53. flag = true;
  54. }
  55. }
  56. break;
  57. case 4:
  58. // 我的报修
  59. if(loginUserStore.loginUser.user.engineer == 0){
  60. flag = true;
  61. }else{
  62. if(loginType==1){
  63. flag = false;
  64. }else{
  65. flag = true;
  66. }
  67. }
  68. break;
  69. case 5:
  70. // 我的
  71. if(loginUserStore.loginUser.user.engineer == 1){
  72. if(loginType==1){
  73. flag = true;
  74. }else{
  75. flag = false;
  76. }
  77. }else{
  78. flag = false;
  79. }
  80. break;
  81. case 6:
  82. // 设置
  83. if(loginUserStore.loginUser.user.engineer == 0){
  84. flag = true;
  85. }else{
  86. if(loginType==1){
  87. flag = false;
  88. }else{
  89. flag = true;
  90. }
  91. }
  92. break;
  93. }
  94. uni.setTabBarItem({
  95. index,
  96. visible: flag,
  97. });
  98. }
  99. return {
  100. setTabbar
  101. };
  102. }