onSiteActivity.js 4.1 KB

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