index.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // custom-tab-bar/index.js
  2. Component({
  3. pageLifetimes: {
  4. show: function () {
  5. const routeList = getCurrentPages()
  6. this.setData({
  7. route: routeList[routeList.length - 1].route
  8. })
  9. const userInfo = wx.getStorageSync('userInfo')
  10. if (!userInfo.isDemonstrate) {
  11. if (routeList[routeList.length - 1].route === this.data.list[1].pagePath) {
  12. wx.reLaunch({
  13. url: '/' + this.data.list[0].pagePath
  14. })
  15. }
  16. this.setData({
  17. [`list[1].showTab`]: false
  18. })
  19. }
  20. },
  21. },
  22. /**
  23. * 组件的属性列表
  24. */
  25. properties: {
  26. },
  27. /**
  28. * 组件的初始数据
  29. */
  30. data: {
  31. route: '',
  32. color: "#000000",
  33. selectedColor: "#1890FF",
  34. list: [
  35. {
  36. pagePath: "pages/my-order/my-order",
  37. iconPath: "./tabBarImage/order.png",
  38. selectedIconPath: "./tabBarImage/order-select.png",
  39. text: "我的订单",
  40. showTab: true,
  41. },
  42. {
  43. pagePath: "pages/index/index",
  44. iconPath: "./tabBarImage/home.png",
  45. selectedIconPath: "./tabBarImage/home-select.png",
  46. text: "需求大厅",
  47. showTab: true,
  48. },
  49. {
  50. pagePath: "pages/person/person",
  51. iconPath: "./tabBarImage/person.png",
  52. selectedIconPath: "./tabBarImage/person-selected.png",
  53. text: "个人中心",
  54. showTab: true,
  55. },
  56. ]
  57. },
  58. /**
  59. * 组件的方法列表
  60. */
  61. methods: {
  62. switchTab(e: any) {
  63. const data = e.currentTarget.dataset
  64. const url = data.path
  65. wx.reLaunch({ url: `/${url}` })
  66. }
  67. }
  68. })