sign.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. const tool = require('../../utils/tool.js');
  2. const app = require('../../utils/util.js');
  3. Page({
  4. data: {
  5. },
  6. go() {
  7. // + this.data.activeId,
  8. wx.navigateTo({
  9. url: '/pages/onSiteActivity/onSiteActivity?id=' + this.data.activeId
  10. })
  11. },
  12. // getNum() {
  13. // wx.request({
  14. // url: app.globalData.publicUrl + '/wx/actives/' + this.data.openid + '/' + this.data.activeId + '/members',
  15. // method: "get",
  16. // success: (res) => {
  17. // if (res.data.code == 0) {
  18. // console.log(res.data.members, '我获取人员名单')
  19. // for (let i = 0; i < res.data.members.length; i++) {
  20. // if (res.data.members[i].openId == this.data.openid) {
  21. // this.setData({
  22. // myNum: res.data.members[i].activeNumber
  23. // })
  24. // }
  25. // }
  26. // }
  27. // }
  28. // })
  29. // },
  30. 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. console.log(res, '我签到的结果')
  36. if (res.data.code == 0) {
  37. if (res.data.activeNumber == 0) {
  38. wx.showModal({
  39. title: '您未报名此活动',
  40. content: '请联系客服呦',
  41. showCancel: false,
  42. success(res) {
  43. if (res.confirm) {
  44. wx.redirectTo({
  45. url: '/pages/index/index',
  46. })
  47. }
  48. }
  49. })
  50. } else {
  51. this.setData({
  52. myNum: res.data.activeNumber
  53. })
  54. }
  55. }
  56. }
  57. })
  58. },
  59. onLoad: function (options) {
  60. console.log(decodeURIComponent(options.q), '我是签到页带过来的参数');
  61. let url = decodeURIComponent(options.q);
  62. let after = url.split('id=')[1];
  63. tool.openidStatus().then(result => {
  64. this.setData({
  65. openid: result[0],
  66. sessionkey: result[1],
  67. activeId: after
  68. })
  69. this.sign();
  70. })
  71. },
  72. /**
  73. * 生命周期函数--监听页面初次渲染完成
  74. */
  75. onReady: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面显示
  79. */
  80. onShow: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload: function () {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh: function () {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom: function () {
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage: function () {
  106. }
  107. })