index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import {
  2. getAuthorityMsg,
  3. getMessageRecord,
  4. msgTopping
  5. } from '~/api/message'
  6. import reachBottom from '~/mixins/reachBottom'
  7. const app = getApp()
  8. Page({
  9. behaviors: [reachBottom],
  10. data: {
  11. targetId: "",
  12. menu: {
  13. show: false,
  14. top: 0,
  15. left: 0
  16. },
  17. authorityMsg: {},
  18. uid: ''
  19. },
  20. onLoad(options) {
  21. this.setData({
  22. uid: wx.getStorageSync('uid')
  23. })
  24. },
  25. onShow() {
  26. if (typeof this.getTabBar === 'function') {
  27. this.getTabBar().setData({
  28. selected: 3
  29. })
  30. }
  31. this.getAuthorityMsg()
  32. this.resetData()
  33. },
  34. async getAuthorityMsg() {
  35. let authorityMsg = await getAuthorityMsg()
  36. console.log(authorityMsg);
  37. this.setData({
  38. authorityMsg
  39. })
  40. },
  41. loadMore() {
  42. this.getData(getMessageRecord)
  43. console.log(this.list);
  44. },
  45. setSearch({
  46. detail
  47. }) {
  48. /* console.log(detail)
  49. if (!detail.value) {
  50. this.setData({
  51. nullList: false,
  52. list: []
  53. });
  54. }
  55. this.setData({
  56. text: detail.value
  57. }); */
  58. },
  59. async search() {
  60. if (!this.data.text) {
  61. this.setData({
  62. list: []
  63. });
  64. return;
  65. }
  66. this.setData({
  67. list,
  68. });
  69. },
  70. onLongPress(e) {
  71. console.log(e);
  72. let {
  73. currentTarget,
  74. detail,
  75. touches,
  76. target
  77. } = e
  78. let remainingW = app.globalData.windowWidth - touches[0].clientX
  79. let remainingH = app.globalData.windowHeight - touches[0].clientY
  80. let wFlag = remainingW - 145 > 0
  81. let hFlag = remainingH - 200 > 0
  82. let {
  83. receiverUid,
  84. senderUid
  85. } = currentTarget.dataset.item
  86. this.setData({
  87. targetId: receiverUid != this.data.uid ? receiverUid : senderUid,
  88. menu: {
  89. show: true,
  90. top: hFlag ? touches[0].clientY : touches[0].clientY - 100,
  91. left: wFlag ? touches[0].clientX : touches[0].clientX - 135
  92. }
  93. })
  94. },
  95. cancelMenu() {
  96. this.setData({
  97. 'menu.show': false
  98. })
  99. },
  100. async msgTopping() {
  101. await msgTopping({
  102. topUid: this.data.targetId
  103. })
  104. this.cancelMenu()
  105. this.getAuthorityMsg()
  106. this.resetData()
  107. },
  108. delMessage() {
  109. this.setData({
  110. 'menu.show': false
  111. })
  112. },
  113. jump({
  114. currentTarget
  115. }) {
  116. wx.navigateTo({
  117. url: `/pages/${currentTarget.dataset.url}/index`,
  118. })
  119. },
  120. jumpChat({
  121. currentTarget
  122. }) {
  123. console.log(currentTarget.dataset);
  124. /* wx.navigateTo({
  125. url: `/pages/${currentTarget.dataset.url}/index`,
  126. }) */
  127. },
  128. })