topbar.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // components/topbar.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. },
  13. attached: function() {
  14. var url =getCurrentPages()[getCurrentPages().length-1].route
  15. let dwObj = wx.getMenuButtonBoundingClientRect()
  16. let navHeight_ = (dwObj.top + dwObj.height)
  17. let capsuleTop_ = dwObj.top
  18. let windowHeight = wx.getSystemInfoSync().windowHeight
  19. this.setData({
  20. navHeight: navHeight_,
  21. capsuleTop:capsuleTop_,
  22. capHeight: dwObj.height,
  23. bodyHeight: windowHeight - navHeight_,
  24. });
  25. },
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. handleBack() {
  31. let routeLen = getCurrentPages().length;
  32. if (routeLen == 1) {
  33. wx.reLaunch({
  34. url: '/pages/welfareMall/index/index',
  35. })
  36. return
  37. }
  38. const url =getCurrentPages()[getCurrentPages().length-2].route
  39. wx.switchTab({
  40. url: "/" + url,
  41. })
  42. }
  43. }
  44. })