const app = require('../../utils/util.js'); const tool = require('../../utils/tool.js'); Page({ data: { checkArr: [] }, love(e) { console.log(e.currentTarget.dataset.index) console.log(e.currentTarget.dataset.id) let status=this.data.checkArr[e.currentTarget.dataset.index] let statusValue = 'checkArr[' + e.currentTarget.dataset.index + ']' console.log(status) if (status) { this.setData({ [statusValue]: false }) wx.request({ url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.id + '/unfollow', method: "get", data:{ targetId:e.currentTarget.dataset.id }, success: (res) => { if (res.data.code == 0) { console.log(res, '我取消心动了') } } }) }else{ this.setData({ [statusValue]: true }) wx.request({ url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.id + '/heartbeat', method: "get", data:{ targetId:e.currentTarget.dataset.id }, success: (res) => { if (res.data.code == 0) { console.log(res, '我心动了') } } }) } }, async onLoad (options) { const getOpenid = await tool.openidStatus(); this.setData({ openid: getOpenid[0], sessionkey: getOpenid[1], activeId:options.id }) // wx.request({ // url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/sign', // method: "get", // success: (res) => { // if (res.data.code == 0) { // console.log(res, '我来到现场了') // } // } // }) wx.request({ url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/members', method: "get", success: (res) => { if (res.data.code == 0) { console.log(res.data.members, '我获取人员名单') this.setData({ member:res.data.menmbers }) let checkArr1 = []; for (let i = 0; i < res.data.members.length; i++) { checkArr1[i] = false; } this.setData({ checkArr: checkArr1 }) } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })