make-money.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. //时间转换
  46. const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
  47. this.setData({
  48. surplusNum,
  49. joinUserList: res.data.data.joinUserList,
  50. surplusList: this.data.surplusList,
  51. timeList,
  52. productId: res.data.data.groupPurchaseOrder.productId,
  53. groupId: res.data.data.groupPurchaseOrder.groupId
  54. })
  55. }).fail( error => {
  56. console.log('错误', error)
  57. })
  58. },
  59. /**
  60. * 生命周期函数--监听页面初次渲染完成
  61. */
  62. onReady: function () {
  63. this.shareDialog = this.selectComponent("#share-dialog");
  64. },
  65. /**
  66. * 生命周期函数--监听页面显示
  67. */
  68. onShow: function () {;
  69. },
  70. /**
  71. * 生命周期函数--监听页面隐藏
  72. */
  73. onHide: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload: function () {
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh: function () {
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage: function () {
  94. if (ops.from === 'button') {
  95. console.log(ops.target)
  96. }
  97. const productId = this.data.productId;
  98. const groupId = this.data.groupId;
  99. const id = this.data.orderId;
  100. return {
  101. title: '小学课文朗读',
  102. path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
  103. imageUrl: '../../../static/groupImg/shareBg.png',
  104. success: function (res) {
  105. // 转发成功
  106. console.log("转发成功:" + JSON.stringify(res));
  107. var shareTickets = res.shareTickets;
  108. // if (shareTickets.length == 0) {
  109. // return false;
  110. // }
  111. // //可以获取群组信息
  112. // wx.getShareInfo({
  113. // shareTicket: shareTickets[0],
  114. // success: function (res) {
  115. // console.log(res)
  116. // }
  117. // })
  118. },
  119. fail: function (res) {
  120. // 转发失败
  121. console.log("转发失败:" + JSON.stringify(res));
  122. }
  123. }
  124. }
  125. })