index.js 888 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const app = getApp();
  2. Component({
  3. data: {
  4. selected: 0,
  5. list: [{
  6. pagePath: "/pages/index/index",
  7. "iconPath": "/img/home2.png",
  8. "selectedIconPath": "/img/home.png",
  9. text: ""
  10. }, {
  11. pagePath: "/pages/my/index",
  12. "iconPath": "/img/user2.png",
  13. "selectedIconPath": "/img/user.png",
  14. text: ""
  15. }]
  16. },
  17. attached() {
  18. },
  19. methods: {
  20. switchTab(e) {
  21. const data = e.currentTarget.dataset
  22. const url = data.path;
  23. if(url === '/pages/my/index' && !app.globalData.userInfo.phone){
  24. console.log(1111);
  25. const pages = getCurrentPages();
  26. const prevPage = pages[pages.length - 1] //获取当前页面信息
  27. prevPage.setData({
  28. hideGetInfo:false
  29. })
  30. return
  31. }
  32. wx.switchTab({url})
  33. this.setData({
  34. selected: data.index
  35. })
  36. }
  37. }
  38. })