sign.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const tool = require('../../utils/tool.js');
  2. const app = require('../../utils/util.js');
  3. Page({
  4. data: {
  5. },
  6. go() {
  7. wx.navigateTo({
  8. url: '/pages/onSiteActivity/onSiteActivity',
  9. })
  10. },
  11. getNum() {
  12. wx.request({
  13. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/members',
  14. method: "get",
  15. success: (res) => {
  16. if (res.data.code == 0) {
  17. console.log(res.data.members, '我获取人员名单')
  18. for (let i = 0; i < res.data.members.length; i++) {
  19. if (res.data.members[i].openId == this.data.openid) {
  20. this.setData({
  21. myNum: res.data.members[i].activeNumber
  22. })
  23. }
  24. }
  25. }
  26. }
  27. })
  28. },
  29. sign(){
  30. // /wx/actives/{openId}/{activeId}/sign
  31. wx.request({
  32. url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/sign',
  33. method: "get",
  34. success: (res) => {
  35. if (res.data.code == 0) {
  36. console.log(res.data, '我签到成功了');
  37. this.getNum();
  38. }
  39. }
  40. })
  41. },
  42. onLoad: function (options) {
  43. console.log(options)
  44. tool.openidStatus().then(result => {
  45. this.setData({
  46. openid: result[0],
  47. sessionkey: result[1],
  48. activeId:options.id
  49. })
  50. this.sign();
  51. })
  52. },
  53. /**
  54. * 生命周期函数--监听页面初次渲染完成
  55. */
  56. onReady: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面显示
  60. */
  61. onShow: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面隐藏
  65. */
  66. onHide: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面卸载
  70. */
  71. onUnload: function () {
  72. },
  73. /**
  74. * 页面相关事件处理函数--监听用户下拉动作
  75. */
  76. onPullDownRefresh: function () {
  77. },
  78. /**
  79. * 页面上拉触底事件的处理函数
  80. */
  81. onReachBottom: function () {
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage: function () {
  87. }
  88. })