index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* eslint-disable */
  2. Component({
  3. data: {
  4. active: 0,
  5. list: [
  6. {
  7. icon: 'home-o',
  8. text: '首页',
  9. url: '/pages/index/main'
  10. },
  11. {
  12. icon: 'point-gift-o',
  13. text: '套餐',
  14. url: '/pages/bundle/main'
  15. },
  16. {
  17. icon: 'location-o',
  18. text: '门店',
  19. url: '/pages/store/main'
  20. },
  21. {
  22. icon: 'friends-o',
  23. text: '我的',
  24. url: '/pages/member/main'
  25. }
  26. ]
  27. },
  28. methods: {
  29. onChange(event) {
  30. if(event.detail === 3 && !wx.getStorageSync('token')) {
  31. wx.redirectTo({
  32. url: '/pages/login/main?lanuch=true&path=' + encodeURIComponent('/pages/member/main')
  33. });
  34. } else {
  35. this.setData({ active: event.detail });
  36. wx.switchTab({
  37. url: this.data.list[event.detail].url
  38. });
  39. }
  40. },
  41. init() {
  42. const page = getCurrentPages().pop();
  43. this.setData({
  44. active: this.data.list.findIndex(item => item.url === `/${page.route}`)
  45. });
  46. }
  47. }
  48. });