index.ts 1.4 KB

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