index.js 1.4 KB

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