index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. lifetimes: {
  4. ready: function () {
  5. if (this.data.count == 1) return;
  6. if (wx.getStorageSync('userauth') != 0) {
  7. //判断页面 以免一直触发
  8. const pages = getCurrentPages(),
  9. prevPage = pages[pages.length - 1];
  10. if (prevPage.route == 'pages/login/selectSite' || prevPage.route.includes('pages/tabbar/')) this.setData({
  11. Permission: ['首页', '我的']
  12. })
  13. }
  14. },
  15. },
  16. data: {
  17. active: 'home',
  18. Permission: ['首页', '我的'], //可看模块
  19. tabbarList: [{
  20. icon: 'icon-a-biaoqianlanshouyexuanzhong',
  21. acicon: 'icon-a-biaoqianlanshouyexuanzhong',
  22. text: '首页',
  23. url: '/pages/tabbar/home/index',
  24. name: 'home'
  25. },
  26. {
  27. icon: 'icon-a-biaoqianlanwode',
  28. acicon: 'icon-a-biaoqianlanwodexuanzhong',
  29. text: '我的',
  30. url: '/pages/tabbar/mine/index',
  31. name: 'mine'
  32. }
  33. ],
  34. },
  35. methods: {
  36. onChange(event) {
  37. let active = event.detail,
  38. obj = this.data.tabbarList.find(v => v.name == active);
  39. wx.switchTab({
  40. url: obj.url
  41. });
  42. this.setData({
  43. active
  44. });
  45. },
  46. init() {
  47. const page = getCurrentPages().pop();
  48. let obj = this.data.tabbarList.find(item => item.url === `/${page.route}`);
  49. this.setData({
  50. active: obj.name
  51. });
  52. },
  53. },
  54. })