onSiteActivity.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. const app = require('../../utils/util.js');
  2. const tool = require('../../utils/tool.js');
  3. Page({
  4. data: {
  5. checkArr: []
  6. },
  7. love(e) {
  8. console.log(e.currentTarget.dataset.index)
  9. console.log(e.currentTarget.dataset.id)
  10. let status=this.data.checkArr[e.currentTarget.dataset.index]
  11. let statusValue = 'checkArr[' + e.currentTarget.dataset.index + ']'
  12. console.log(status)
  13. if (status) {
  14. this.setData({
  15. [statusValue]: false
  16. })
  17. wx.request({
  18. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.id + '/unfollow',
  19. method: "get",
  20. data:{
  21. targetId:e.currentTarget.dataset.id
  22. },
  23. success: (res) => {
  24. if (res.data.code == 0) {
  25. console.log(res, '我取消心动了')
  26. }
  27. }
  28. })
  29. }else{
  30. this.setData({
  31. [statusValue]: true
  32. })
  33. wx.request({
  34. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.id + '/heartbeat',
  35. method: "get",
  36. data:{
  37. targetId:e.currentTarget.dataset.id
  38. },
  39. success: (res) => {
  40. if (res.data.code == 0) {
  41. console.log(res, '我心动了')
  42. }
  43. }
  44. })
  45. }
  46. },
  47. async onLoad (options) {
  48. const getOpenid = await tool.openidStatus();
  49. this.setData({
  50. openid: getOpenid[0],
  51. sessionkey: getOpenid[1],
  52. activeId:options.id
  53. })
  54. // wx.request({
  55. // url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/sign',
  56. // method: "get",
  57. // success: (res) => {
  58. // if (res.data.code == 0) {
  59. // console.log(res, '我来到现场了')
  60. // }
  61. // }
  62. // })
  63. wx.request({
  64. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/members',
  65. method: "get",
  66. success: (res) => {
  67. if (res.data.code == 0) {
  68. console.log(res.data.members, '我获取人员名单')
  69. this.setData({
  70. member:res.data.menmbers
  71. })
  72. let checkArr1 = [];
  73. for (let i = 0; i < res.data.members.length; i++) {
  74. checkArr1[i] = false;
  75. }
  76. this.setData({
  77. checkArr: checkArr1
  78. })
  79. }
  80. }
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面显示
  90. */
  91. onShow: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload: function () {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh: function () {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom: function () {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage: function () {
  117. }
  118. })