运维小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. Component({
  2. data: {
  3. tabList: [], // 动态生成的tab列表
  4. currentPath: '' // 当前页面路径
  5. },
  6. attached() {
  7. // 获取当前页面路径
  8. setTimeout(() => {
  9. const pages = getCurrentPages();
  10. console.log(pages);
  11. this.setData({
  12. currentPath: '/' + pages[pages.length - 1].route
  13. });
  14. }, 10);
  15. // 根据角色生成对应tab列表
  16. const role = wx.getStorageSync('partnerPosition');
  17. const allTabs = [
  18. { pagePath: '/pages/index/index',
  19. text: '首页',
  20. iconPath: '/static/sz3.png', // 未选中图标
  21. selectedIconPath: '/static/sz4.png' // 选中图标
  22. },
  23. { pagePath: '/pages/tool/index',
  24. text: '工单',
  25. iconPath: '/static/tool.png', // 未选中图标
  26. selectedIconPath: '/static/tool1.png' // 选中图标
  27. },
  28. {
  29. pagePath: "/pages/setup/index",
  30. text: "我的",
  31. iconPath: "/static/user1.png",
  32. selectedIconPath: "/static/user2.png"
  33. }
  34. ];
  35. const customer = [
  36. { pagePath: '/pages/home/index',
  37. text: '首页',
  38. iconPath: '/static/sz3.png', // 未选中图标
  39. selectedIconPath: '/static/sz4.png' // 选中图标
  40. },
  41. {
  42. pagePath: "/pages/setup/index",
  43. text: "我的",
  44. iconPath: "/static/user1.png",
  45. selectedIconPath: "/static/user2.png"
  46. }
  47. ];
  48. console.log(allTabs);
  49. // 筛选当前角色可见的tab
  50. let tabList = [];
  51. if (role.partnerPosition != 5) {
  52. tabList = allTabs
  53. } else{
  54. tabList = customer
  55. }
  56. this.setData({ tabList });
  57. },
  58. methods: {
  59. // 切换tab页
  60. switchTab(e) {
  61. console.log(e);
  62. const path = e.currentTarget.dataset.path;
  63. wx.switchTab({ url: path });
  64. }
  65. }
  66. });