activityHistory.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // pages/activity/activityhistory/activityHistory.js
  2. const util = require('../../../utils/util.js');
  3. const api = require('../../../config/api.js');
  4. const user = require('../../../utils/user.js');
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. tabState: 1,
  11. myPost: [], //我发起的数据
  12. myJoin: [], //我参与的数据
  13. myPostQuery: {
  14. },
  15. myJoinQuery: {
  16. }
  17. },
  18. chooseTab: function (e) {
  19. console.log(e.currentTarget.dataset.state);
  20. this.setData({
  21. tabState: e.currentTarget.dataset.state
  22. })
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. let userInfo = wx.getStorageSync('userInfo');
  29. //console.info(userInfo);
  30. this.setData({
  31. userInfo: userInfo,
  32. });
  33. this.wofaqide(); //我发起的
  34. this.wochanyude(); //我参与的
  35. },
  36. wofaqide() {
  37. //我发起的
  38. let that = this;
  39. util.request(api.ActivityList, {
  40. userId: that.data.userInfo.id
  41. }).then(function (res) {
  42. console.info(res.data);
  43. if (res.errno === 0) {
  44. res.data.forEach(function (item, index) {
  45. item.shichang = util.dateDifference(item.startTime, item.endTime);
  46. })
  47. that.setData({
  48. myPost: res.data
  49. })
  50. }
  51. })
  52. },
  53. wochanyude() {
  54. let that = this;
  55. util.request(api.ActivityParticipate, {
  56. userId: that.data.userInfo.id
  57. }).then(function (res) {
  58. console.info(res.data);
  59. if (res.errno === 0) {
  60. res.data.forEach(function (item, index) {
  61. item.shichang = util.dateDifference(item.startTime, item.endTime);
  62. })
  63. that.setData({
  64. myJoin: res.data
  65. })
  66. }
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow: function () {
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload: function () {
  88. },
  89. /**
  90. * 页面相关事件处理函数--监听用户下拉动作
  91. */
  92. onPullDownRefresh: function () {
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom: function () {
  98. },
  99. async requestActivityCreate() {
  100. let tt = await util.request(api.ActivityCreate, {
  101. userId: this.data.userInfo.id
  102. }).then(function (res) {
  103. console.log(res.data);
  104. }).catch(function (err) {
  105. console.log(err);
  106. });
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. let that = this;
  113. console.log("进入邀请了");
  114. that.requestActivityCreate();
  115. return {
  116. title: "邀请好友领60元现金券",
  117. path: '/pages/index/index?rId=' + that.data.userInfo.id,
  118. // path: '/pages/index/index?rId=1',
  119. success: function (res) {
  120. // 转发成功
  121. console.log("转发成功:" + JSON.stringify(res));
  122. },
  123. fail: function (res) {
  124. // 转发失败
  125. console.log("转发失败:" + JSON.stringify(res));
  126. }
  127. };
  128. },
  129. goCouponList() {
  130. wx.navigateTo({
  131. url: '/pages/ucenter/couponList/couponList',
  132. })
  133. }
  134. })