index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const app = getApp()
  2. Page({
  3. data: {
  4. messageId: '',
  5. menu: {
  6. show: false,
  7. top: 0,
  8. left: 0
  9. }
  10. },
  11. onLoad(options) {
  12. },
  13. onShow() {
  14. if (typeof this.getTabBar === 'function') {
  15. this.getTabBar().setData({
  16. selected: 3
  17. })
  18. }
  19. },
  20. onLongPress(e) {
  21. console.log(e);
  22. let {
  23. currentTarget,
  24. detail,
  25. touches,
  26. target
  27. } = e
  28. let remainingW = app.globalData.windowWidth - touches[0].clientX
  29. let remainingH = app.globalData.windowHeight - touches[0].clientY
  30. let wFlag = remainingW - 145 > 0
  31. let hFlag = remainingH - 200 > 0
  32. this.setData({
  33. messageId: currentTarget.dataset.id,
  34. menu: {
  35. show: true,
  36. top: hFlag ? touches[0].clientY : touches[0].clientY - 100,
  37. left: wFlag ? touches[0].clientX : touches[0].clientX - 135
  38. }
  39. })
  40. },
  41. cancelMenu() {
  42. this.setData({
  43. 'menu.show': false
  44. })
  45. },
  46. setIsTop() {},
  47. delMessage() {
  48. this.setData({
  49. 'menu.show': false
  50. })
  51. },
  52. jump({
  53. currentTarget
  54. }) {
  55. console.log(currentTarget);
  56. wx.navigateTo({
  57. url: `/pages/${currentTarget.dataset.url}/index`,
  58. })
  59. }
  60. })