index.js 780 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const app = getApp()
  2. Page({
  3. data: {
  4. menu: {
  5. show: true,
  6. top: 0,
  7. left: 0
  8. }
  9. },
  10. onLoad(options) {
  11. },
  12. onShow() {
  13. if (typeof this.getTabBar === 'function') {
  14. this.getTabBar().setData({
  15. selected: 3
  16. })
  17. }
  18. },
  19. onLongPress(e) {
  20. console.log(e);
  21. let {
  22. currentTarget,
  23. detail,
  24. touches,
  25. target
  26. } = e
  27. let remainingW = app.globalData.windowWidth - touches[0].clientX
  28. let remainingH = app.globalData.windowHeight - touches[0].clientY
  29. let wFlag = remainingW - 145 > 0
  30. let hFlag = remainingH - 200 > 0
  31. this.setData({
  32. menu: {
  33. show: true,
  34. top: hFlag ? e.detail.y : e.detail.y - 100,
  35. left: wFlag ? e.detail.x : e.detail.x - 135
  36. }
  37. })
  38. }
  39. })