make-money.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // pages/groupPage/make-money/make-money.js
  2. import httpRequestApi from '../../../utils/APIClient';
  3. import util from '../../../utils/util';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. joinUserList: [],
  10. surplusList: [],
  11. timeList: [],
  12. productId: '',
  13. orderId: '',
  14. groupId: ''
  15. },
  16. //显示分享页
  17. share: function () {
  18. this.shareDialog.share();
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. wx.setNavigationBarTitle({
  25. title: '邀请赚取奖学金'
  26. })
  27. console.log(options.id);
  28. if(!options.id) {
  29. return false;
  30. }
  31. const orderId = options.id;
  32. const productId = options.productId;
  33. const groupId = options.groupId;
  34. this.setData({
  35. orderId,
  36. productId,
  37. groupId
  38. })
  39. httpRequestApi.getMygroupInfo(orderId).success( res => {
  40. console.log('支付详情', res.data.data);
  41. const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
  42. for(var i = 0; i < surplusNum; i++) {
  43. this.data.surplusList.push(1);
  44. }
  45. //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
  46. //时间转换
  47. const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
  48. this.setData({
  49. surplusNum,
  50. joinUserList: res.data.data.joinUserList,
  51. surplusList: this.data.surplusList,
  52. timeList,
  53. productId: res.data.data.groupPurchaseOrder.productId,
  54. groupId: res.data.data.groupPurchaseOrder.groupId
  55. })
  56. }).fail( error => {
  57. console.log('错误', error)
  58. })
  59. },
  60. /**
  61. * 生命周期函数--监听页面初次渲染完成
  62. */
  63. onReady: function () {
  64. this.shareDialog = this.selectComponent("#share-dialog");
  65. },
  66. /**
  67. * 生命周期函数--监听页面显示
  68. */
  69. onShow: function () {;
  70. },
  71. /**
  72. * 生命周期函数--监听页面隐藏
  73. */
  74. onHide: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面卸载
  78. */
  79. onUnload: function () {
  80. },
  81. /**
  82. * 页面相关事件处理函数--监听用户下拉动作
  83. */
  84. onPullDownRefresh: function () {
  85. },
  86. /**
  87. * 页面上拉触底事件的处理函数
  88. */
  89. onReachBottom: function () {
  90. },
  91. /**
  92. * 用户点击右上角分享
  93. */
  94. onShareAppMessage: function () {
  95. if (ops.from === 'button') {
  96. console.log(ops.target)
  97. }
  98. const productId = this.data.productId;
  99. const groupId = this.data.groupId;
  100. const id = this.data.orderId;
  101. return {
  102. title: '小学课文朗读',
  103. path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  104. imageUrl: '../../../static/groupImg/shareBg.png',
  105. success: function (res) {
  106. // 转发成功
  107. console.log("转发成功:" + JSON.stringify(res));
  108. var shareTickets = res.shareTickets;
  109. // if (shareTickets.length == 0) {
  110. // return false;
  111. // }
  112. // //可以获取群组信息
  113. // wx.getShareInfo({
  114. // shareTicket: shareTickets[0],
  115. // success: function (res) {
  116. // console.log(res)
  117. // }
  118. // })
  119. },
  120. fail: function (res) {
  121. // 转发失败
  122. console.log("转发失败:" + JSON.stringify(res));
  123. }
  124. }
  125. }
  126. })