index.js 886 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Component({
  2. data: {
  3. selected: 0,
  4. color: "#999999",
  5. selectedColor: "#4A90C2",
  6. list: [
  7. {
  8. pagePath: "/pages/home/home",
  9. text: "首页",
  10. icon: "⌂"
  11. },
  12. {
  13. pagePath: "/pages/orders/orders",
  14. text: "出行",
  15. icon: "⟐"
  16. },
  17. {
  18. pagePath: "/pages/mall/mall",
  19. text: "积分",
  20. icon: "◈"
  21. },
  22. {
  23. pagePath: "/pages/mine/mine",
  24. text: "我的",
  25. icon: "⚬"
  26. }
  27. ]
  28. },
  29. attached() {
  30. },
  31. methods: {
  32. switchTab(e) {
  33. const data = e.currentTarget.dataset
  34. const url = data.path
  35. wx.switchTab({
  36. url,
  37. success: () => {
  38. this.setData({
  39. selected: data.index
  40. })
  41. },
  42. fail: (err) => {
  43. console.error('Tab switch failed:', err)
  44. }
  45. })
  46. }
  47. }
  48. })