onSiteActivity.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. const app = require('../../utils/util.js');
  2. const tool = require('../../utils/tool.js');
  3. Page({
  4. data: {
  5. checkArr: [],
  6. member: [],
  7. planHeart: 0,
  8. heartTime: 0,
  9. myNum: 0
  10. },
  11. goTousu() {
  12. wx.switchTab({
  13. url: '/pages/service/service',
  14. })
  15. },
  16. love(e) {
  17. console.log(e)
  18. let status = this.data.member[e.currentTarget.dataset.index].hearted
  19. let status1 = 'member['+e.currentTarget.dataset.index+'].hearted'
  20. console.log(status)
  21. if (status == 0) {
  22. wx.request({
  23. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/unfollow',
  24. method: "get",
  25. data: {
  26. targetId: e.currentTarget.dataset.openid
  27. },
  28. success: (res) => {
  29. if (res.data.code == 0) {
  30. console.log(res, '我取消心动了')
  31. this.setData({
  32. [status1]:1,
  33. member:this.data.member
  34. })
  35. console.log(this.data.member)
  36. this.getMyheartNowTimes();
  37. }
  38. }
  39. })
  40. } else {
  41. wx.request({
  42. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/heartbeat',
  43. method: "get",
  44. data: {
  45. targetId: e.currentTarget.dataset.openid
  46. },
  47. success: (res) => {
  48. if (res.data.code == 0) {
  49. console.log(res, '我心动了')
  50. this.setData({
  51. [status1]:0,
  52. member:this.data.member
  53. })
  54. console.log(this.data.member)
  55. this.getMyheartNowTimes();
  56. }
  57. }
  58. })
  59. }
  60. },
  61. // 获取我的心动次数
  62. getMyheartNowTimes() {
  63. wx.request({
  64. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/myHearts',
  65. method: "get",
  66. success: (res) => {
  67. console.log(res, '查询目前心动次数')
  68. if (res.data.code == 0) {
  69. this.setData({
  70. heartTime: res.data.heartCount
  71. })
  72. }
  73. }
  74. })
  75. },
  76. getActivies() {
  77. wx.request({
  78. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/detail',
  79. method: "get",
  80. success: (res) => {
  81. console.log(res, '查询活动详情获取心动上限次数')
  82. if (res.data.code == 0) {
  83. this.setData({
  84. planHeart: Number(res.data.activeRoll.planHeart)
  85. })
  86. }
  87. }
  88. })
  89. wx.request({
  90. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/members',
  91. method: "get",
  92. success: (res) => {
  93. if (res.data.code == 0) {
  94. console.log(res.data.members, '我获取人员名单')
  95. for (let i = 0; i < res.data.members.length; i++) {
  96. if (res.data.members[i].openId == this.data.openid) {
  97. this.setData({
  98. myNum: res.data.members[i].activeNumber
  99. })
  100. // 删除自己
  101. res.data.members.splice(i,1);
  102. }
  103. }
  104. this.setData({
  105. member: res.data.members
  106. })
  107. }
  108. }
  109. })
  110. },
  111. async onLoad(options) {
  112. tool.openidStatus().then(result => {
  113. this.setData({
  114. openid: result[0],
  115. sessionkey: result[1],
  116. activeId: options.id
  117. })
  118. this.getActivies();
  119. this.getMyheartNowTimes();
  120. })
  121. },
  122. /**
  123. * 生命周期函数--监听页面初次渲染完成
  124. */
  125. onReady: function () {
  126. },
  127. /**
  128. * 生命周期函数--监听页面显示
  129. */
  130. onShow: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面隐藏
  134. */
  135. onHide: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面卸载
  139. */
  140. onUnload: function () {
  141. },
  142. /**
  143. * 页面相关事件处理函数--监听用户下拉动作
  144. */
  145. onPullDownRefresh: function () {
  146. },
  147. /**
  148. * 页面上拉触底事件的处理函数
  149. */
  150. onReachBottom: function () {
  151. },
  152. /**
  153. * 用户点击右上角分享
  154. */
  155. onShareAppMessage: function () {
  156. }
  157. })